diff --git a/core/apt.go b/core/apt.go index 4fef7dd..eda81d2 100644 --- a/core/apt.go +++ b/core/apt.go @@ -3,6 +3,7 @@ package core import ( "bufio" "errors" + "fmt" "os" "path/filepath" ) @@ -22,7 +23,7 @@ func BuildAptModule(recipe *Recipe, module Module) (string, error) { if len(module.Source.Paths) > 0 { cmd := "" - for i, path := range module.Source.Paths { + for _, path := range module.Source.Paths { instPath := filepath.Join(recipe.ParentPath, path+".inst") pkgs := "" file, err := os.Open(instPath) @@ -40,13 +41,11 @@ func BuildAptModule(recipe *Recipe, module Module) (string, error) { return "", err } - cmd += "apt install -y " + pkgs - if i < len(module.Source.Paths)-1 { - cmd += " && " - } + cmd += fmt.Sprintf("apt install -y %s && ", pkgs) } + cmd += "apt clean" return cmd, nil } diff --git a/core/dpkg-buildpackage.go b/core/dpkg-buildpackage.go index 6104a20..bd8ce40 100644 --- a/core/dpkg-buildpackage.go +++ b/core/dpkg-buildpackage.go @@ -10,12 +10,10 @@ func BuildDpkgBuildPkgModule(module Module) (string, error) { module.Name, ) - for i, path := range module.Source.Paths { - cmd += fmt.Sprintf(" dpkg -i ../%s*.deb && apt install -f", path) - if i < len(module.Source.Paths)-1 { - cmd += " && " - } + for _, path := range module.Source.Paths { + cmd += fmt.Sprintf(" dpkg -i ../%s*.deb && apt install -f && ", path) } + cmd += " && apt clean" return cmd, nil } diff --git a/core/dpkg.go b/core/dpkg.go index d172eaa..97a5f13 100644 --- a/core/dpkg.go +++ b/core/dpkg.go @@ -5,11 +5,10 @@ import "fmt" // BuildDpkgModule builds a module that installs a .deb package func BuildDpkgModule(module Module) (string, error) { cmd := "" - for i, path := range module.Source.Paths { - cmd += fmt.Sprintf(" dpkg -i /sources/%s && apt install -f", path) - if i < len(module.Source.Paths)-1 { - cmd += " && " - } + for _, path := range module.Source.Paths { + cmd += fmt.Sprintf(" dpkg -i /sources/%s && apt install -f && ", path) } + + cmd += " && apt clean" return cmd, nil } diff --git a/main.go b/main.go index 07763c6..00b8238 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( ) var ( - Version = "0.2.1" + Version = "0.2.2" ) func main() {