func main() { goopt.Parse(func() []string { return []string{} }) syscall.Umask(0077) // Turn off read/write/execute priviledges for others if len(goopt.Args) < 1 { fmt.Println("You need to provide a go file argument.") os.Exit(1) } execname := goopt.Args[0] + ".secret" e := compile.Compile(execname, goopt.Args) if e != nil { fmt.Fprintln(os.Stderr, e) os.Exit(1) } if *outname == "FILENAME.go" { fmt.Fprintln(os.Stderr, "secretrun requires a -o argument!") os.Exit(1) } e = deps.Exec("./"+execname, *outname) os.Remove(execname) if e != nil { fmt.Fprintln(os.Stderr, e) os.Exit(1) } }
func Remove(pkg string) os.Error { return runapt(func() os.Error { once.Do(findInstalled) if _, i := installed[pkg]; i { return deps.Exec("apt-get", "remove", "-y", "-q", pkg) } fmt.Println(pkg, "is already removed.") return nil }) }
func Compile(outname string, files []string) (e os.Error) { oldmask := syscall.Umask(0) syscall.Umask(0077) // Turn off read/write/execute priviledges for others if len(files) < 1 { return os.NewError("go.Compile requires at least one file argument.") } objname := "_go_." + archnum() os.Remove(objname) // so umask will have its desired effect args := make([]string, len(files)+2) args[0] = "-o" args[1] = objname for i, f := range files { args[i+2] = f } e = deps.Execs(archnum()+"g", args) if e != nil { return } os.Remove(outname) // so umask will have its desired effect retval := deps.Exec(archnum()+"l", "-o", outname, objname) syscall.Umask(oldmask) return retval }
func DistUpgrade() os.Error { return runapt(func() os.Error { return deps.Exec("apt-get", "dist-upgrade", "-y", "-q") }) }
func AutoRemove() os.Error { return runapt(func() os.Error { return deps.Exec("apt-get", "autoremove", "-qq") }) }
func AutoClean() os.Error { return runapt(func() os.Error { return deps.Exec("apt-get", "autoclean", "-qq") }) }
func Update() os.Error { return runapt(func() os.Error { return deps.Exec("apt-get", "update", "-qq") }) }