From 4bfc325c66cb03699060021a423fde358f25540a Mon Sep 17 00:00:00 2001 From: EnumDev Date: Sun, 6 Jul 2025 22:01:57 +0300 Subject: [PATCH] Show error when compiling source packages in a different root directory --- src/bpmlib/general.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/bpmlib/general.go b/src/bpmlib/general.go index ff80caa..fe4d6e5 100644 --- a/src/bpmlib/general.go +++ b/src/bpmlib/general.go @@ -7,6 +7,7 @@ import ( "os" "path" "slices" + "strings" ) 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 }