Change -o flag from output filename to output directory

This commit is contained in:
2025-04-26 16:20:40 +03:00
parent 5085981f52
commit 903c7dce3e
3 changed files with 30 additions and 35 deletions
+3 -11
View File
@@ -15,7 +15,7 @@ import (
var rootCompilationUID = "65534"
var rootCompilationGID = "65534"
func CompileSourcePackage(archiveFilename, outputFilename string, skipChecks bool) (outputBpmPackages map[string]string, err error) {
func CompileSourcePackage(archiveFilename, outputDirectory string, skipChecks bool) (outputBpmPackages map[string]string, err error) {
// Initialize map
outputBpmPackages = make(map[string]string)
@@ -326,16 +326,8 @@ func CompileSourcePackage(archiveFilename, outputFilename string, skipChecks boo
return nil, err
}
// Set output filename if split package
if len(bpmpkg.PkgInfo.SplitPackages) != 1 {
// Get current working directory
workdir, err := os.Getwd()
if err != nil {
return nil, fmt.Errorf("could not get working directory: %s", err)
}
outputFilename = path.Join(workdir, fmt.Sprintf("%s-%s-%d.bpm", pkgInfo.Name, pkgInfo.Version, pkgInfo.Revision))
}
// Set output filename
outputFilename := path.Join(outputDirectory, fmt.Sprintf("%s-%s-%d.bpm", pkgInfo.Name, pkgInfo.Version, pkgInfo.Revision))
// Move final BPM archive
err = os.Rename(path.Join(tempDirectory, "final-archive.bpm"), outputFilename)
+3 -4
View File
@@ -473,9 +473,8 @@ func (operation *BPMOperation) Execute(verbose, force bool) error {
// Compile package if type is 'source'
if bpmpkg.PkgInfo.Type == "source" {
// Get path to compiled package directory and output filename
// Get path to compiled package directory
compiledDir := path.Join(operation.RootDir, "/var/lib/bpm/compiled/")
outputFilename := path.Join(compiledDir, fmt.Sprintf("%s-%s-%d.bpm", bpmpkg.PkgInfo.Name, bpmpkg.PkgInfo.Version, bpmpkg.PkgInfo.Revision))
// Create compiled package directory if not exists
if _, err := os.Stat(compiledDir); err != nil {
@@ -486,14 +485,14 @@ func (operation *BPMOperation) Execute(verbose, force bool) error {
}
// Compile source package
outputBpmPackages, err := CompileSourcePackage(value.File, outputFilename, false)
outputBpmPackages, err := CompileSourcePackage(value.File, compiledDir, false)
if err != nil {
return fmt.Errorf("could not compile source package (%s): %s\n", value.File, err)
}
// Set values
fileToInstall = outputBpmPackages[bpmpkg.PkgInfo.Name]
bpmpkg, err = ReadPackage(outputFilename)
bpmpkg, err = ReadPackage(fileToInstall)
if err != nil {
return fmt.Errorf("could not read package (%s): %s\n", fileToInstall, err)
}