build RPM for peridot cli

This commit is contained in:
Neil Hanlon 2022-12-17 20:19:41 -05:00
parent dba4868fbc
commit a019665f84
Signed by: neil
GPG Key ID: 705BC21EC3C70F34
3 changed files with 53 additions and 3 deletions

View File

@ -63,6 +63,19 @@ load("//:repositories.bzl", "go_repositories")
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.22.2",

View File

@ -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 = [
@ -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 = [
@ -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,
)

View File

@ -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",
Version: Version,
}
func init() {