Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge branch 'master' of github.com:pkgng/pkgng
Matthew Seaman committed 13 years ago
commit 4e16cb98255ce49b7e019037aeb8e805c9941a75
parent b996d70
6 files changed +181 -107
modified pkg/delete.c
@@ -39,8 +39,8 @@
void
usage_delete(void)
{
-
	fprintf(stderr, "usage: pkg delete [-yqgxXfr] <pkg-name> <...>\n");
-
	fprintf(stderr, "       pkg delete [-yq] -a\n\n");
+
	fprintf(stderr, "usage: pkg delete [-fgnqRXxy] <pkg-name> ...\n");
+
	fprintf(stderr, "       pkg delete [-nqy] -a\n\n");
	fprintf(stderr, "For more information see 'pkg help delete'.\n");
}

@@ -56,35 +56,39 @@ exec_delete(int argc, char **argv)
	int flags = PKG_LOAD_BASIC;
	int force = 0;
	bool yes = false;
+
	bool dry_run = false;
	int retcode = EX_SOFTWARE;
	int recursive = 0;

-
	while ((ch = getopt(argc, argv, "aqgxXfyR")) != -1) {
+
	while ((ch = getopt(argc, argv, "afgnqRXxy")) != -1) {
		switch (ch) {
		case 'a':
			match = MATCH_ALL;
			break;
+
		case 'f':
+
			force = 1;
+
			break;
		case 'g':
			match = MATCH_GLOB;
			break;
-
		case 'x':
-
			match = MATCH_REGEX;
+
		case 'n':
+
			dry_run = true;
+
			break;
+
		case 'q':
+
			quiet = true;
+
			break;
+
		case 'R':
+
			recursive = 1;
			break;
		case 'X':
			match = MATCH_EREGEX;
			break;
-
		case 'f':
-
			force = 1;
-
			break;
-
		case 'q':
-
			quiet = true;
+
		case 'x':
+
			match = MATCH_REGEX;
			break;
		case 'y':
			yes = true;
			break;
-
		case 'R':
-
			recursive = 1;
-
			break;
		default:
			usage_delete();
			return (EX_USAGE);
@@ -135,14 +139,17 @@ exec_delete(int argc, char **argv)
	}

	pkg = NULL;
-
	if (!quiet) {
-
		print_jobs_summary(jobs, PKG_JOBS_DEINSTALL, "The following packages will be deinstalled:\n\n");
+
	if (!quiet || dry_run) {
+
		print_jobs_summary(jobs, PKG_JOBS_DEINSTALL,
+
		    "The following packages will be deinstalled:\n\n");

		if (!yes)
			pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
-
		if (!yes)
-
			yes = query_yesno("\nProceed with deinstalling packages [y/N]: ");
-

+
		if (!yes && !dry_run)
+
			yes = query_yesno(
+
		            "\nProceed with deinstalling packages [y/N]: ");
+
		if (dry_run)
+
			yes = false;
	}
	if (yes) {
		if ((retcode = pkg_jobs_apply(jobs, force)) != EPKG_OK)
modified pkg/install.c
@@ -44,7 +44,8 @@
void
usage_install(void)
{
-
	fprintf(stderr, "usage: pkg install [-r reponame] [-yqfgxXRL] <pkg-name> <...>\n\n");
+
	fprintf(stderr,
+
	    "usage: pkg install [-fgLnqRXxy] [-r reponame] <pkg-name> ...\n\n");
	fprintf(stderr, "For more information see 'pkg help install'.\n");
}

@@ -64,36 +65,40 @@ exec_install(int argc, char **argv)

	match_t match = MATCH_EXACT;
	bool force = false;
+
	bool dry_run = false;

-
	while ((ch = getopt(argc, argv, "yfgxXr:qLR")) != -1) {
+
	while ((ch = getopt(argc, argv, "fgLnqRr:Xxy")) != -1) {
		switch (ch) {
-
		case 'y':
-
			yes = true;
+
		case 'f':
+
			force = true;
			break;
		case 'g':
			match = MATCH_GLOB;
			break;
-
		case 'x':
-
			match = MATCH_REGEX;
-
			break;
-
		case 'X':
-
			match = MATCH_EREGEX;
-
			break;
-
		case 'r':
-
			reponame = optarg;
+
		case 'L':
+
			auto_update = false;
			break;
-
		case 'f':
-
			force = true;
+
		case 'n':
+
			dry_run = true;
			break;
		case 'q':
			quiet = true;
			break;
-
		case 'L':
-
			auto_update = false;
-
			break;
		case 'R':
			recursive = true;
			break;
+
		case 'r':
+
			reponame = optarg;
+
			break;
+
		case 'X':
+
			match = MATCH_EREGEX;
+
			break;
+
		case 'x':
+
			match = MATCH_REGEX;
+
			break;
+
		case 'y':
+
			yes = true;
+
			break;
		default:
			usage_install();
			return (EX_USAGE);
@@ -124,10 +129,12 @@ exec_install(int argc, char **argv)
		goto cleanup;
	}

-
	if ((it = pkgdb_query_installs(db, match, argc, argv, reponame, force, recursive)) == NULL)
+
	if ((it = pkgdb_query_installs(db, match, argc, argv, reponame,
+
	    force, recursive)) == NULL)
		goto cleanup;

-
	while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC|PKG_LOAD_DEPS) == EPKG_OK) {
+
	while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC|PKG_LOAD_DEPS) ==
+
	    EPKG_OK) {
		pkg_jobs_add(jobs, pkg);
		pkg = NULL;
	}
@@ -138,13 +145,17 @@ exec_install(int argc, char **argv)

	/* print a summary before applying the jobs */
	pkg = NULL;
-
	if (!quiet) {
-
		print_jobs_summary(jobs, PKG_JOBS_INSTALL, "The following packages will be installed:\n\n");
+
	if (!quiet || dry_run) {
+
		print_jobs_summary(jobs, PKG_JOBS_INSTALL,
+
		    "The following packages will be installed:\n\n");

		if (!yes)
			pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
-
		if (!yes)
-
			yes = query_yesno("\nProceed with installing packages [y/N]: ");
+
		if (!yes && !dry_run)
+
			yes = query_yesno(
+
			    "\nProceed with installing packages [y/N]: ");
+
		if (dry_run)
+
			yes = false;
	}

	if (yes)
modified pkg/pkg-delete.8
@@ -20,37 +20,63 @@
.Os
.Sh NAME
.Nm "pkg delete"
-
.Nd deletes a package from the database and the system
+
.Nd deletes packages from the database and the system
.Sh SYNOPSIS
.Nm
-
.Op Fl ay
+
.Op Fl fgnqRXxy
+
.Ar <pkg-name> ...
.Nm
-
.Op Fl yqfRgxX
-
.Ar <pkg-name> <...>
+
.Op Fl nqy
+
.Fl a
.Sh DESCRIPTION
.Nm
-
is used for deleting previously installed packages and removes them from the
-
database.
+
is used for deleting installed packages from the system.
+
.Nm
+
creates a work-list of all the installed packages matching the package
+
names on the command line.
+
The list is presented to the user.
+
If the user confirms that they do want to remove those packages, or
+
if the
+
.Cm ASSUME_ALWAYS_YES
+
consifuration option is set,
+
.Nm
+
proceeds to remove the listed packages.
+
.Pp
+
If the set of packages to be deleted would leave installed packages
+
with unfulfilled dependencies,
+
.Nm
+
will emit an error message and quit without deleting anything unless
+
forced to proceed by the
+
.Fl f
+
option.
.Sh OPTIONS
The following options are supported by
.Nm :
.Bl -tag -width F1
-
.It Fl f
-
Forces packages to be removed.
.It Fl a
-
Deletes all installed packages from the system and the database.
-
.It Fl y
-
Assume yes when asked for confirmation before package deletion.
+
Deletes all installed packages from the system and empties the database.
+
.It Fl f
+
Forces packages to be removed despite leaving unresolved dependencies.
.It Fl g
Treat the package names as shell glob patterns.
+
.It Fl n
+
Dry run mode.
+
The list of packages to delete is always printed, but no packages are
+
actually deleted.
+
.It Fl q
+
Force quiet output, except where
+
.Fl n
+
is also used, when
+
.Nm
+
will show the list of packages to be deleted.
.It Fl R
-
Recursively delete all packages that depend on the deleted package as well.
-
.It Fl x
-
Treat the package names as regular expressions.
+
Delete all packages that require the listed packages as well.
.It Fl X
Treat the package names as extended regular expressions.
-
.It Fl q
-
Force quiet output
+
.It Fl x
+
Treat the package names as regular expressions.
+
.It Fl y
+
Assume yes when asked for confirmation before package deletion.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
modified pkg/pkg-install.8
@@ -23,9 +23,9 @@
.Nd installs packages from remote package repositories
.Sh SYNOPSIS
.Nm
+
.Op Fl fgLnqRXxy
.Op Fl r Ar reponame
-
.Op Fl yqfgxXRL
-
.Ar <pkg-origin> <...>
+
.Ar <pkg-origin> ...
.Sh DESCRIPTION
.Nm
is used for installation of packages from a remote package
@@ -71,18 +71,22 @@ for finding the autoremoval status of a package, and
.Xr pkg-set 8
for modifying it.
.Pp
+
Currently
.Nm
-
can install packages from multiple repositories.
-
Repository catalogues will be downloaded from all listed repositories.
-
The order in which repositories are listed in
+
will only use one repository to install packages from.
+
When
+
.Ev PACKAGESITE
+
is set in the environment, or the equivalent
+
.Cm PACKAGESITE
+
setting is present in
.Fa pkg.conf
-
is significant.
-
If a package is found to exist in more than one repository, package
-
fetching will be attempted from each repository listed as containing
-
the package in the order specified in
-
.Fa pkg.conf ,
-
until either the package has been successfully downloaded or all
-
the repositories have been tried.
+
only that site will be used.
+
.Pp
+
Alternatively, when in multi-repo mode, the
+
.Fl r
+
option may be used to select one of the package repositories listed
+
in the configuration file.
+
Otherwise the default repository will be used.
.Pp
Multiple package repository support is only activated when neither the
environment variable
@@ -90,9 +94,6 @@ environment variable
nor the equivalent
.Cm PACKAGESITE
configuration setting are defined.
-
When
-
.Ev PACKAGESITE
-
is defined only the referenced repository will be used.
.Pp
Package repository catalogues will be automatically updated whenever
.Xr pkg-update 8
@@ -106,31 +107,38 @@ package installation with
The following options are supported by
.Nm :
.Bl -tag -width F1
-
.It Fl r Ar reponame
-
In multi-repo mode, override the
-
.Fa pkg.conf
-
ordering and only attempt to download packages from the named
-
repository.
-
.It Fl y
-
Assume yes when asked for confirmation before package installation.
-
.It Fl g
-
Treat the package names as shell glob patterns.
-
.It Fl x
-
Treat the package names as regular expressions.
-
.It Fl X
-
Treat the package names as extended regular expressions.
.It Fl f
Force the reinstallation of the package if already installed.
-
.It Fl q
-
Force quiet output.
+
.It Fl g
+
Treat the package names as shell glob patterns.
.It Fl L
Don't auto update repository catalogues with
.Xr pkg-update 8 .
Use the locally cached copies only.
+
.It Fl n
+
Dry-run mode.  The list of changes to packages is always printed, but
+
no changes are actually made.
+
.It Fl q
+
Force quiet output, except when
+
.Fl n
+
is used, where
+
.Nm
+
will always show packages to be installed, upgraded or deleted.
.It Fl R
When used with
.Fl f ,
reinstalls any packages that require the given package.
+
.It Fl r Ar reponame
+
In multi-repo mode, override the
+
.Fa pkg.conf
+
ordering and only attempt to download packages from the named
+
repository.
+
.It Fl X
+
Treat the package names as extended regular expressions.
+
.It Fl x
+
Treat the package names as regular expressions.
+
.It Fl y
+
Assume yes when asked for confirmation before package installation.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
modified pkg/pkg-upgrade.8
@@ -23,14 +23,20 @@
.Nd performs upgrades of package software distributions
.Sh SYNOPSIS
.Nm
-
.Op Fl yfqL
+
.Op Fl fLnqy
+
.Op Fl r Ar reponame
.Sh DESCRIPTION
.Nm
is used for upgrading of package software distributions.
.Pp
-
Currently only one package repository can be
-
used during package upgrades as defined by the environment variable
-
.Ev PACKAGESITE .
+
Currently only one package repository can be used during package
+
upgrades.
+
This is either as defined by the environment variable
+
.Ev PACKAGESITE ,
+
or when in multi-repos mode, either the default repository or the
+
argument to the
+
.Fl r
+
option.
.Pp
Soon enough
.Nm
@@ -45,16 +51,26 @@ flag.
The following options are supported by
.Nm :
.Bl -tag -width F1
-
.It Fl y
-
Assume yes when asked for confirmation before package installation.
.It Fl f
Force reinstalling/upgrading the whole set of packages
-
.It Fl q
-
Force quiet output
.It Fl L
Don't auto update the remote database with
.Xr pkg-update 8 .
Use the local cache only.
+
.It Fl n
+
Dry-run mode: show what packages have updates available, but do not perform
+
any upgrades.
+
Repository catalogues will be updated as usual unless the
+
.Fl L
+
option is also given.
+
.It Fl q
+
Force quiet output, except when
+
.Fl n
+
is used, where
+
.Nm
+
will always print out the list of packages with available updates.
+
.It Fl y
+
Assume yes when asked for confirmation before package installation.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
modified pkg/upgrade.c
@@ -37,7 +37,7 @@
void
usage_upgrade(void)
{
-
	fprintf(stderr, "usage: pkg upgrade [-r reponame] [-yfqL]\n\n");
+
	fprintf(stderr, "usage: pkg upgrade [-fLnqy] [-r reponame]\n\n");
	fprintf(stderr, "For more information see 'pkg help upgrade'.\n");
}

@@ -53,6 +53,7 @@ exec_upgrade(int argc, char **argv)
	int ch;
	bool yes = false;
	bool all = false;
+
	bool dry_run = false;
	bool auto_update = true;

	if (geteuid() != 0) {
@@ -60,22 +61,25 @@ exec_upgrade(int argc, char **argv)
		return (EX_NOPERM);
	}

-
	while ((ch = getopt(argc, argv, "yr:fqL")) != -1) {
+
	while ((ch = getopt(argc, argv, "fLnqr:y")) != -1) {
		switch (ch) {
-
		case 'y':
-
			yes = true;
+
		case 'f':
+
			all = true;
			break;
-
		case 'r':
-
			reponame = optarg;
+
		case 'L':
+
			auto_update = false;
+
			break;
+
		case 'n':
+
			dry_run = true;
			break;
		case 'q':
			quiet = true;
			break;
-
		case 'f':
-
			all = true;
+
		case 'r':
+
			reponame = optarg;
			break;
-
		case 'L':
-
			auto_update = false;
+
		case 'y':
+
			yes = true;
			break;
		default:
			usage_upgrade();
@@ -121,13 +125,15 @@ exec_upgrade(int argc, char **argv)
	}

	pkg = NULL;
-
	if (!quiet) {
+
	if (!quiet || dry_run) {
		print_jobs_summary(jobs, PKG_JOBS_INSTALL, "The following packages will be upgraded:\n\n");

		if (!yes)
			pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
-
		if (!yes)
+
		if (!yes && !dry_run)
			yes = query_yesno("\nProceed with upgrading packages [y/N]: ");
+
		if (dry_run)
+
			yes = false;
	}

	if (yes)