mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-16 02:26:12 +00:00
Show optional dependencies after install or update operation
This commit is contained in:
@@ -577,6 +577,9 @@ func installPackages() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get optional dependencies
|
||||||
|
optionalDepends := operation.GetOptionalDependencies()
|
||||||
|
|
||||||
// Execute operation
|
// Execute operation
|
||||||
err = operation.Execute(verbose, force)
|
err = operation.Execute(verbose, force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -593,6 +596,18 @@ func installPackages() {
|
|||||||
exitCode = 1
|
exitCode = 1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show optional dependencies
|
||||||
|
if !installOptional && len(optionalDepends) != 0 {
|
||||||
|
// List optional dependencies
|
||||||
|
fmt.Println("The following opitonal dependenices have been discovered:")
|
||||||
|
for dependant, depends := range optionalDepends {
|
||||||
|
fmt.Printf("%s: \n", dependant)
|
||||||
|
for _, depend := range depends {
|
||||||
|
fmt.Printf(" - %s\n", depend)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func removePackages() {
|
func removePackages() {
|
||||||
@@ -942,6 +957,9 @@ func updatePackages() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get optional dependencies
|
||||||
|
optionalDepends := operation.GetOptionalDependencies()
|
||||||
|
|
||||||
// Execute operation
|
// Execute operation
|
||||||
err = operation.Execute(verbose, force)
|
err = operation.Execute(verbose, force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -958,6 +976,18 @@ func updatePackages() {
|
|||||||
exitCode = 1
|
exitCode = 1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show optional dependencies
|
||||||
|
if !installOptional && len(optionalDepends) != 0 {
|
||||||
|
// List optional dependencies
|
||||||
|
fmt.Println("The following opitonal dependenices have been discovered:")
|
||||||
|
for dependant, depends := range optionalDepends {
|
||||||
|
fmt.Printf("%s: \n", dependant)
|
||||||
|
for _, depend := range depends {
|
||||||
|
fmt.Printf(" - %s\n", depend)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFileOwner() {
|
func getFileOwner() {
|
||||||
|
|||||||
@@ -466,6 +466,40 @@ func (operation *BPMOperation) ShowSourcePackageContent() (sourcePackagesShown i
|
|||||||
return sourcePackagesShown, nil
|
return sourcePackagesShown, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (operation *BPMOperation) GetOptionalDependencies() (optionalDepends map[string][]string) {
|
||||||
|
optionalDepends = make(map[string][]string)
|
||||||
|
|
||||||
|
// Find all optional dependencies
|
||||||
|
for _, value := range slices.Clone(operation.Actions) {
|
||||||
|
var pkgInfo *PackageInfo
|
||||||
|
if value.GetActionType() == "install" {
|
||||||
|
action := value.(*InstallPackageAction)
|
||||||
|
pkgInfo = action.BpmPackage.PkgInfo
|
||||||
|
} else if value.GetActionType() == "fetch" {
|
||||||
|
action := value.(*FetchPackageAction)
|
||||||
|
pkgInfo = action.DatabaseEntry.Info
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, depend := range pkgInfo.OptionalDepends {
|
||||||
|
// Skip if dependency is already installed
|
||||||
|
if IsPackageInstalled(depend, operation.RootDir) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip if not a new dependency of the package
|
||||||
|
if installedPkg := GetPackage(pkgInfo.Name, operation.RootDir); installedPkg != nil && slices.Contains(installedPkg.PkgInfo.OptionalDepends, depend) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
optionalDepends[pkgInfo.Name] = append(optionalDepends[pkgInfo.Name], depend)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (operation *BPMOperation) RunHooks(verbose bool) error {
|
func (operation *BPMOperation) RunHooks(verbose bool) error {
|
||||||
// Return if hooks directory does not exist
|
// Return if hooks directory does not exist
|
||||||
if stat, err := os.Stat(path.Join(operation.RootDir, "var/lib/bpm/hooks")); err != nil || !stat.IsDir() {
|
if stat, err := os.Stat(path.Join(operation.RootDir, "var/lib/bpm/hooks")); err != nil || !stat.IsDir() {
|
||||||
|
|||||||
Reference in New Issue
Block a user