From 54af19f3efc09d8fb4ac8249ec3dfa4155244e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 22 Sep 2024 09:23:03 +0200 Subject: [PATCH] dir2apk: Tweaks --- Scripts/alpine/dir2apk.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Scripts/alpine/dir2apk.go b/Scripts/alpine/dir2apk.go index 7d8d8f4..baf24f7 100644 --- a/Scripts/alpine/dir2apk.go +++ b/Scripts/alpine/dir2apk.go @@ -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 { @@ -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 { @@ -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) {