[Frugalware-darcs] pacman-g2: add warning when local db is old

VMiklos vmiklos at frugalware.org
Sun Jul 22 16:42:00 CEST 2007


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=pacman-g2;a=darcs_commitdiff;h=20070722143608-e2957-3f66059640449570b11db6b608d69e362aa47432.gz;

[add warning when local db is old
VMiklos <vmiklos at frugalware.org>**20070722143608
 closes #448
] {
hunk ./doc/pacman-g2.8 308
+.TP
+.B "OldDelay = <number>"
+Issue a warning when you install a package, but the local sync database (which
+can be upgraded using \fB-Sy\fP) haven't been updated for <number> days.
hunk ./etc/pacman.conf.in 13
+# Issue a warning before install when you haven't done a -Sy for X days
+OldDelay    = 3
hunk ./lib/libpacman/handle.c 265
+		case PM_OPT_OLDDELAY:
+			handle->olddelay = data;
+		break;
hunk ./lib/libpacman/handle.c 346
+		case PM_OPT_OLDDELAY:  *data = (long)handle->olddelay; break;
hunk ./lib/libpacman/handle.h 53
+	time_t olddelay;
hunk ./lib/libpacman/pacman.c 1313
+						}
+					} else if (!strcmp(key, "OLDDELAY")) {
+						/* The config value is in days, we use seconds */
+						_pacman_log(PM_LOG_DEBUG, _("config: OldDelay: %i\n"), (60*60*24) * atol(ptr));
+						if(pacman_set_option(PM_OPT_OLDDELAY, (60*60*24) * atol(ptr)) == -1) {
+							/* pm_errno is set by pacman_set_option */
+							return(-1);
hunk ./lib/libpacman/pacman.h 119
-	PM_OPT_MAXTRIES
+	PM_OPT_MAXTRIES,
+	PM_OPT_OLDDELAY
hunk ./lib/libpacman/sync.c 376
+static int check_olddelay()
+{
+	pmlist_t *i;
+	char lastupdate[16] = "";
+	struct tm tm;
+
+	if(!handle->olddelay) {
+		return(0);
+	}
+
+	for(i = handle->dbs_sync; i; i= i->next) {
+		pmdb_t *db = i->data;
+		if(_pacman_db_getlastupdate(db, lastupdate) == -1) {
+			continue;
+		}
+		if(strptime(lastupdate, "%Y%m%d%H%M%S", &tm) == NULL) {
+			continue;
+		}
+		if((time(NULL)-mktime(&tm)) > handle->olddelay) {
+			_pacman_log(PM_LOG_WARNING, _("local copy of '%s' repo is too old"), db->treename);
+		}
+	}
+	return(0);
+}
+
hunk ./lib/libpacman/sync.c 775
+	/* issue warning if the local db is too old */
+	check_olddelay();
+
}


More information about the Frugalware-darcs mailing list