Skip to content
Permalink
Browse files

Correct Debian package discovery (#535)

  • Loading branch information
pedroMMM authored and aelsabbahy committed Jan 7, 2020
1 parent 16c3099 commit 8afe63173041dfafa1c7abc981dfdf31860a7924
Showing with 7 additions and 7 deletions.
  1. +6 −6 system/system.go
  2. +1 −1 system/system_test.go
@@ -79,11 +79,11 @@ func New(c *cli.Context) *System {
// detectPackage adds the correct package creation function to a System struct
func (sys *System) detectPackage(c *cli.Context) {
p := c.GlobalString("package")
if p != "deb" && p != "apk" && p != "pacman" && p != "rpm" {
if p != "dpkg" && p != "apk" && p != "pacman" && p != "rpm" {
p = DetectPackageManager()
}
switch p {
case "deb":
case "dpkg":
sys.NewPackage = NewDebPackage
case "apk":
sys.NewPackage = NewAlpinePackage
@@ -111,23 +111,23 @@ func (sys *System) detectService() {
}

// DetectPackageManager attempts to detect whether or not the system is using
// "deb", "rpm", "apk", or "pacman" package managers. It first attempts to
// "dpkg", "rpm", "apk", or "pacman" package managers. It first attempts to
// detect the distro. If that fails, it falls back to finding package manager
// executables. If that fails, it returns the empty string.
func DetectPackageManager() string {
switch DetectDistro() {
case "ubuntu":
return "deb"
return "dpkg"
case "redhat":
return "rpm"
case "alpine":
return "apk"
case "arch":
return "pacman"
case "debian":
return "deb"
return "dpkg"
}
for _, manager := range []string{"deb", "rpm", "apk", "pacman"} {
for _, manager := range []string{"dpkg", "rpm", "apk", "pacman"} {
if HasCommand(manager) {
return manager
}
@@ -28,7 +28,7 @@ func TestPackageManager(t *testing.T) {
t.Parallel()
testOutputs(
DetectPackageManager,
[]string{"deb", "rpm", "apk", "pacman", ""},
[]string{"dpkg", "rpm", "apk", "pacman", ""},
t,
)
}

0 comments on commit 8afe631

Please sign in to comment.
You can’t perform that action at this time.