Show error when compiling source packages in a different root directory

This commit is contained in:
2025-07-06 22:01:57 +03:00
parent 8a627254c9
commit 4bfc325c66
+23
View File
@@ -7,6 +7,7 @@ import (
"os" "os"
"path" "path"
"slices" "slices"
"strings"
) )
type ReinstallMethod uint8 type ReinstallMethod uint8
@@ -128,6 +129,28 @@ func InstallPackages(rootDir string, installationReason InstallationReason, rein
} }
} }
// Check whether compiling source packages on different root directory
if rootDir != "/" {
sourcePackages := make([]string, 0)
for _, action := range operation.Actions {
switch action.(type) {
case *InstallPackageAction:
if action.(*InstallPackageAction).BpmPackage.PkgInfo.Type == "source" {
sourcePackages = append(sourcePackages, action.(*InstallPackageAction).BpmPackage.PkgInfo.Name)
}
case *FetchPackageAction:
if action.(*FetchPackageAction).DatabaseEntry.Info.Type == "source" {
sourcePackages = append(sourcePackages, action.(*FetchPackageAction).DatabaseEntry.Info.Name)
}
}
}
// Return error if source packages are present in the operation
if len(sourcePackages) != 0 {
return nil, fmt.Errorf("cannot compile source packages in different root directory: %s", strings.Join(sourcePackages, ", "))
}
}
return operation, nil return operation, nil
} }