extract db files with dbonly
Some database files (install, mtree, and changelog) are extracted directly from the package, but DBONLY was skipping extraction altogether, causing those files to be missing after the transaction. Fixes #52052 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
1a2d5bee3b
commit
2c4511bdbe
3 changed files with 78 additions and 51 deletions
|
@ -405,6 +405,10 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||
alpm_event_package_operation_t event;
|
||||
const char *log_msg = "adding";
|
||||
const char *pkgfile;
|
||||
struct archive *archive;
|
||||
struct archive_entry *entry;
|
||||
int fd, cwdfd;
|
||||
struct stat buf;
|
||||
|
||||
ASSERT(trans != NULL, return -1);
|
||||
|
||||
|
@ -477,14 +481,6 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if(!(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
|
||||
struct archive *archive;
|
||||
struct archive_entry *entry;
|
||||
struct stat buf;
|
||||
int fd, cwdfd;
|
||||
|
||||
_alpm_log(handle, ALPM_LOG_DEBUG, "extracting files\n");
|
||||
|
||||
fd = _alpm_open_archive(db->handle, pkgfile, &buf,
|
||||
&archive, ALPM_ERR_PKG_OPEN);
|
||||
if(fd < 0) {
|
||||
|
@ -511,6 +507,19 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if(trans->flags & ALPM_TRANS_FLAG_DBONLY) {
|
||||
_alpm_log(handle, ALPM_LOG_DEBUG, "extracting db files\n");
|
||||
while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
|
||||
const char *entryname = archive_entry_pathname(entry);
|
||||
if(entryname[0] == '.') {
|
||||
errors += extract_db_file(handle, archive, entry, newpkg, entryname);
|
||||
} else {
|
||||
archive_read_data_skip(archive);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_alpm_log(handle, ALPM_LOG_DEBUG, "extracting files\n");
|
||||
|
||||
/* call PROGRESS once with 0 percent, as we sort-of skip that here */
|
||||
PROGRESS(handle, progress, newpkg->name, 0, pkg_count, pkg_current);
|
||||
|
||||
|
@ -535,6 +544,8 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||
/* extract the next file from the archive */
|
||||
errors += extract_single_file(handle, archive, entry, newpkg, oldpkg);
|
||||
}
|
||||
}
|
||||
|
||||
_alpm_archive_read_free(archive);
|
||||
close(fd);
|
||||
|
||||
|
@ -563,7 +574,6 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||
newpkg->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* make an install date (in UTC) */
|
||||
newpkg->installdate = time(NULL);
|
||||
|
|
|
@ -11,6 +11,7 @@ TESTS += test/pacman/tests/database002.py
|
|||
TESTS += test/pacman/tests/database010.py
|
||||
TESTS += test/pacman/tests/database011.py
|
||||
TESTS += test/pacman/tests/database012.py
|
||||
TESTS += test/pacman/tests/dbonly-extracted-files.py
|
||||
TESTS += test/pacman/tests/depconflict100.py
|
||||
TESTS += test/pacman/tests/depconflict110.py
|
||||
TESTS += test/pacman/tests/depconflict111.py
|
||||
|
|
16
test/pacman/tests/dbonly-extracted-files.py
Normal file
16
test/pacman/tests/dbonly-extracted-files.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
import util
|
||||
import os.path
|
||||
|
||||
self.description = "Install a package with dbonly"
|
||||
|
||||
sp = pmpkg("foobar", "1-1")
|
||||
sp.files = ["bin/foobar"]
|
||||
sp.install['post_install'] = "echo foobar"
|
||||
self.addpkg2db("sync", sp)
|
||||
|
||||
self.args = "-S --dbonly %s" % sp.name
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
self.addrule("PKG_EXIST=foobar")
|
||||
self.addrule("FILE_EXIST=%s" % os.path.join(util.PM_DBPATH, "local/foobar-1-1/install"))
|
||||
self.addrule("!FILE_EXIST=bin/foobar")
|
Loading…
Add table
Reference in a new issue