Changeset 2494

Show
Ignore:
Timestamp:
02/11/07 01:45:04 (2 years ago)
Author:
dhozac
Message:

Remove the --source and --dest "options" from vclone, both are required.
Catch error conditions about the arguments in vclone.
Attempt to figure out where the source if it's not a directory, and make sure it is one before running vclone.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/scripts/vserver-build.clone

    r2468 r2494  
    2424use_pkgmgmt= 
    2525SOURCE= 
    26 declare -a OPTS=() 
    2726while true; do 
    2827    case "$1" in 
     
    3130        --pkgmgmt)      use_pkgmgmt=1;; 
    3231        -s|--source)    SOURCE=$2; shift;; 
    33         -o)             OPTS=( "${OPTS[@]}" "$2" ); shift;; 
    3432        --)             shift; break ;; 
    3533        *)              echo "vserver-build.clone: internal error: unrecognized option '$1'" >&2 
     
    4038done 
    4139 
    42 if test -z "$SOURCE"; then 
    43     panic $"vserver-build.clone: --source argument required" 
     40if test -d "$SOURCE"; then 
     41    : 
     42elif test -d "$__CONFDIR/$SOURCE"; then 
     43    SOURCE=`getPhysicalDir "$__CONFDIR/$SOURCE/vdir"` 
     44elif test -d "$__DEFAULT_VSERVERDIR/$SOURCE"; then 
     45    SOURCE=`getPhysicalDir "$__DEFAULT_VSERVERDIR/$SOURCE"` 
     46else 
     47    SOURCE= 
    4448fi 
    4549 
    46 test -z "${OPTS[*]}" && OPTS=( -Hazx --numeric-ids ) 
     50test -n "$SOURCE" || panic $"vserver-build.clone: valid --source argument required" 
    4751 
    4852getDistribution '' 1 
     
    6064test -z "$BUILD_INITPRE"  || "$BUILD_INITPRE" "$SETUP_CONFDIR"  "$UTIL_VSERVER_VARS" 
    6165 
    62 $_VCLONE --source "$SOURCE"/ --dest "$VDIR"/ 
     66$_VCLONE "$SOURCE"/ "$VDIR"/ 
    6367 
    6468test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS" 
  • trunk/src/vclone.c

    r2472 r2494  
    4545#define CMD_HELP                0x8000 
    4646#define CMD_VERSION             0x8001 
    47 #define CMD_SOURCE              0x8002 
    48 #define CMD_DEST                0x8003 
    4947 
    5048struct WalkdownInfo 
     
    6866  { "help",     no_argument,       0, CMD_HELP }, 
    6967  { "version",  no_argument,       0, CMD_VERSION }, 
    70   { "source",   required_argument, 0, CMD_SOURCE }, 
    71   { "dest",     required_argument, 0, CMD_DEST }, 
    7268  { 0,0,0,0 } 
    7369}; 
     
    8278  WRITE_STR(fd, cmd); 
    8379  WRITE_MSG(fd, 
    84             " --source <source> --dest <destination>\n\n" 
     80            " <source> <absolute path to destination>\n\n" 
    8581            "Please report bugs to " PACKAGE_BUGREPORT "\n"); 
    8682  exit(res); 
     
    161157  }; 
    162158  uint64_t              res; 
     159  int                   num_args; 
    163160 
    164161  global_args = &args; 
     
    171168      case CMD_HELP     :  showHelp(1, argv[0], 0); 
    172169      case CMD_VERSION  :  showVersion(); 
    173       case CMD_SOURCE   :  ENSC_PI_SETSTR(global_info.src, optarg); break; 
    174       case CMD_DEST     :  ENSC_PI_SETSTR(global_info.dst, optarg); break; 
    175170      default           : 
    176171        WRITE_MSG(2, "Try '"); 
     
    182177  } 
    183178 
     179  num_args = argc - optind; 
     180  if (num_args < 1) { 
     181    WRITE_MSG(2, "Source is missing; try '"); 
     182    WRITE_STR(2, argv[0]); 
     183    WRITE_MSG(2, " --help' for more information.\n"); 
     184    return EXIT_FAILURE; 
     185  } 
     186  else if (num_args < 2) { 
     187    WRITE_MSG(2, "Destination is missing; try '"); 
     188    WRITE_STR(2, argv[0]); 
     189    WRITE_MSG(2, " --help' for more information.\n"); 
     190    return EXIT_FAILURE; 
     191  } 
     192  else if (num_args > 2) { 
     193    WRITE_MSG(2, "Too many arguments; try '"); 
     194    WRITE_STR(2, argv[0]); 
     195    WRITE_MSG(2, " --help' for more information.\n"); 
     196    return EXIT_FAILURE; 
     197  } 
     198  else if (*argv[optind+1] != '/') { 
     199    WRITE_MSG(2, "The destination must be an absolute path; try '"); 
     200    WRITE_STR(2, argv[0]); 
     201    WRITE_MSG(2, " --help' for more information.\n"); 
     202    return EXIT_FAILURE; 
     203  } 
     204  ENSC_PI_SETSTR(global_info.src, argv[optind]); 
     205  ENSC_PI_SETSTR(global_info.dst, argv[optind+1]); 
     206 
    184207  if (global_args->verbosity>3) 
    185208    WRITE_MSG(1, "Starting to traverse directories...\n");