func doRm(c *cli.Context) error { rootDir := c.String("root") if rootDir == "" { cli.ShowCommandHelp(c, "run") return errors.New("--root option required") } if !osutil.ExistsDir(rootDir) { return fmt.Errorf("No such directory %s", rootDir) } if err := osutil.UmountRoot(rootDir); err != nil { return err } return osutil.RunCmd("rm", "-fr", rootDir) }
func Rsync(from, to string, arg ...string) error { from = from + "/" // append "/" when not terminated by "/" if strings.LastIndex(to, "/") != len(to)-1 { to = to + "/" } // TODO --exclude, --excluded-from rsyncArgs := []string{} rsyncArgs = append(rsyncArgs, RsyncDefaultOpts...) rsyncArgs = append(rsyncArgs, from, to) if err := osutil.RunCmd("rsync", rsyncArgs...); err != nil { return err } return nil }