xbps-install: fix --reproducable.
The 'repository' obj also needs to be skipped to be fully reproducable between different repositories. Updated the test case accordingly.
This commit is contained in:
parent
2c7c4e1bf0
commit
d68ff7ebf0
@ -47,21 +47,20 @@ usage(bool fail)
|
||||
" -C --config <dir> Path to confdir (xbps.d)\n"
|
||||
" -c --cachedir <dir> Path to cachedir\n"
|
||||
" -d --debug Debug mode shown to stderr\n"
|
||||
" -D --download-only Download packages and check integrity, nothing else.\n"
|
||||
" -D --download-only Download packages and check integrity, nothing else\n"
|
||||
" -f --force Force package re-installation\n"
|
||||
" If specified twice, all files will be\n"
|
||||
" overwritten.\n"
|
||||
" If specified twice, all files will be overwritten.\n"
|
||||
" -h --help Print help usage\n"
|
||||
" -i --ignore-conf-repos Ignore repositories defined in xbps.d\n"
|
||||
" -I --ignore-file-conflicts Ignore detected file conflicts.\n"
|
||||
" -I --ignore-file-conflicts Ignore detected file conflicts\n"
|
||||
" -U --unpack-only Unpack packages in transaction, do not configure them\n"
|
||||
" -M --memory-sync Remote repository data is fetched and stored\n"
|
||||
" in memory, ignoring on-disk repodata archives.\n"
|
||||
" in memory, ignoring on-disk repodata archives\n"
|
||||
" -n --dry-run Dry-run mode\n"
|
||||
" -R,--repository=<url> Add repository to the top of the list.\n"
|
||||
" This option can be specified multiple times.\n"
|
||||
" -R,--repository=<url> Add repository to the top of the list\n"
|
||||
" This option can be specified multiple times\n"
|
||||
" -r --rootdir <dir> Full path to rootdir\n"
|
||||
" --reproducible Enable reproducible mode in pkgdb.\n"
|
||||
" --reproducible Enable reproducible mode in pkgdb\n"
|
||||
" -S --sync Sync remote repository index\n"
|
||||
" -u --update Update target package(s)\n"
|
||||
" -v --verbose Verbose messages\n"
|
||||
|
@ -116,7 +116,9 @@ This option can be specified multiple times.
|
||||
.It Fl -reproducible
|
||||
Enables reproducible mode in pkgdb. The
|
||||
.Ar install-date
|
||||
package object is not added to pkgdb.
|
||||
and
|
||||
.Ar repository
|
||||
package objects are not stored in pkgdb.
|
||||
.It Fl r, Fl -rootdir Ar dir
|
||||
Specifies a full path for the target root directory.
|
||||
.It Fl S, Fl -sync
|
||||
|
@ -232,7 +232,8 @@
|
||||
|
||||
/**
|
||||
* @def XBPS_FLAG_INSTALL_REPRO
|
||||
* Enabled reproducible mode; skips adding the "install-date" obj into pkgdb.
|
||||
* Enabled reproducible mode; skips adding the "install-date"
|
||||
* and "repository" objs into pkgdb.
|
||||
* Must be set through the xbps_handle::flags member.
|
||||
*/
|
||||
#define XBPS_FLAG_INSTALL_REPRO 0x00008000
|
||||
|
@ -64,10 +64,17 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Set the "install-date" object to know the pkg installation date.
|
||||
*/
|
||||
if ((xhp->flags & XBPS_FLAG_INSTALL_REPRO) == 0) {
|
||||
if (xhp->flags & XBPS_FLAG_INSTALL_REPRO) {
|
||||
/*
|
||||
* Reproducible mode. Some objects must not be recorded:
|
||||
* - install-date
|
||||
* - repository
|
||||
*/
|
||||
xbps_dictionary_remove(pkgd, "repository");
|
||||
} else {
|
||||
/*
|
||||
* Set the "install-date" object to know the pkg installation date.
|
||||
*/
|
||||
t = time(NULL);
|
||||
if ((tmp = localtime(&t)) == NULL) {
|
||||
xbps_dbg_printf(xhp, "%s: localtime failed: %s\n",
|
||||
@ -105,6 +112,7 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
|
||||
xbps_dictionary_remove(pkgd, "skip-obsoletes");
|
||||
xbps_dictionary_remove(pkgd, "pkgname");
|
||||
xbps_dictionary_remove(pkgd, "version");
|
||||
|
||||
/*
|
||||
* Remove self replacement when applicable.
|
||||
*/
|
||||
|
@ -65,40 +65,40 @@ reproducible_head() {
|
||||
}
|
||||
|
||||
reproducible_body() {
|
||||
mkdir -p repo pkg_A
|
||||
mkdir -p repo-1 repo-2 pkg_A
|
||||
touch pkg_A/file
|
||||
cd repo
|
||||
cd repo-1
|
||||
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
|
||||
atf_check_equal $? 0
|
||||
xbps-rindex -d -a $PWD/*.xbps
|
||||
atf_check_equal $? 0
|
||||
cd ../repo-2
|
||||
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
|
||||
atf_check_equal $? 0
|
||||
xbps-rindex -d -a $PWD/*.xbps
|
||||
atf_check_equal $? 0
|
||||
cd ..
|
||||
xbps-install -r root-1 --repo=$PWD/repo --repro -y A
|
||||
|
||||
xbps-install -r root-1 --repo=$PWD/repo-1 --repro -y A
|
||||
atf_check_equal $? 0
|
||||
xbps-install -r root-2 --repo=$PWD/repo --repro -y A
|
||||
xbps-install -r root-2 --repo=$PWD/repo-2 --repro -y A
|
||||
atf_check_equal $? 0
|
||||
|
||||
# Compare pkgdb in both rootdirs
|
||||
cmp root-1/var/db/xbps/pkgdb-0.38.plist root-2/var/db/xbps/pkgdb-0.38.plist
|
||||
atf_check_equal $? 0
|
||||
# compare pkgdb meta files in both rootdirs
|
||||
cmp root-1/var/db/xbps/.A-files.plist root-2/var/db/xbps/.A-files.plist
|
||||
cmp -s root-1/var/db/xbps/pkgdb-0.38.plist root-2/var/db/xbps/pkgdb-0.38.plist
|
||||
atf_check_equal $? 0
|
||||
|
||||
# Now check without --reproducible
|
||||
rm -rf root-1 root-2
|
||||
|
||||
xbps-install -r root-1 --repo=$PWD/repo --repro -y A
|
||||
xbps-install -r root-1 --repo=$PWD/repo-1 --repro -y A
|
||||
atf_check_equal $? 0
|
||||
xbps-install -r root-2 --repo=$PWD/repo -y A
|
||||
xbps-install -r root-2 --repo=$PWD/repo-2 -y A
|
||||
atf_check_equal $? 0
|
||||
|
||||
# Compare pkgdb in both rootdirs
|
||||
cmp root-1/var/db/xbps/pkgdb-0.38.plist root-2/var/db/xbps/pkgdb-0.38.plist
|
||||
cmp -s root-1/var/db/xbps/pkgdb-0.38.plist root-2/var/db/xbps/pkgdb-0.38.plist
|
||||
atf_check_equal $? 1
|
||||
# compare pkgdb meta files in both rootdirs
|
||||
cmp root-1/var/db/xbps/.A-files.plist root-2/var/db/xbps/.A-files.plist
|
||||
atf_check_equal $? 0
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
|
Loading…
Reference in New Issue
Block a user