Skip to content

Commit

Permalink
build RPM for peridot cli
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilHanlon committed Feb 29, 2024
1 parent 64031c3 commit 4668740
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
13 changes: 13 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

go_rules_dependencies()

http_archive(
name = "rules_pkg",
urls = [
"https://github.com/bazelbuild/rules_pkg/releases/download/0.10.1/rules_pkg-0.10.1.tar.gz",
],
sha256 = "d250924a2ecc5176808fc4c25d5cf5e9e79e6346d79d5ab1c493e289e722d1d0",
)
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
rules_pkg_dependencies()

load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
find_system_rpmbuild(name="rules_pkg_rpmbuild")

go_register_toolchains(
nogo = "@peridot//:nogo",
version = "1.18.10",
Expand Down
33 changes: 33 additions & 0 deletions peridot/cmd/v1/peridot/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

load(
"@rules_pkg//pkg:mappings.bzl",
"pkg_attributes",
"pkg_files",
)
load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm")

go_library(
name = "peridot_lib",
srcs = [
Expand All @@ -20,6 +27,9 @@ go_library(
data = [
"//peridot/proto/v1:client_go",
],
x_defs = {
"Version": "{STABLE_BUILD_TAG}",
},
importpath = "peridot.resf.org/peridot/cmd/v1/peridot",
visibility = ["//visibility:private"],
deps = [
Expand All @@ -37,3 +47,26 @@ go_binary(
embed = [":peridot_lib"],
visibility = ["//visibility:public"],
)

pkg_files(
name = "peridot-files",
srcs = [":peridot"],
attributes = pkg_attributes(
user = "root",
group = "root",
mode = "0755",
),
prefix = "/usr/bin"
)

pkg_rpm(
name = "peridot-cli",
srcs = [":peridot-files"],
license = "MIT",
summary = "Peridot Command Line Interface",
version = "0.2.0",
release = "0",
architecture = "x86_64",
description = "A command line interface to interact with the Peridot build system",
source_date_epoch = 0,
)
10 changes: 7 additions & 3 deletions peridot/cmd/v1/peridot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@
package main

import (
"log"
"strings"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"log"
"strings"
)

var Version = "[unknown]"

var root = &cobra.Command{
Use: "peridot",
Use: "peridot",
Version: Version,
}

func init() {
Expand Down

0 comments on commit 4668740

Please sign in to comment.