* Added --cachedir commandline option

* Removed usage of 'realpath'.  From the manpage:
  "Avoid  using this function. It is broken by design"
This commit is contained in:
Aaron Griffin 2007-02-12 07:03:08 +00:00
parent be85600dfd
commit 62cd381894

View file

@ -155,6 +155,7 @@ static void usage(int op, char *myname)
printf(_(" -v, --verbose be verbose\n"));
printf(_(" -r, --root <path> set an alternate installation root\n"));
printf(_(" -b, --dbpath <path> set an alternate database location\n"));
printf(_(" --cachedir <dir> set an alternate database location\n"));
}
}
@ -257,9 +258,9 @@ static int parseargs(int argc, char *argv[])
{"noprogressbar", no_argument, 0, 1004},
{"noscriptlet", no_argument, 0, 1005},
{"ask", required_argument, 0, 1006},
{"cachedir", required_argument, 0, 1007},
{0, 0, 0, 0}
};
char root[PATH_MAX];
struct stat st;
unsigned short logmask;
@ -309,6 +310,13 @@ static int parseargs(int argc, char *argv[])
case 1004: config->noprogressbar = 1; break;
case 1005: config->flags |= PM_TRANS_FLAG_NOSCRIPTLET; break;
case 1006: config->noask = 1; config->ask = atoi(optarg); break;
case 1007:
if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
ERR(NL, _("'%s' is not a valid cache directory\n"), optarg);
return(1);
}
alpm_option_set_cachedir(optarg);
break;
case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break;
case 'D':
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST);
@ -359,11 +367,11 @@ static int parseargs(int argc, char *argv[])
config->flags |= PM_TRANS_FLAG_PRINTURIS;
break;
case 'r':
if(realpath(optarg, root) == NULL) {
if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
ERR(NL, _("'%s' is not a valid root path\n"), optarg);
return(1);
}
alpm_option_set_root(strdup(root));
alpm_option_set_root(optarg);
break;
case 's':
config->op_s_search = 1;