Skip to content

Commit

Permalink
cleanup after each install
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkobrombin committed May 5, 2023
1 parent 07c0eaf commit a72305a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
9 changes: 4 additions & 5 deletions core/apt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package core
import (
"bufio"
"errors"
"fmt"
"os"
"path/filepath"
)
Expand All @@ -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)
Expand All @@ -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
}

Expand Down
8 changes: 3 additions & 5 deletions core/dpkg-buildpackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
9 changes: 4 additions & 5 deletions core/dpkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

var (
Version = "0.2.1"
Version = "0.2.2"
)

func main() {
Expand Down

0 comments on commit a72305a

Please sign in to comment.