|
|
@ -4,12 +4,30 @@ import ( |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"os" |
|
|
|
"os/exec" |
|
|
|
|
|
|
|
"PackageManager/Archive" |
|
|
|
"PackageManager/Client/Database" |
|
|
|
"PackageManager/Variables" |
|
|
|
) |
|
|
|
|
|
|
|
func runInstallCmd(cmdStr string) error { |
|
|
|
var ( |
|
|
|
cmd *exec.Cmd |
|
|
|
) |
|
|
|
|
|
|
|
if cmdStr == "" { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
cmd = exec.Command("/bin/sh", "-c", cmdStr) |
|
|
|
cmd.Dir = Variables.RootDir |
|
|
|
cmd.Stdin = os.Stdin |
|
|
|
cmd.Stdout = os.Stdout |
|
|
|
cmd.Stderr = os.Stderr |
|
|
|
return cmd.Run() |
|
|
|
} |
|
|
|
|
|
|
|
func CheckPackageDependancies(deps map[string]string) ([]int64, error) { |
|
|
|
var ( |
|
|
|
name, version string |
|
|
@ -64,16 +82,25 @@ func InstallPackage(pkgs []string) error { |
|
|
|
if !Variables.IgnoreDepsCheck { |
|
|
|
depIds, e = CheckPackageDependancies(manifest.Dependancies) |
|
|
|
if e != nil { |
|
|
|
// TODO: Search for package on error
|
|
|
|
return e |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
e = runInstallCmd(manifest.PreInstallCmds) |
|
|
|
if e != nil { |
|
|
|
return e |
|
|
|
} |
|
|
|
|
|
|
|
e = Archive.ExtractArchive(pkg, Variables.RootDir) |
|
|
|
if e != nil { |
|
|
|
return e |
|
|
|
} |
|
|
|
|
|
|
|
e = runInstallCmd(manifest.PostInstallCmds) |
|
|
|
if e != nil { |
|
|
|
return e |
|
|
|
} |
|
|
|
|
|
|
|
e = Database.InsertPackage(manifest.Name, manifest.Version, depIds) |
|
|
|
if e != nil { |
|
|
|
return e |
|
|
|