Skip to content

Commit

Permalink
dir2apk: Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
remko committed Sep 22, 2024
1 parent c672e3e commit 54af19f
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Scripts/alpine/dir2apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,25 @@ func doMain() error {

docpkginfo := NewPKGInfo()
docpkginfo["arch"] = "noarch"
docpkginfo["builddate"] = strconv.FormatInt(builddate.UnixMilli(), 10)
docpkginfo["pkgver"] = *version
docpkginfo["commit"] = *commit
docpkginfo["pkgdesc"] = docpkginfo["pkgdesc"] + " (documentation)"
docpkginfo["install_if"] = fmt.Sprintf("docs %s=%s", docpkginfo["pkgname"], docpkginfo["pkgver"])
docpkginfo["pkgname"] = docpkginfo["pkgname"] + "-doc"
docpkginfo["builddate"] = pkginfo["builddate"]
docpkginfo["pkgver"] = pkginfo["pkgver"]
docpkginfo["commit"] = pkginfo["commit"]
docpkginfo["pkgdesc"] = pkginfo["pkgdesc"] + " (documentation)"
docpkginfo["install_if"] = fmt.Sprintf("docs %s=%s", pkginfo["pkgname"], pkginfo["pkgver"])
docpkginfo["pkgname"] = pkginfo["pkgname"] + "-doc"

if err := CreatePackage(docpkginfo, rootdir, isDocPath, *outdir, *keyfile, builddate); err != nil {
return err
}
return nil
}

func isDocPath(path string) bool {
return strings.Contains(path, "/man/") || strings.Contains("/licenses/", path)
}

////////////////////////////////////////////////////////////////////////////////

func CreatePackage(pkginfo PKGInfo, rootdir string, pathfilter func(string) bool, outdir string, keyfile string, buildtime time.Time) error {
datapath, size, err := CreateDataTarball(rootdir, pathfilter, buildtime)
if err != nil {
Expand Down Expand Up @@ -151,6 +158,8 @@ func CreatePackage(pkginfo PKGInfo, rootdir string, pathfilter func(string) bool
return nil
}

////////////////////////////////////////////////////////////////////////////////

func CreateDataTarball(rootdir string, pathfilter func(string) bool, buildtime time.Time) (string, int64, error) {
datafile, err := os.CreateTemp("", "apk-data")
if err != nil {
Expand Down Expand Up @@ -284,10 +293,6 @@ func CreateTarSegment(filename string, contents []byte, buildtime time.Time) ([]
return gzbuf.Bytes(), nil
}

func isDocPath(path string) bool {
return strings.Contains(path, "/man/") || strings.Contains("/licenses/", path)
}

////////////////////////////////////////////////////////////////////////////////

func sha1sum(path string) (string, error) {
Expand Down

0 comments on commit 54af19f

Please sign in to comment.