mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
Dan McGee <dpmcgee@gmail.com>
* fix for -Qii regression * package.c cleanup * some refactoring changes Moved split_pkgname as per Dan's suggestion
This commit is contained in:
parent
31e0561865
commit
c6f56aee57
@ -37,48 +37,48 @@
|
|||||||
*/
|
*/
|
||||||
void dump_pkg_full(pmpkg_t *pkg, int level)
|
void dump_pkg_full(pmpkg_t *pkg, int level)
|
||||||
{
|
{
|
||||||
const char *date, *type;
|
const char *bdate, *type, *idate, *reason;
|
||||||
|
|
||||||
if(pkg == NULL) {
|
if(pkg == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
|
/* set variables here, do all output below */
|
||||||
printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
|
bdate = alpm_pkg_get_builddate(pkg);
|
||||||
|
|
||||||
pmlist_display(_("Groups :"), alpm_pkg_get_groups(pkg));
|
|
||||||
|
|
||||||
printf(_("Packager : %s\n"), (char *)alpm_pkg_get_packager(pkg));
|
|
||||||
printf("URL : %s\n", (char *)alpm_pkg_get_url(pkg));
|
|
||||||
pmlist_display(_("License :"), alpm_pkg_get_licenses(pkg));
|
|
||||||
printf(_("Architecture : %s\n"), (char *)alpm_pkg_get_arch(pkg));
|
|
||||||
printf(_("Size : %ld\n"), (long int)alpm_pkg_get_size(pkg));
|
|
||||||
|
|
||||||
date = alpm_pkg_get_builddate(pkg);
|
|
||||||
printf(_("Build Date : %s %s\n"), date, strlen(date) ? "UTC" : "");
|
|
||||||
type = alpm_pkg_get_buildtype(pkg);
|
type = alpm_pkg_get_buildtype(pkg);
|
||||||
printf(_("Build Type : %s\n"), strlen(type) ? type : _("Unknown"));
|
idate = alpm_pkg_get_installdate(pkg);
|
||||||
date = alpm_pkg_get_installdate(pkg);
|
|
||||||
printf(_("Install Date : %s %s\n"), date, strlen(date) ? "UTC" : "");
|
|
||||||
|
|
||||||
printf(_("Install Script : %s\n"), alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"));
|
|
||||||
|
|
||||||
printf(_("Reason : "));
|
|
||||||
switch((long)alpm_pkg_get_reason(pkg)) {
|
switch((long)alpm_pkg_get_reason(pkg)) {
|
||||||
case PM_PKG_REASON_EXPLICIT:
|
case PM_PKG_REASON_EXPLICIT:
|
||||||
printf(_("Explicitly installed\n"));
|
reason = _("Explicitly installed\n");
|
||||||
break;
|
break;
|
||||||
case PM_PKG_REASON_DEPEND:
|
case PM_PKG_REASON_DEPEND:
|
||||||
printf(_("Installed as a dependency for another package\n"));
|
reason = _("Installed as a dependency for another package\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf(_("Unknown\n"));
|
reason = _("Unknown\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* actual output */
|
||||||
|
printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
|
||||||
|
printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
|
||||||
|
pmlist_display(_("Groups :"), alpm_pkg_get_groups(pkg));
|
||||||
|
printf(_("Packager : %s\n"), (char *)alpm_pkg_get_packager(pkg));
|
||||||
|
printf(_("URL : %s\n"), (char *)alpm_pkg_get_url(pkg));
|
||||||
|
pmlist_display(_("License :"), alpm_pkg_get_licenses(pkg));
|
||||||
|
printf(_("Architecture : %s\n"), (char *)alpm_pkg_get_arch(pkg));
|
||||||
|
printf(_("Installed Size : %ld\n"), (long int)alpm_pkg_get_size(pkg));
|
||||||
|
printf(_("Build Date : %s %s\n"), bdate, strlen(bdate) ? "UTC" : "");
|
||||||
|
printf(_("Build Type : %s\n"), strlen(type) ? type : _("Unknown"));
|
||||||
|
/* TODO only applicable if querying installed package, not a file */
|
||||||
|
printf(_("Install Date : %s %s\n"), idate, strlen(idate) ? "UTC" : "");
|
||||||
|
printf(_("Install Script : %s\n"), alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"));
|
||||||
|
printf(_("Reason : %s\n"), reason);
|
||||||
pmlist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
|
pmlist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
|
||||||
pmlist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
|
pmlist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
|
||||||
pmlist_display(_("Removes :"), alpm_pkg_get_removes(pkg));
|
pmlist_display(_("Removes :"), alpm_pkg_get_removes(pkg));
|
||||||
|
/* TODO only applicable if querying installed package, not a file */
|
||||||
pmlist_display(_("Required By :"), alpm_pkg_get_requiredby(pkg));
|
pmlist_display(_("Required By :"), alpm_pkg_get_requiredby(pkg));
|
||||||
pmlist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
|
pmlist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
|
||||||
|
|
||||||
@ -86,41 +86,11 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
|
|||||||
indentprint(alpm_pkg_get_desc(pkg), 17);
|
indentprint(alpm_pkg_get_desc(pkg), 17);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
/* Print additional package info if info flag passed more than once */
|
||||||
|
/* TODO only applicable if querying installed package, not a file */
|
||||||
if(level > 1) {
|
if(level > 1) {
|
||||||
pmlist_t *i;
|
/* call new backup function */
|
||||||
const char *root = alpm_option_get_root();
|
dump_pkg_backups(pkg);
|
||||||
fprintf(stdout, "\n");
|
|
||||||
for(i = alpm_list_first(alpm_pkg_get_backup(pkg)); i; i = alpm_list_next(i)) {
|
|
||||||
struct stat buf;
|
|
||||||
char path[PATH_MAX];
|
|
||||||
char *str = strdup(alpm_list_getdata(i));
|
|
||||||
char *ptr = index(str, '\t');
|
|
||||||
if(ptr == NULL) {
|
|
||||||
FREE(str);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
*ptr = '\0';
|
|
||||||
ptr++;
|
|
||||||
snprintf(path, PATH_MAX-1, "%s%s", root, str);
|
|
||||||
if(!stat(path, &buf)) {
|
|
||||||
char *md5sum = alpm_get_md5sum(path);
|
|
||||||
char *sha1sum = alpm_get_sha1sum(path);
|
|
||||||
if(md5sum == NULL && sha1sum == NULL) {
|
|
||||||
ERR(NL, _("error calculating md5sum or sha1sum for %s\n"), path);
|
|
||||||
FREE(str);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!sha1sum)
|
|
||||||
printf(_("%sMODIFIED\t%s\n"), strcmp(md5sum, ptr) ? "" : _("NOT "), path);
|
|
||||||
if (!md5sum)
|
|
||||||
printf(_("%sMODIFIED\t%s\n"), strcmp(sha1sum, ptr) ? "" : _("NOT "), path);
|
|
||||||
FREE(md5sum);
|
|
||||||
FREE(sha1sum);
|
|
||||||
} else {
|
|
||||||
printf(_("MISSING\t\t%s\n"), path);
|
|
||||||
}
|
|
||||||
FREE(str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@ -130,38 +100,93 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
|
|||||||
*/
|
*/
|
||||||
void dump_pkg_sync(pmpkg_t *pkg, char *treename)
|
void dump_pkg_sync(pmpkg_t *pkg, char *treename)
|
||||||
{
|
{
|
||||||
char *sum;
|
char *md5sum, *sha1sum;
|
||||||
if(pkg == NULL) {
|
if(pkg == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(_("Repository : %s\n"), treename);
|
md5sum = (char *)alpm_pkg_get_md5sum(pkg);
|
||||||
printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
|
sha1sum = (char *)alpm_pkg_get_sha1sum(pkg);
|
||||||
printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
|
|
||||||
|
|
||||||
pmlist_display(_("Groups :"), alpm_pkg_get_groups(pkg));
|
printf(_("Repository : %s\n"), treename);
|
||||||
pmlist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
|
printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
|
||||||
pmlist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
|
printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
|
||||||
pmlist_display(_("Removes :"), alpm_pkg_get_removes(pkg));
|
pmlist_display(_("Groups :"), alpm_pkg_get_groups(pkg));
|
||||||
pmlist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
|
pmlist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
|
||||||
pmlist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
|
pmlist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
|
||||||
|
pmlist_display(_("Removes :"), alpm_pkg_get_removes(pkg));
|
||||||
|
pmlist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
|
||||||
|
pmlist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
|
||||||
|
printf(_("Download Size : %ld\n"), (long)alpm_pkg_get_size(pkg));
|
||||||
|
printf(_("Installed Size : %ld\n"), (long)alpm_pkg_get_isize(pkg));
|
||||||
|
|
||||||
printf(_("Size (compressed) : %ld\n"), (long)alpm_pkg_get_size(pkg));
|
printf(_("Description : "));
|
||||||
printf(_("Size (installed) : %ld\n"), (long)alpm_pkg_get_isize(pkg));
|
indentprint(alpm_pkg_get_desc(pkg), 17);
|
||||||
printf(_("Description : "));
|
printf("\n");
|
||||||
indentprint(alpm_pkg_get_desc(pkg), 20);
|
|
||||||
|
|
||||||
sum = (char *)alpm_pkg_get_md5sum(pkg);
|
if (md5sum != NULL && md5sum[0] != '\0') {
|
||||||
if (sum != NULL && sum[0] != '\0') {
|
printf(_("MD5 Sum : %s"), md5sum);
|
||||||
printf(_("\nMD5 Sum : %s"), sum);
|
|
||||||
}
|
}
|
||||||
sum = (char *)alpm_pkg_get_sha1sum(pkg);
|
if (sha1sum != NULL && sha1sum[0] != '\0') {
|
||||||
if (sum != NULL && sum[0] != '\0') {
|
printf(_("SHA1 Sum : %s"), sha1sum);
|
||||||
printf(_("\nSHA1 Sum : %s"), sum);
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Display list of backup files and their modification states
|
||||||
|
*/
|
||||||
|
void dump_pkg_backups(pmpkg_t *pkg)
|
||||||
|
{
|
||||||
|
pmlist_t *i;
|
||||||
|
const char *root = alpm_option_get_root();
|
||||||
|
printf("\nBackup Files :\n");
|
||||||
|
for(i = alpm_list_first(alpm_pkg_get_backup(pkg)); i; i = alpm_list_next(i)) {
|
||||||
|
struct stat buf;
|
||||||
|
char path[PATH_MAX];
|
||||||
|
char *str = strdup(alpm_list_getdata(i));
|
||||||
|
char *ptr = index(str, '\t');
|
||||||
|
if(ptr == NULL) {
|
||||||
|
FREE(str);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*ptr = '\0';
|
||||||
|
ptr++;
|
||||||
|
snprintf(path, PATH_MAX-1, "%s%s", root, str);
|
||||||
|
/* if we find the file, calculate checksums, otherwise it is missing */
|
||||||
|
if(!stat(path, &buf)) {
|
||||||
|
char *sum;
|
||||||
|
char *md5sum = alpm_get_md5sum(path);
|
||||||
|
char *sha1sum = alpm_get_sha1sum(path);
|
||||||
|
|
||||||
|
if(md5sum == NULL || sha1sum == NULL) {
|
||||||
|
ERR(NL, _("error calculating checksums for %s\n"), path);
|
||||||
|
FREE(str);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* TODO Is this a good way to check type of backup stored?
|
||||||
|
* We aren't storing it anywhere in the database. */
|
||||||
|
if (strlen(ptr) == 32) {
|
||||||
|
sum = md5sum;
|
||||||
|
} else { /*if (strlen(ptr) == 40) */
|
||||||
|
sum = sha1sum;
|
||||||
|
}
|
||||||
|
/* if checksums don't match, file has been modified */
|
||||||
|
if (strcmp(sum, ptr)) {
|
||||||
|
printf(_("MODIFIED\t%s\n"), path);
|
||||||
|
} else {
|
||||||
|
printf(_("Not Modified\t%s\n"), path);
|
||||||
|
}
|
||||||
|
FREE(md5sum);
|
||||||
|
FREE(sha1sum);
|
||||||
|
} else {
|
||||||
|
printf(_("MISSING\t\t%s\n"), path);
|
||||||
|
}
|
||||||
|
FREE(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* List all files contained in a package
|
||||||
|
*/
|
||||||
void dump_pkg_files(pmpkg_t *pkg)
|
void dump_pkg_files(pmpkg_t *pkg)
|
||||||
{
|
{
|
||||||
const char *pkgname;
|
const char *pkgname;
|
||||||
@ -202,47 +227,4 @@ void dump_pkg_changelog(char *clfile, const char *pkgname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int split_pkgname(char *target, char *name, char *version)
|
|
||||||
{
|
|
||||||
char tmp[512];
|
|
||||||
char *p, *q;
|
|
||||||
|
|
||||||
if(target == NULL) {
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* trim path name (if any) */
|
|
||||||
if((p = strrchr(target, '/')) == NULL) {
|
|
||||||
p = target;
|
|
||||||
} else {
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
strncpy(tmp, p, 512);
|
|
||||||
/* trim file extension (if any) */
|
|
||||||
if((p = strstr(tmp, PM_EXT_PKG))) {
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
/* trim architecture */
|
|
||||||
if((p = alpm_pkg_name_hasarch(tmp))) {
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
p = tmp + strlen(tmp);
|
|
||||||
|
|
||||||
for(q = --p; *q && *q != '-'; q--);
|
|
||||||
if(*q != '-' || q == tmp) {
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
for(p = --q; *p && *p != '-'; p--);
|
|
||||||
if(*p != '-' || p == tmp) {
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
strncpy(version, p+1, 64);
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
strncpy(name, tmp, 256);
|
|
||||||
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set ts=2 sw=2 noet: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
@ -24,11 +24,10 @@
|
|||||||
void dump_pkg_full(pmpkg_t *pkg, int level);
|
void dump_pkg_full(pmpkg_t *pkg, int level);
|
||||||
void dump_pkg_sync(pmpkg_t *pkg, char *treename);
|
void dump_pkg_sync(pmpkg_t *pkg, char *treename);
|
||||||
|
|
||||||
|
void dump_pkg_backups(pmpkg_t *pkg);
|
||||||
void dump_pkg_files(pmpkg_t *pkg);
|
void dump_pkg_files(pmpkg_t *pkg);
|
||||||
void dump_pkg_changelog(char *clfile, const char *pkgname);
|
void dump_pkg_changelog(char *clfile, const char *pkgname);
|
||||||
|
|
||||||
int split_pkgname(char *target, char *name, char *version);
|
|
||||||
|
|
||||||
#define FREEPKG(p) { alpm_pkg_free(p); p = NULL; }
|
#define FREEPKG(p) { alpm_pkg_free(p); p = NULL; }
|
||||||
|
|
||||||
#endif /* _PM_PACKAGE_H */
|
#endif /* _PM_PACKAGE_H */
|
||||||
|
@ -296,7 +296,7 @@ static int parseargs(int argc, char *argv[])
|
|||||||
#else
|
#else
|
||||||
config->configfile = strndup(optarg, PATH_MAX);
|
config->configfile = strndup(optarg, PATH_MAX);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 1002: config->op_s_ignore = list_add(config->op_s_ignore, strdup(optarg)); break;
|
case 1002: config->op_s_ignore = list_add(config->op_s_ignore, strdup(optarg)); break;
|
||||||
case 1003: config->debug = atoi(optarg); break;
|
case 1003: config->debug = atoi(optarg); break;
|
||||||
case 1004: config->noprogressbar = 1; break;
|
case 1004: config->noprogressbar = 1; break;
|
||||||
@ -307,11 +307,11 @@ static int parseargs(int argc, char *argv[])
|
|||||||
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST);
|
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST);
|
||||||
config->op_d_resolve = 1;
|
config->op_d_resolve = 1;
|
||||||
config->flags |= PM_TRANS_FLAG_ALLDEPS;
|
config->flags |= PM_TRANS_FLAG_ALLDEPS;
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE);
|
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE);
|
||||||
config->flags |= PM_TRANS_FLAG_FRESHEN;
|
config->flags |= PM_TRANS_FLAG_FRESHEN;
|
||||||
break;
|
break;
|
||||||
case 'Q': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_QUERY); break;
|
case 'Q': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_QUERY); break;
|
||||||
case 'R': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_REMOVE); break;
|
case 'R': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_REMOVE); break;
|
||||||
case 'S': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_SYNC); break;
|
case 'S': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_SYNC); break;
|
||||||
@ -321,7 +321,7 @@ static int parseargs(int argc, char *argv[])
|
|||||||
case 'Y':
|
case 'Y':
|
||||||
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST);
|
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST);
|
||||||
config->op_d_vertest = 1;
|
config->op_d_vertest = 1;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
||||||
pm_fprintf(stderr, NL, _("error: '%s' is not a valid db path\n"), optarg);
|
pm_fprintf(stderr, NL, _("error: '%s' is not a valid db path\n"), optarg);
|
||||||
@ -329,21 +329,21 @@ static int parseargs(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
alpm_option_set_dbpath(optarg);
|
alpm_option_set_dbpath(optarg);
|
||||||
config->dbpath = alpm_option_get_dbpath(optarg);
|
config->dbpath = alpm_option_get_dbpath(optarg);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
config->op_s_clean++;
|
(config->op_s_clean)++;
|
||||||
config->flags |= PM_TRANS_FLAG_CASCADE;
|
config->flags |= PM_TRANS_FLAG_CASCADE;
|
||||||
config->op_q_changelog = 1;
|
config->op_q_changelog = 1;
|
||||||
break;
|
break;
|
||||||
case 'd': config->flags |= PM_TRANS_FLAG_NODEPS; break;
|
case 'd': config->flags |= PM_TRANS_FLAG_NODEPS; break;
|
||||||
case 'e': config->op_q_orphans = 1; config->flags |= PM_TRANS_FLAG_DEPENDSONLY; break;
|
case 'e':
|
||||||
|
config->op_q_orphans = 1;
|
||||||
|
config->flags |= PM_TRANS_FLAG_DEPENDSONLY;
|
||||||
|
break;
|
||||||
case 'f': config->flags |= PM_TRANS_FLAG_FORCE; break;
|
case 'f': config->flags |= PM_TRANS_FLAG_FORCE; break;
|
||||||
case 'g': config->group++; break;
|
case 'g': (config->group)++; break;
|
||||||
case 'h': config->help = 1; break;
|
case 'h': config->help = 1; break;
|
||||||
case 'i':
|
case 'i': (config->op_q_info)++; (config->op_s_info)++; break;
|
||||||
config->op_q_info++;
|
|
||||||
config->op_s_info++;
|
|
||||||
break;
|
|
||||||
case 'k': config->flags |= PM_TRANS_FLAG_DBONLY; break;
|
case 'k': config->flags |= PM_TRANS_FLAG_DBONLY; break;
|
||||||
case 'l': config->op_q_list = 1; break;
|
case 'l': config->op_q_list = 1; break;
|
||||||
case 'm': config->op_q_foreign = 1; break;
|
case 'm': config->op_q_foreign = 1; break;
|
||||||
@ -352,7 +352,7 @@ static int parseargs(int argc, char *argv[])
|
|||||||
case 'p':
|
case 'p':
|
||||||
config->op_q_isfile = 1;
|
config->op_q_isfile = 1;
|
||||||
config->flags |= PM_TRANS_FLAG_PRINTURIS;
|
config->flags |= PM_TRANS_FLAG_PRINTURIS;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
printf("setting root path=%s\n", optarg);
|
printf("setting root path=%s\n", optarg);
|
||||||
if(realpath(optarg, root) == NULL) {
|
if(realpath(optarg, root) == NULL) {
|
||||||
@ -360,20 +360,20 @@ static int parseargs(int argc, char *argv[])
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
config->root = strdup(root);
|
config->root = strdup(root);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
config->op_s_search = 1;
|
config->op_s_search = 1;
|
||||||
config->op_q_search = 1;
|
config->op_q_search = 1;
|
||||||
config->flags |= PM_TRANS_FLAG_RECURSE;
|
config->flags |= PM_TRANS_FLAG_RECURSE;
|
||||||
break;
|
break;
|
||||||
case 'u': config->op_s_upgrade = 1; break;
|
case 'u': config->op_s_upgrade = 1; break;
|
||||||
case 'v': config->verbose++; break;
|
case 'v': (config->verbose)++; break;
|
||||||
case 'w':
|
case 'w':
|
||||||
config->op_s_downloadonly = 1;
|
config->op_s_downloadonly = 1;
|
||||||
config->flags |= PM_TRANS_FLAG_DOWNLOADONLY;
|
config->flags |= PM_TRANS_FLAG_DOWNLOADONLY;
|
||||||
config->flags |= PM_TRANS_FLAG_NOCONFLICTS;
|
config->flags |= PM_TRANS_FLAG_NOCONFLICTS;
|
||||||
break;
|
break;
|
||||||
case 'y': config->op_s_sync++; break;
|
case 'y': (config->op_s_sync)++; break;
|
||||||
case '?': return(1);
|
case '?': return(1);
|
||||||
default: return(1);
|
default: return(1);
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,51 @@ extern config_t *config;
|
|||||||
|
|
||||||
extern list_t *pmc_syncs;
|
extern list_t *pmc_syncs;
|
||||||
|
|
||||||
|
|
||||||
|
/* splits package name into its respective parts */
|
||||||
|
static int split_pkgname(char *target, char *name, char *version)
|
||||||
|
{
|
||||||
|
char tmp[512];
|
||||||
|
char *p, *q;
|
||||||
|
|
||||||
|
if(target == NULL) {
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* trim path name (if any) */
|
||||||
|
if((p = strrchr(target, '/')) == NULL) {
|
||||||
|
p = target;
|
||||||
|
} else {
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
strncpy(tmp, p, 512);
|
||||||
|
/* trim file extension (if any) */
|
||||||
|
if((p = strstr(tmp, PM_EXT_PKG))) {
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
/* trim architecture */
|
||||||
|
if((p = alpm_pkg_name_hasarch(tmp))) {
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
p = tmp + strlen(tmp);
|
||||||
|
|
||||||
|
for(q = --p; *q && *q != '-'; q--);
|
||||||
|
if(*q != '-' || q == tmp) {
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
for(p = --q; *p && *p != '-'; p--);
|
||||||
|
if(*p != '-' || p == tmp) {
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
strncpy(version, p+1, 64);
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
|
strncpy(name, tmp, 256);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
static int sync_cleancache(int level)
|
static int sync_cleancache(int level)
|
||||||
{
|
{
|
||||||
const char *root, *cachedir;
|
const char *root, *cachedir;
|
||||||
|
Loading…
Reference in New Issue
Block a user