Skip to content

Commit

Permalink
Merge pull request #21 from djgilcrease/feature/additional-scalar-fields
Browse files Browse the repository at this point in the history
feat: add additional scalar fields
  • Loading branch information
jarondl authored Sep 23, 2019
2 parents ddaf72a + 2e41eaf commit 7a403f0
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 23 deletions.
36 changes: 24 additions & 12 deletions cmd/tar2rpm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ import (
)

var (
name = flag.String("name", "", "the package name")
version = flag.String("version", "", "the package version")
release = flag.String("release", "", "the rpm release")
arch = flag.String("arch", "noarch", "the rpm architecture")
compressor = flag.String("compressor", "gzip", "the rpm compressor")
name = flag.String("name", "", "the package name")
version = flag.String("version", "", "the package version")
release = flag.String("release", "", "the rpm release")
arch = flag.String("arch", "noarch", "the rpm architecture")
compressor = flag.String("compressor", "gzip", "the rpm compressor")
osName = flag.String("os", "linux", "the rpm os")
description = flag.String("description", "", "the rpm description")
vendor = flag.String("vendor", "", "the rpm vendor")
packager = flag.String("packager", "", "the rpm packager")
url = flag.String("url", "", "the rpm url")
licence = flag.String("licence", "", "the rpm licence name")

prein = flag.String("prein", "", "prein scriptlet contents (not filename)")
postin = flag.String("postin", "", "postin scriptlet contents (not filename)")
Expand All @@ -51,8 +57,8 @@ Options:
func main() {
flag.Usage = usage
flag.Parse()
if *name == "" || *version == "" || *release == "" {
fmt.Fprintln(os.Stderr, "name, version, and release are all required")
if *name == "" || *version == "" {
fmt.Fprintln(os.Stderr, "name and version are required")
flag.Usage()
os.Exit(2)
}
Expand Down Expand Up @@ -87,11 +93,17 @@ func main() {
r, err := rpmpack.FromTar(
i,
rpmpack.RPMMetaData{
Name: *name,
Version: *version,
Release: *release,
Arch: *arch,
Compressor: *compressor,
Name: *name,
Version: *version,
Release: *release,
Arch: *arch,
OS: *osName,
Vendor: *vendor,
Packager: *packager,
URL: *url,
Licence: *licence,
Description: *description,
Compressor: *compressor,
})
r.AddPrein(*prein)
r.AddPostin(*postin)
Expand Down
2 changes: 1 addition & 1 deletion def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pkg_tar2rpm = rule(
"data": attr.label(mandatory = True, allow_single_file = [".tar"]),
"pkg_name": attr.string(mandatory = True),
"version": attr.string(mandatory = True),
"release": attr.string(mandatory = True),
"release": attr.string(),
"prein": attr.string(),
"postin": attr.string(),
"preun": attr.string(),
Expand Down
21 changes: 17 additions & 4 deletions rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ var (

// RPMMetaData contains meta info about the whole package.
type RPMMetaData struct {
Name string
Version string
Release string
Arch string
Name,
Description,
Version,
Release,
Arch,
OS,
Vendor,
URL,
Packager,
Licence,
Compressor string
}

Expand Down Expand Up @@ -199,6 +205,13 @@ func (r *RPM) writeGenIndexes(h *index) {
h.Add(tagPayloadFlags, entry("9"))
h.Add(tagOS, entry("linux"))
h.Add(tagArch, entry(r.Arch))
h.Add(tagOS, entry(r.OS))
h.Add(tagArch, entry(r.Arch))
h.Add(tagVendor, entry(r.Vendor))
h.Add(tagLicence, entry(r.Licence))
h.Add(tagPackager, entry(r.Packager))
h.Add(tagURL, entry(r.URL))

// A package must provide itself...
h.Add(tagProvides, entry([]string{r.Name}))
h.Add(tagProvideVersion, entry([]string{r.FullVersion()}))
Expand Down
16 changes: 10 additions & 6 deletions tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ const (
sigSize = 0x03e8 // 1000
sigPayloadSize = 0x03ef // 1007

tagName = 0x03e8 // 1000
tagVersion = 0x03e9 // 1001
tagRelease = 0x03ea // 1002
tagSize = 0x03f1 // 1009
tagOS = 0x03fd // 1021
tagArch = 0x03fe // 1022
tagName = 0x03e8 // 1000
tagVersion = 0x03e9 // 1001
tagRelease = 0x03ea // 1002
tagSize = 0x03f1 // 1009
tagVendor = 0x03f3 // 1011
tagLicence = 0x03f6 // 1014
tagPackager = 0x03f7 // 1015
tagURL = 0x03fc // 1020
tagOS = 0x03fd // 1021
tagArch = 0x03fe // 1022

tagPrein = 0x03ff // 1023
tagPostin = 0x0400 // 1024
Expand Down

0 comments on commit 7a403f0

Please sign in to comment.