From b05f4b4db562197524a69a4359b5c21d22bdbdf0 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 29 Dec 2019 10:38:55 +0100 Subject: [PATCH] xbps-install: added --reproducible long option. If set, enables reproducible mode in pkgdb. Added a new test case. --- bin/xbps-install/main.c | 5 +++ bin/xbps-install/xbps-install.1 | 6 ++- tests/xbps/xbps-install/behaviour_tests.sh | 44 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index 3622af5a..5622b225 100644 --- a/bin/xbps-install/main.c +++ b/bin/xbps-install/main.c @@ -61,6 +61,7 @@ usage(bool fail) " -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" " -S --sync Sync remote repository index\n" " -u --update Update target package(s)\n" " -v --verbose Verbose messages\n" @@ -117,6 +118,7 @@ main(int argc, char **argv) { "verbose", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'V' }, { "yes", no_argument, NULL, 'y' }, + { "reproducible", no_argument, NULL, 1 }, { NULL, 0, NULL, 0 } }; struct xbps_handle xh; @@ -134,6 +136,9 @@ main(int argc, char **argv) while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) { switch (c) { + case 1: + flags |= XBPS_FLAG_INSTALL_REPRO; + break; case 'A': flags |= XBPS_FLAG_INSTALL_AUTO; break; diff --git a/bin/xbps-install/xbps-install.1 b/bin/xbps-install/xbps-install.1 index f551fcec..73f976ba 100644 --- a/bin/xbps-install/xbps-install.1 +++ b/bin/xbps-install/xbps-install.1 @@ -1,4 +1,4 @@ -.Dd June 21, 2019 +.Dd December 29, 2019 .Dt XBPS-INSTALL 1 .Sh NAME .Nm xbps-install @@ -113,6 +113,10 @@ a path for local repositories. Note that remote repositories must be signed using .Xr xbps-rindex 1 . 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. .It Fl r, Fl -rootdir Ar dir Specifies a full path for the target root directory. .It Fl S, Fl -sync diff --git a/tests/xbps/xbps-install/behaviour_tests.sh b/tests/xbps/xbps-install/behaviour_tests.sh index 4430ada5..3185eef6 100644 --- a/tests/xbps/xbps-install/behaviour_tests.sh +++ b/tests/xbps/xbps-install/behaviour_tests.sh @@ -58,7 +58,51 @@ update_existent_body() { atf_check_equal $? 0 } +atf_test_case reproducible + +reproducible_head() { + atf_set "descr" "xbps-install(1): test --reproducible" +} + +reproducible_body() { + mkdir -p repo pkg_A + touch pkg_A/file + cd repo + 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 + atf_check_equal $? 0 + xbps-install -r root-2 --repo=$PWD/repo --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 + 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 + atf_check_equal $? 0 + xbps-install -r root-2 --repo=$PWD/repo -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 $? 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() { atf_add_test_case install_existent atf_add_test_case update_existent + atf_add_test_case reproducible }