Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Issue #396: Add REPO_AUTOUPDATE config variable, which sets the default for the -L option to pkg upgrade, pkg install, pkg fetch or the -U option to pkg version
Matthew Seaman committed 13 years ago
commit b542637cd2704783f8e13ca06bbc11f9dc9fa676
parent 973bb67
8 files changed +28 -4
modified libpkg/pkg.h.in
@@ -311,6 +311,7 @@ typedef enum _pkg_config_key {
	PKG_CONFIG_DEBUG_SCRIPTS,
	PKG_CONFIG_PLUGINS_CONF_DIR,
	PKG_CONFIG_PERMISSIVE,
+
	PKG_CONFIG_REPO_AUTOUPDATE,
} pkg_config_key;

typedef enum {
modified libpkg/pkg_config.c
@@ -174,6 +174,11 @@ static struct config_entry c[] = {
		"PERMISSIVE",
		"NO",
	}
+
	[PKG_CONFIG_REPO_AUTOUPDATE] = {
+
		PKG_CONFIG_BOOL,
+
		"REPO_AUTOUPDATE",
+
		"YES",
+
	}
};

static bool parsed = false;
modified pkg/fetch.c
@@ -56,10 +56,12 @@ exec_fetch(int argc, char **argv)
	int ch;
	bool force = false;
	bool yes = false;
-
	bool auto_update = true;
+
	bool auto_update;
	match_t match = MATCH_EXACT;
	pkg_flags f = PKG_FLAG_NONE;

+
	pkg_config_bool(PKG_CONFIG_REPO_AUTOUPDATE, &auto_update);
+

	while ((ch = getopt(argc, argv, "ygxr:qaLd")) != -1) {
		switch (ch) {
		case 'y':
modified pkg/install.c
@@ -59,13 +59,14 @@ exec_install(int argc, char **argv)
	int updcode = EPKG_OK;
	int ch;
	bool yes;
-
	bool auto_update = true;
+
	bool auto_update;
	match_t match = MATCH_EXACT;
	bool dry_run = false;
	nbactions = nbdone = 0;
	pkg_flags f = PKG_FLAG_NONE;

	pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
+
	pkg_config_bool(PKG_CONFIG_REPO_AUTOUPDATE, &auto_update);

	while ((ch = getopt(argc, argv, "AfgLnqRr:xy")) != -1) {
		switch (ch) {
modified pkg/pkg.conf.5
@@ -137,6 +137,16 @@ See
for more information.
.It Cm DEBUG_SCRIPTS: boolean
Activate debug mode for scripts (aka set -x)
+
.It Cm REPO_AUTOUPDATE: boolean
+
When true, automatically check for and download updates to
+
.Fa /var/db/pkg/repo.sqlite
+
when running one of:
+
.Nm pkg upgrade ,
+
.Nm pkg fetch ,
+
.Nm pkg install
+
or
+
.Nm pkg version -R .
+
(default: YES)
.El
.Sh ENVIRONMENT
An environment variable with the same name as the option in the configuration
modified pkg/pkg.conf.sample
@@ -18,6 +18,7 @@ PACKAGESITE : http://pkg.freebsd.org/${ABI}/latest
#PKG_PLUGINS_DIR    : /usr/local/lib/pkg/plugins
#PKG_ENABLE_PLUGINS : YES
#PLUGINS	    : [commands/mystat]
+
#REPO_AUTOUPDATE    : YES

# Repository definitions
#repos:
modified pkg/upgrade.c
@@ -52,11 +52,13 @@ exec_upgrade(int argc, char **argv)
	int ch;
	bool yes;
	bool dry_run = false;
-
	bool auto_update = true;
+
	bool auto_update;
	nbactions = nbdone = 0;
	pkg_flags f = PKG_FLAG_NONE;

	pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
+
	pkg_config_bool(PKG_CONFIG_REPO_AUTOUPDATE, &auto_update);
+


	while ((ch = getopt(argc, argv, "fLnqr:y")) != -1) {
		switch (ch) {
modified pkg/version.c
@@ -164,7 +164,7 @@ exec_version(int argc, char **argv)
	const char *reponame = NULL;
	const char *version_remote = NULL;
	bool have_ports;
-
	bool auto_update = true;
+
	bool auto_update;
	match_t match = MATCH_ALL;
	char *pattern=NULL;
	struct stat sb;
@@ -172,6 +172,8 @@ exec_version(int argc, char **argv)

	SLIST_INIT(&indexhead);

+
	pkg_config_bool(PKG_CONFIG_REPO_AUTOUPDATE, &auto_update);
+

	while ((ch = getopt(argc, argv, "hIPRUoqvl:L:x:g:e:O:r:tT")) != -1) {
		switch (ch) {
		case 'h':