Merge branch 'morganamilo/backup' into morganamilo/tip
This commit is contained in:
commit
15eb65c839
2 changed files with 30 additions and 24 deletions
|
@ -351,7 +351,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
|
||||||
|
|
||||||
/* Print additional package info if info flag passed more than once */
|
/* Print additional package info if info flag passed more than once */
|
||||||
if(from == ALPM_PKG_FROM_LOCALDB && extra) {
|
if(from == ALPM_PKG_FROM_LOCALDB && extra) {
|
||||||
dump_backup_status(pkg);
|
dump_backup_status(pkg, cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* final newline to separate packages */
|
/* final newline to separate packages */
|
||||||
|
@ -410,21 +410,21 @@ static const char *get_backup_file_status(const char *root,
|
||||||
|
|
||||||
/* if checksums don't match, file has been modified */
|
/* if checksums don't match, file has been modified */
|
||||||
if(strcmp(md5sum, backup->hash) != 0) {
|
if(strcmp(md5sum, backup->hash) != 0) {
|
||||||
ret = "MODIFIED";
|
ret = "[modified]";
|
||||||
} else {
|
} else {
|
||||||
ret = "UNMODIFIED";
|
ret = "[unmodified]";
|
||||||
}
|
}
|
||||||
free(md5sum);
|
free(md5sum);
|
||||||
} else {
|
} else {
|
||||||
switch(errno) {
|
switch(errno) {
|
||||||
case EACCES:
|
case EACCES:
|
||||||
ret = "UNREADABLE";
|
ret = "[unreadable]";
|
||||||
break;
|
break;
|
||||||
case ENOENT:
|
case ENOENT:
|
||||||
ret = "MISSING";
|
ret = "[missing]";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = "UNKNOWN";
|
ret = "[unknown]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -432,27 +432,33 @@ static const char *get_backup_file_status(const char *root,
|
||||||
|
|
||||||
/* Display list of backup files and their modification states
|
/* Display list of backup files and their modification states
|
||||||
*/
|
*/
|
||||||
void dump_backup_status(alpm_pkg_t *pkg)
|
void dump_backup_status(alpm_pkg_t *pkg, unsigned short cols)
|
||||||
{
|
{
|
||||||
alpm_list_t *i;
|
alpm_list_t *i, *text = NULL;
|
||||||
const char *root = alpm_option_get_root(config->handle);
|
const char *root = alpm_option_get_root(config->handle);
|
||||||
printf("%s%s\n%s", config->colstr.title, titles[T_BACKUP_FILES],
|
|
||||||
config->colstr.nocolor);
|
|
||||||
if(alpm_pkg_get_backup(pkg)) {
|
|
||||||
/* package has backup files, so print them */
|
/* package has backup files, so print them */
|
||||||
for(i = alpm_pkg_get_backup(pkg); i; i = alpm_list_next(i)) {
|
for(i = alpm_pkg_get_backup(pkg); i; i = alpm_list_next(i)) {
|
||||||
const alpm_backup_t *backup = i->data;
|
const alpm_backup_t *backup = i->data;
|
||||||
const char *value;
|
const char *value;
|
||||||
|
char *line;
|
||||||
|
size_t needed;
|
||||||
if(!backup->hash) {
|
if(!backup->hash) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
value = get_backup_file_status(root, backup);
|
value = get_backup_file_status(root, backup);
|
||||||
printf("%s\t%s%s\n", value, root, backup->name);
|
needed = strlen(root) + strlen(backup->name) + 1 + strlen(value) + 1;
|
||||||
|
line = malloc(needed);
|
||||||
|
if(!line) {
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
sprintf(line, "%s%s %s", root, backup->name, value);
|
||||||
/* package had no backup files */
|
text = alpm_list_add(text, line);
|
||||||
printf(_("(none)\n"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_display_linebreak(titles[T_BACKUP_FILES], text, cols);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
FREELIST(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List all files contained in a package
|
/* List all files contained in a package
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
void dump_pkg_full(alpm_pkg_t *pkg, int extra);
|
void dump_pkg_full(alpm_pkg_t *pkg, int extra);
|
||||||
|
|
||||||
void dump_backup_status(alpm_pkg_t *pkg);
|
void dump_backup_status(alpm_pkg_t *pkg, unsigned short cols);
|
||||||
void dump_pkg_backups(alpm_pkg_t *pkg, int quiet, int all);
|
void dump_pkg_backups(alpm_pkg_t *pkg, int quiet, int all);
|
||||||
void dump_pkg_files(alpm_pkg_t *pkg, int quiet);
|
void dump_pkg_files(alpm_pkg_t *pkg, int quiet);
|
||||||
void dump_pkg_changelog(alpm_pkg_t *pkg);
|
void dump_pkg_changelog(alpm_pkg_t *pkg);
|
||||||
|
|
Loading…
Add table
Reference in a new issue