summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.go22
-rw-r--r--control.read.go85
-rw-r--r--main.go3
3 files changed, 16 insertions, 94 deletions
diff --git a/build.go b/build.go
index a28e6e4..420c88e 100644
--- a/build.go
+++ b/build.go
@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "strings"
"time"
"go.wit.com/lib/debian"
@@ -188,15 +189,6 @@ func buildPackage(repo *gitpb.Repo) (bool, error) {
}
}
- controlfile := debian.MakeControlFile(me.pb)
- controlfile += "\n"
- log.Info(controlfile)
- if err := os.WriteFile("files/DEBIAN/control", []byte(controlfile), 0644); err != nil {
- me.sh.BadExit("write err files/DEBIAN/control", err)
- }
- // if !writeDebianControlFile(repo) {
- // return false, errors.New("write control file")
- // }
if shell.Exists("postinst") {
repo.RunVerbose([]string{"cp", "postinst", "files/DEBIAN/"})
}
@@ -211,6 +203,18 @@ func buildPackage(repo *gitpb.Repo) (bool, error) {
log.Info(repo.FullPath, "NOT FOUND ./build HERE")
}
+ r := repo.Run([]string{"du", "-s"})
+ if len(r.Stdout) != 1 {
+ me.sh.BadExit("du -s files/ failed", r.Error)
+ }
+ me.pb.DebInfo.InstalledSize = strings.Fields(r.Stdout[0])[0]
+ controlfile := debian.MakeControlFile(me.pb)
+ controlfile += "\n"
+ log.Info(controlfile)
+ if err := os.WriteFile("files/DEBIAN/control", []byte(controlfile), 0644); err != nil {
+ me.sh.BadExit("write err files/DEBIAN/control", err)
+ }
+
cmd := []string{"dpkg-deb", "--root-owner-group", "--build", "files", fulldebname}
result := repo.RunVerbose(cmd)
if shell.Exists(fulldebname) {
diff --git a/control.read.go b/control.read.go
index e5de915..672b99b 100644
--- a/control.read.go
+++ b/control.read.go
@@ -1,10 +1,6 @@
package main
-import (
- "strings"
- "unicode"
-)
-
+/*
func trimNonNumericPrefix(s string) string {
// Find the index of the first character that IS a digit.
firstDigitIndex := strings.IndexFunc(s, unicode.IsDigit)
@@ -18,83 +14,4 @@ func trimNonNumericPrefix(s string) string {
// Return the substring starting from the first digit.
return s[firstDigitIndex:]
}
-
-/*
-// readGitConfig reads and parses the control file
-func readControlFile(repo *gitpb.Repo) error {
- pairs := make(map[string]string)
- var key string
-
- file, err := os.Open("control")
- if err != nil {
- log.Warn("readControlFile() could not find the file")
- // return errors.New("'control': file not found")
- // if this happens, make up a fake control file
- pairs["Architecture"] = argv.Arch
- pairs["Recommends"] = ""
- pairs["Source"] = "notsure"
- if me.repo == nil {
- pairs["Description"] = "put something here"
- } else {
- pairs["Description"] = me.repo.GetGoPath()
- }
- if repo.Control == nil {
- repo.Control = make(map[string]string)
- }
- for key, value := range pairs {
- repo.Control[key] = value
- }
- if os.Getenv("GIT_AUTHOR_NAME") != "" {
- author := log.Sprintf("%s <%s>", os.Getenv("GIT_AUTHOR_NAME"), os.Getenv("GIT_AUTHOR_EMAIL"))
- repo.Control["Packager"] = author
- }
- _, fname := filepath.Split(repo.GetFullPath())
- repo.Control["Package"] = fname
- repo.Control["Version"] = trimNonNumericPrefix(repo.GetCurrentVersion())
- repo.Control["URL"] = repo.URL
- return nil
- }
- defer file.Close()
-
- pairs["Version"] = trimNonNumericPrefix(repo.GetCurrentVersion())
-
- scanner := bufio.NewScanner(file)
- for scanner.Scan() {
- line := scanner.Text()
-
- // Skip empty lines and comments
- if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, ";") {
- continue
- }
-
- // if line starts with a space, it's part of the last key
- if strings.HasPrefix(line, " ") {
- pairs[key] = pairs[key] + "\n" + strings.TrimSpace(line)
- continue
- }
-
- partsNew := strings.SplitN(line, ":", 2)
- if len(partsNew) < 2 {
- log.Warn("error on line:", line)
- continue
- }
-
- key = strings.TrimSpace(partsNew[0])
- value := strings.TrimSpace(partsNew[1])
- pairs[key] = value
- }
- if repo.Control == nil {
- repo.Control = make(map[string]string)
- }
- for key, value := range pairs {
- repo.Control[key] = value
- }
- pairs["Architecture"] = argv.Arch
-
- if err := scanner.Err(); err != nil {
- return err
- }
-
- return nil
-}
*/
diff --git a/main.go b/main.go
index 395bcc6..a38ceff 100644
--- a/main.go
+++ b/main.go
@@ -56,7 +56,8 @@ func main() {
} else {
me.pb.Architecture = argv.Arch
}
- me.pb.Version = trimNonNumericPrefix(me.repo.DebianCurrentVersion())
+ me.pb.Version = me.repo.DebianCurrentVersion(3)
+ me.pb.DebInfo.InstalledSize = "2222" // just to make the control file work
me.pb.DebInfo.URL = me.repo.URL
me.pb.DebInfo.Homepage = me.repo.URL // deprecate this usage (?)
log.Info("INITIAL PARSE RESULT:")