Added --installation-reason flag

This commit is contained in:
2024-11-05 15:34:55 +02:00
parent b625fe97ef
commit 2accc30390
3 changed files with 37 additions and 18 deletions
+10 -4
View File
@@ -10,9 +10,10 @@ import (
)
type BPMOperation struct {
Actions []OperationAction
UnresolvedDepends []string
RootDir string
Actions []OperationAction
UnresolvedDepends []string
RootDir string
ForceInstallationReason InstallationReason
}
func (operation *BPMOperation) ActionsContainPackage(pkg string) bool {
@@ -396,7 +397,12 @@ func (operation *BPMOperation) Execute(verbose, force bool) error {
return errors.New(fmt.Sprintf("could not install package (%s): %s\n", bpmpkg.PkgInfo.Name, err))
}
fmt.Printf("Package (%s) was successfully installed\n", bpmpkg.PkgInfo.Name)
if value.IsDependency {
if operation.ForceInstallationReason != Unknown {
err := SetInstallationReason(bpmpkg.PkgInfo.Name, operation.ForceInstallationReason, operation.RootDir)
if err != nil {
return errors.New(fmt.Sprintf("could not set installation reason for package (%s): %s\n", value.BpmPackage.PkgInfo.Name, err))
}
} else if value.IsDependency && !IsPackageInstalled(bpmpkg.PkgInfo.Name, operation.RootDir) {
err := SetInstallationReason(bpmpkg.PkgInfo.Name, Dependency, operation.RootDir)
if err != nil {
return errors.New(fmt.Sprintf("could not set installation reason for package (%s): %s\n", value.BpmPackage.PkgInfo.Name, err))
+2 -5
View File
@@ -1185,11 +1185,8 @@ func InstallPackage(filename, rootDir string, verbose, force, binaryPkgFromSrc,
return err
}
pkgDir := path.Join(installedDir, bpmpkg.PkgInfo.Name)
err = os.RemoveAll(pkgDir)
if err != nil {
return err
}
err = os.Mkdir(pkgDir, 0755)
err = os.MkdirAll(pkgDir, 0755)
if err != nil {
return err
}