DISTRIBUTION=:
use_pkgmgmt=
SOURCE=
-declare -a OPTS=()
while true; do
case "$1" in
-d) DISTRIBUTION=$2; shift;;
--debug) set -x;;
--pkgmgmt) use_pkgmgmt=1;;
-s|--source) SOURCE=$2; shift;;
- -o) OPTS=( "${OPTS[@]}" "$2" ); shift;;
--) shift; break ;;
*) echo "vserver-build.clone: internal error: unrecognized option '$1'" >&2
exit 1
shift
done
-if test -z "$SOURCE"; then
- panic $"vserver-build.clone: --source argument required"
+if test -d "$SOURCE"; then
+ :
+elif test -d "$__CONFDIR/$SOURCE"; then
+ SOURCE=`getPhysicalDir "$__CONFDIR/$SOURCE/vdir"`
+elif test -d "$__DEFAULT_VSERVERDIR/$SOURCE"; then
+ SOURCE=`getPhysicalDir "$__DEFAULT_VSERVERDIR/$SOURCE"`
+else
+ SOURCE=
fi
-test -z "${OPTS[*]}" && OPTS=( -Hazx --numeric-ids )
+test -n "$SOURCE" || panic $"vserver-build.clone: valid --source argument required"
getDistribution '' 1
test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
-$_VCLONE --source "$SOURCE"/ --dest "$VDIR"/
+$_VCLONE "$SOURCE"/ "$VDIR"/
test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
#define CMD_HELP 0x8000
#define CMD_VERSION 0x8001
-#define CMD_SOURCE 0x8002
-#define CMD_DEST 0x8003
struct WalkdownInfo
{
CMDLINE_OPTIONS[] = {
{ "help", no_argument, 0, CMD_HELP },
{ "version", no_argument, 0, CMD_VERSION },
- { "source", required_argument, 0, CMD_SOURCE },
- { "dest", required_argument, 0, CMD_DEST },
{ 0,0,0,0 }
};
WRITE_MSG(fd, "Usage:\n ");
WRITE_STR(fd, cmd);
WRITE_MSG(fd,
- " --source <source> --dest <destination>\n\n"
+ " <source> <absolute path to destination>\n\n"
"Please report bugs to " PACKAGE_BUGREPORT "\n");
exit(res);
}
.verbosity = 0,
};
uint64_t res;
+ int num_args;
global_args = &args;
while (1) {
switch (c) {
case CMD_HELP : showHelp(1, argv[0], 0);
case CMD_VERSION : showVersion();
- case CMD_SOURCE : ENSC_PI_SETSTR(global_info.src, optarg); break;
- case CMD_DEST : ENSC_PI_SETSTR(global_info.dst, optarg); break;
default :
WRITE_MSG(2, "Try '");
WRITE_STR(2, argv[0]);
}
}
+ num_args = argc - optind;
+ if (num_args < 1) {
+ WRITE_MSG(2, "Source is missing; try '");
+ WRITE_STR(2, argv[0]);
+ WRITE_MSG(2, " --help' for more information.\n");
+ return EXIT_FAILURE;
+ }
+ else if (num_args < 2) {
+ WRITE_MSG(2, "Destination is missing; try '");
+ WRITE_STR(2, argv[0]);
+ WRITE_MSG(2, " --help' for more information.\n");
+ return EXIT_FAILURE;
+ }
+ else if (num_args > 2) {
+ WRITE_MSG(2, "Too many arguments; try '");
+ WRITE_STR(2, argv[0]);
+ WRITE_MSG(2, " --help' for more information.\n");
+ return EXIT_FAILURE;
+ }
+ else if (*argv[optind+1] != '/') {
+ WRITE_MSG(2, "The destination must be an absolute path; try '");
+ WRITE_STR(2, argv[0]);
+ WRITE_MSG(2, " --help' for more information.\n");
+ return EXIT_FAILURE;
+ }
+ ENSC_PI_SETSTR(global_info.src, argv[optind]);
+ ENSC_PI_SETSTR(global_info.dst, argv[optind+1]);
+
if (global_args->verbosity>3)
WRITE_MSG(1, "Starting to traverse directories...\n");