Replace .compilation-options 'ARCH' field with 'output_architecture' field in pkg.info

This commit is contained in:
2025-09-26 10:10:48 +03:00
parent 926b0e35fc
commit 264a0f87ba
2 changed files with 5 additions and 61 deletions
+3 -61
View File
@@ -31,12 +31,6 @@ func CompileSourcePackage(archiveFilename, outputDirectory string, skipChecks bo
return nil, errors.New("cannot compile a non-source package")
}
// Read compilation options file in current directory
compilationOptions, err := readCompilationOptionsFile()
if err != nil {
return nil, err
}
// Get HOME directory
homeDir, err := os.UserHomeDir()
if err != nil {
@@ -131,12 +125,7 @@ func CompileSourcePackage(archiveFilename, outputDirectory string, skipChecks bo
env = append(env, "BPM_PKG_NAME="+bpmpkg.PkgInfo.Name)
env = append(env, "BPM_PKG_VERSION="+bpmpkg.PkgInfo.Version)
env = append(env, "BPM_PKG_REVISION="+strconv.Itoa(bpmpkg.PkgInfo.Revision))
// Check for architecture override in compilation options
if val, ok := compilationOptions["ARCH"]; ok {
env = append(env, "BPM_PKG_ARCH="+val)
} else {
env = append(env, "BPM_PKG_ARCH="+GetArch())
}
env = append(env, "BPM_PKG_ARCH="+bpmpkg.PkgInfo.OutputArch)
env = append(env, CompilationBPMConfig.CompilationEnvironment...)
// Execute prepare and build functions in source.sh script
@@ -259,11 +248,8 @@ func CompileSourcePackage(archiveFilename, outputDirectory string, skipChecks bo
pkgInfo.Type = "binary"
// Set package architecture
if val, ok := compilationOptions["ARCH"]; ok {
pkgInfo.Arch = val
} else {
pkgInfo.Arch = GetArch()
}
pkgInfo.Arch = pkg.OutputArch
pkgInfo.OutputArch = ""
// Remove split package field
pkgInfo.SplitPackages = nil
@@ -337,47 +323,3 @@ func CompileSourcePackage(archiveFilename, outputDirectory string, skipChecks bo
return outputBpmPackages, nil
}
func readCompilationOptionsFile() (options map[string]string, err error) {
// Initialize options map
options = make(map[string]string)
// Check if file compilation options file exists
stat, err := os.Stat(".compilation-options")
if err != nil {
return nil, nil
}
// Ensure it is a regular file
if !stat.Mode().IsRegular() {
return nil, fmt.Errorf("%s is not a regular file", stat.Name())
}
// Read file data
data, err := os.ReadFile(stat.Name())
if err != nil {
return nil, err
}
for _, line := range strings.Split(string(data), "\n") {
// Trim line
line = strings.TrimSpace(line)
// Skip empty lines
if line == "" {
continue
}
// Split line
split := strings.SplitN(line, "=", 2)
// Throw error if line isn't valid
if len(split) < 2 {
return nil, fmt.Errorf("invalid line in compilation-options file: '%s'", line)
}
options[split[0]] = split[1]
}
return options, nil
}
+2
View File
@@ -33,6 +33,7 @@ type PackageInfo struct {
Url string `yaml:"url,omitempty"`
License string `yaml:"license,omitempty"`
Arch string `yaml:"architecture,omitempty"`
OutputArch string `yaml:"output_architecture,omitempty"`
Type string `yaml:"type,omitempty"`
Keep []string `yaml:"keep,omitempty"`
Depends []string `yaml:"depends,omitempty"`
@@ -420,6 +421,7 @@ func ReadPackageInfo(contents string) (*PackageInfo, error) {
Url: "",
License: "",
Arch: "",
OutputArch: GetArch(),
Type: "",
Keep: make([]string, 0),
Depends: make([]string, 0),