Fixed bug where dependencies would be installed with 'manual' as installation reason

This commit is contained in:
EnumDev 2024-11-05 22:11:37 +02:00
parent 2accc30390
commit e285fd792e

View File

@ -387,6 +387,7 @@ func (operation *BPMOperation) Execute(verbose, force bool) error {
} else if action.GetActionType() == "install" { } else if action.GetActionType() == "install" {
value := action.(*InstallPackageAction) value := action.(*InstallPackageAction)
bpmpkg := value.BpmPackage bpmpkg := value.BpmPackage
isReinstall := IsPackageInstalled(bpmpkg.PkgInfo.Name, operation.RootDir)
var err error var err error
if value.IsDependency { if value.IsDependency {
err = InstallPackage(value.File, operation.RootDir, verbose, true, false, false, false) err = InstallPackage(value.File, operation.RootDir, verbose, true, false, false, false)
@ -396,18 +397,18 @@ func (operation *BPMOperation) Execute(verbose, force bool) error {
if err != nil { if err != nil {
return errors.New(fmt.Sprintf("could not install package (%s): %s\n", bpmpkg.PkgInfo.Name, err)) 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 operation.ForceInstallationReason != Unknown && !value.IsDependency {
if operation.ForceInstallationReason != Unknown {
err := SetInstallationReason(bpmpkg.PkgInfo.Name, operation.ForceInstallationReason, operation.RootDir) err := SetInstallationReason(bpmpkg.PkgInfo.Name, operation.ForceInstallationReason, operation.RootDir)
if err != nil { if err != nil {
return errors.New(fmt.Sprintf("could not set installation reason for package (%s): %s\n", value.BpmPackage.PkgInfo.Name, err)) 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) { } else if value.IsDependency && !isReinstall {
err := SetInstallationReason(bpmpkg.PkgInfo.Name, Dependency, operation.RootDir) err := SetInstallationReason(bpmpkg.PkgInfo.Name, Dependency, operation.RootDir)
if err != nil { if err != nil {
return errors.New(fmt.Sprintf("could not set installation reason for package (%s): %s\n", value.BpmPackage.PkgInfo.Name, err)) return errors.New(fmt.Sprintf("could not set installation reason for package (%s): %s\n", value.BpmPackage.PkgInfo.Name, err))
} }
} }
fmt.Printf("Package (%s) was successfully installed\n", bpmpkg.PkgInfo.Name)
} }
} }
fmt.Println("Operation complete!") fmt.Println("Operation complete!")