xbps-install: added --reproducible long option.
If set, enables reproducible mode in pkgdb. Added a new test case.
This commit is contained in:
		@@ -61,6 +61,7 @@ usage(bool fail)
 | 
			
		||||
	    " -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"
 | 
			
		||||
	    " -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user