diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index 5622b225..d060723f 100644 --- a/bin/xbps-install/main.c +++ b/bin/xbps-install/main.c @@ -47,21 +47,20 @@ usage(bool fail) " -C --config Path to confdir (xbps.d)\n" " -c --cachedir 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= Add repository to the top of the list.\n" - " This option can be specified multiple times.\n" + " -R,--repository= Add repository to the top of the list\n" + " This option can be specified multiple times\n" " -r --rootdir 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" diff --git a/bin/xbps-install/xbps-install.1 b/bin/xbps-install/xbps-install.1 index 73f976ba..ea86f7b8 100644 --- a/bin/xbps-install/xbps-install.1 +++ b/bin/xbps-install/xbps-install.1 @@ -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 diff --git a/include/xbps.h.in b/include/xbps.h.in index 1443cae3..4814c58f 100644 --- a/include/xbps.h.in +++ b/include/xbps.h.in @@ -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 diff --git a/lib/package_register.c b/lib/package_register.c index dcf150e9..e482493e 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -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. */ diff --git a/tests/xbps/xbps-install/behaviour_tests.sh b/tests/xbps/xbps-install/behaviour_tests.sh index 3185eef6..fdd375d6 100644 --- a/tests/xbps/xbps-install/behaviour_tests.sh +++ b/tests/xbps/xbps-install/behaviour_tests.sh @@ -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() {