Exemplo n.º 1
0
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)
	}
}
Exemplo n.º 2
0
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
	})
}
Exemplo n.º 3
0
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
}
Exemplo n.º 4
0
func DistUpgrade() os.Error {
	return runapt(func() os.Error {
		return deps.Exec("apt-get", "dist-upgrade", "-y", "-q")
	})
}
Exemplo n.º 5
0
func AutoRemove() os.Error {
	return runapt(func() os.Error {
		return deps.Exec("apt-get", "autoremove", "-qq")
	})
}
Exemplo n.º 6
0
func AutoClean() os.Error {
	return runapt(func() os.Error {
		return deps.Exec("apt-get", "autoclean", "-qq")
	})
}
Exemplo n.º 7
0
func Update() os.Error {
	return runapt(func() os.Error {
		return deps.Exec("apt-get", "update", "-qq")
	})
}