|
@ -4,12 +4,30 @@ import ( |
|
|
"errors" |
|
|
"errors" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"os" |
|
|
"os" |
|
|
|
|
|
"os/exec" |
|
|
|
|
|
|
|
|
"PackageManager/Archive" |
|
|
"PackageManager/Archive" |
|
|
"PackageManager/Client/Database" |
|
|
"PackageManager/Client/Database" |
|
|
"PackageManager/Variables" |
|
|
"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) { |
|
|
func CheckPackageDependancies(deps map[string]string) ([]int64, error) { |
|
|
var ( |
|
|
var ( |
|
|
name, version string |
|
|
name, version string |
|
@ -64,16 +82,25 @@ func InstallPackage(pkgs []string) error { |
|
|
if !Variables.IgnoreDepsCheck { |
|
|
if !Variables.IgnoreDepsCheck { |
|
|
depIds, e = CheckPackageDependancies(manifest.Dependancies) |
|
|
depIds, e = CheckPackageDependancies(manifest.Dependancies) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
// TODO: Search for package on error
|
|
|
|
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
e = runInstallCmd(manifest.PreInstallCmds) |
|
|
|
|
|
if e != nil { |
|
|
|
|
|
return e |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
e = Archive.ExtractArchive(pkg, Variables.RootDir) |
|
|
e = Archive.ExtractArchive(pkg, Variables.RootDir) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
e = runInstallCmd(manifest.PostInstallCmds) |
|
|
|
|
|
if e != nil { |
|
|
|
|
|
return e |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
e = Database.InsertPackage(manifest.Name, manifest.Version, depIds) |
|
|
e = Database.InsertPackage(manifest.Name, manifest.Version, depIds) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
return e |
|
|
return e |
|
|