Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
pkg: Support bootstrap -f
Bryan Drewery committed 12 years ago
commit 923e171e391a524e6c5de964ccd5c5f3f1d55a9c
parent 6f47559
2 files changed +38 -3
modified pkg/main.c
@@ -706,9 +706,29 @@ main(int argc, char **argv)
	if (activation_test)
		do_activation_test(argc);

-
	if (argc == 1 && strcmp(argv[0], "bootstrap") == 0) {
-
		printf("pkg already bootstrapped\n");
-
		exit(EXIT_SUCCESS);
+
	if (argc >= 1 && strcmp(argv[0], "bootstrap") == 0) {
+
		if (argc == 1) {
+
			printf("pkg(8) already installed, use -f to force.\n");
+
			exit(EXIT_SUCCESS);
+
		} else if (argc == 2 && strcmp(argv[1], "-f") == 0) {
+
			if (access("/usr/sbin/pkg", R_OK) == 0) {
+
				/* Only 10.0+ supported 'bootstrap -f' */
+
#if __FreeBSD_version < 1000502
+
				printf("Execute these steps to rebootstrap"
+
				     " pkg(8):\n");
+
				printf("# pkg delete -f pkg\n");
+
				printf("# /usr/sbin/pkg -v\n");
+
				exit(EXIT_SUCCESS);
+
#endif
+
				printf("pkg(8) is already installed. Forcing "
+
				    "reinstallation through pkg(7).\n");
+
				execl("/usr/sbin/pkg", "pkg", "bootstrap",
+
				    "-f", NULL);
+
				/* NOTREACHED */
+
			} else
+
				errx(EXIT_FAILURE, "pkg(7) bootstrapper not"
+
				    " found at /usr/sbin/pkg.");
+
		}
	}

	newargv = argv;
modified pkg/pkg.8
@@ -179,6 +179,21 @@ Audits installed packages against known vulnerabilities.
Delete packages which were automatically installed as dependencies and are not required any more.
.It Ic backup
Dump the local package database to a file specified on the command-line.
+
.It Ic bootstrap
+
This is for compatibility with the
+
.Xr pkg 7
+
bootstrapper.
+
If
+
.Nm
+
is already installed, nothing is done.
+
.Pp
+
If invoked with the
+
.Fl f
+
flag an attempt will be made to reinstall
+
.Nm
+
from remote repository.
+
This is not supported on FreeBSD 8.3 as it did not have
+
.Xr pkg 7 .
.It Ic check
Sanity checks installed packages.
.It Ic clean