mirror of
https://github.com/EnumeratedDev/bpm-utils.git
synced 2026-09-25 23:16:13 +00:00
Compare commits
3
Commits
7.0.0
...
154f546b7f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
154f546b7f
|
||
|
|
c4a0e9f860
|
||
|
|
b9d7dfd9d0
|
@@ -20,6 +20,7 @@ import (
|
|||||||
|
|
||||||
var compile = flag.BoolP("compile", "c", false, "Compile BPM source package")
|
var compile = flag.BoolP("compile", "c", false, "Compile BPM source package")
|
||||||
var skipCheck = flag.BoolP("skip-checks", "s", false, "Skip 'check' function while compiling")
|
var skipCheck = flag.BoolP("skip-checks", "s", false, "Skip 'check' function while compiling")
|
||||||
|
var keepCompilationFiles = flag.BoolP("keep", "k", false, "Keep compilation files after successful package compilation")
|
||||||
var installDepends = flag.BoolP("depends", "d", false, "Install package dependencies for compilation")
|
var installDepends = flag.BoolP("depends", "d", false, "Install package dependencies for compilation")
|
||||||
var installPackage = flag.BoolP("install", "i", false, "Install compiled BPM package after compilation finishes")
|
var installPackage = flag.BoolP("install", "i", false, "Install compiled BPM package after compilation finishes")
|
||||||
var moveToBinaryDir = flag.BoolP("move", "m", false, "Move output packages to the current repository's binary directory")
|
var moveToBinaryDir = flag.BoolP("move", "m", false, "Move output packages to the current repository's binary directory")
|
||||||
@@ -163,6 +164,9 @@ func compilePackage(archive string) {
|
|||||||
if *skipCheck {
|
if *skipCheck {
|
||||||
args = append(args, "-s")
|
args = append(args, "-s")
|
||||||
}
|
}
|
||||||
|
if *keepCompilationFiles {
|
||||||
|
args = append(args, "-k")
|
||||||
|
}
|
||||||
if *installDepends {
|
if *installDepends {
|
||||||
args = append(args, "-d")
|
args = append(args, "-d")
|
||||||
}
|
}
|
||||||
@@ -231,11 +235,13 @@ func compilePackage(archive string) {
|
|||||||
os.Rename(line, newPath)
|
os.Rename(line, newPath)
|
||||||
outputPkgs[pkgInfo.Name] = newPath
|
outputPkgs[pkgInfo.Name] = newPath
|
||||||
|
|
||||||
bpmutilsshared.UpdateDatabases(repo)
|
|
||||||
} else {
|
} else {
|
||||||
outputPkgs[pkgInfo.Name] = line
|
outputPkgs[pkgInfo.Name] = line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if repo := bpmutilsshared.GetRepository(); repo != "" && *moveToBinaryDir {
|
||||||
|
bpmutilsshared.UpdateDatabases(repo)
|
||||||
|
}
|
||||||
|
|
||||||
// Print out generated packages
|
// Print out generated packages
|
||||||
for k, v := range outputPkgs {
|
for k, v := range outputPkgs {
|
||||||
|
|||||||
@@ -58,31 +58,44 @@ func GenerateDatabase(path string) error {
|
|||||||
// Initialize database entry
|
// Initialize database entry
|
||||||
entry := BPMDatabaseEntry{}
|
entry := BPMDatabaseEntry{}
|
||||||
entry.DownloadSize = info.Size()
|
entry.DownloadSize = info.Size()
|
||||||
|
entry.InstalledSize = 0
|
||||||
entry.Filepath, err = filepath.Rel(path, packagePath)
|
entry.Filepath, err = filepath.Rel(path, packagePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get package installed size
|
|
||||||
cmd := exec.Command("tar", "-t", "-v", "-f", packagePath, "files.tar.gz")
|
|
||||||
output, err := cmd.Output()
|
|
||||||
if err == nil {
|
|
||||||
entry.InstalledSize, err = strconv.ParseInt(strings.Fields(string(output))[2], 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else if err.(*exec.ExitError).ExitCode() == 2 {
|
|
||||||
entry.InstalledSize = 0
|
|
||||||
} else {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get package info
|
// Get package info
|
||||||
entry.PackageInfo, err = ReadPacakgeInfoFromTarball(packagePath)
|
entry.PackageInfo, err = ReadPacakgeInfoFromTarball(packagePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get package installed size
|
||||||
|
if entry.PackageInfo.Type == "binary" {
|
||||||
|
cmd := exec.Command("tar", "xf", packagePath, "pkg.files", "-O")
|
||||||
|
output, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, line := range strings.Split(string(output), "\n") {
|
||||||
|
line = strings.TrimSpace(line)
|
||||||
|
if line == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
stringEntry := strings.Split(line, " ")
|
||||||
|
if len(stringEntry) < 5 {
|
||||||
|
return fmt.Errorf("pkg.files is not formatted correctly")
|
||||||
|
}
|
||||||
|
size, err := strconv.ParseInt(stringEntry[len(stringEntry)-1], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.InstalledSize += size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add entry to database
|
// Add entry to database
|
||||||
if _, ok := database.Entries[entry.PackageInfo.Name]; ok {
|
if _, ok := database.Entries[entry.PackageInfo.Name]; ok {
|
||||||
return fmt.Errorf("package (%s) has already been added to the database", entry.PackageInfo.Name)
|
return fmt.Errorf("package (%s) has already been added to the database", entry.PackageInfo.Name)
|
||||||
|
|||||||
Reference in New Issue
Block a user