Remove leading "./" from filenames in mtree file

A properly formatted mtree file may stick a leading "./" in front
of file names in the root directory.  Strip this if present.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2012-09-09 11:13:55 +10:00
parent 7d27b2b0f4
commit 5186f702d3
1 changed files with 7 additions and 0 deletions

View File

@ -248,18 +248,25 @@ int check_pkg_full(alpm_pkg_t *pkg)
mode_t type;
size_t file_errors = 0;
/* strip leading "./" from path entries */
if(path[0] == '.' && path[1] == '/') {
path += 2;
}
if(strcmp(path, ".INSTALL") == 0) {
char filename[PATH_MAX];
snprintf(filename, PATH_MAX, "%slocal/%s-%s/install",
alpm_option_get_dbpath(config->handle) + 1,
pkgname, alpm_pkg_get_version(pkg));
archive_entry_set_pathname(entry, filename);
path = archive_entry_pathname(entry);
} else if(strcmp(path, ".CHANGELOG") == 0) {
char filename[PATH_MAX];
snprintf(filename, PATH_MAX, "%slocal/%s-%s/changelog",
alpm_option_get_dbpath(config->handle) + 1,
pkgname, alpm_pkg_get_version(pkg));
archive_entry_set_pathname(entry, filename);
path = archive_entry_pathname(entry);
} else if(*path == '.') {
continue;
}