Skip to content

Commit

Permalink
osprepare: Ensure its ok to fail early
Browse files Browse the repository at this point in the history
It is quite likely that we either encounter a distro or configuration that is
new to us, due to the nature of the new osprepare module, so we shouldn't
fail here. Rather, we should fail later on so that osprepare can be improved
retroactively to fix whatever setup issue we encountered.

With this change it is also OK to pass nil dependencies, to enable easier
plugging in of the functionality, and future expansion of the core entry
method, PrepareOsDeps.

Signed-off-by: Ikey Doherty <[email protected]>
  • Loading branch information
Ikey Doherty committed Aug 23, 2016
1 parent aab99e4 commit 891228f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions osprepare/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func collectPackages(dist distro, reqs *PackageRequirements) []string {
return nil
}

// PrepareCIAO installs all the dependencies defined in
// PrepareOsDeps installs all the dependencies defined in
// PackageRequirements in order to run the ciao component
func PrepareCIAO(reqs *PackageRequirements) bool {
func PrepareOsDeps(reqs *PackageRequirements) {
distro := getDistro()

if distro == nil {
Expand All @@ -86,14 +86,15 @@ func PrepareCIAO(reqs *PackageRequirements) bool {
} else {
fmt.Fprintln(os.Stderr, "No os-release found on this host")
}
return false
return
}
// Nothing requested to install
if reqs == nil {
return
}
fmt.Println(distro.getID())
if reqPkgs := collectPackages(distro, reqs); reqPkgs != nil {
if distro.InstallPackages(reqPkgs) == false {
fmt.Fprintf(os.Stderr, "Failed to install: %s\n", strings.Join(reqPkgs, ", "))
return false
}
}
return true
}

0 comments on commit 891228f

Please sign in to comment.