1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

Fixed pacman -U:

* Accidental database read of a file-based package (whoops)
    * Proper fetching of url-based -U or -A
Removed some newlines from _alpm_log calls, to make debug output more concise
This commit is contained in:
Aaron Griffin 2006-11-01 06:30:47 +00:00
parent 48ee3c4434
commit 3bf918dc4e
7 changed files with 64 additions and 46 deletions

View File

@ -327,7 +327,7 @@ int alpm_db_update(int force, PM_DB *db)
/* get the lastupdate time */
_alpm_db_getlastupdate(db, lastupdate);
if(strlen(lastupdate) == 0) {
_alpm_log(PM_LOG_DEBUG, _("failed to get lastupdate time for %s (no big deal)\n"), db->treename);
_alpm_log(PM_LOG_DEBUG, _("failed to get lastupdate time for %s (no big deal)"), db->treename);
}
}
@ -346,11 +346,11 @@ int alpm_db_update(int force, PM_DB *db)
} else if(ret == -1) {
/* we use fetchLastErrString and fetchLastErrCode here, error returns from
* libfetch */
_alpm_log(PM_LOG_DEBUG, _("failed to sync db: %s [%d]\n"), fetchLastErrString, fetchLastErrCode);
_alpm_log(PM_LOG_DEBUG, _("failed to sync db: %s [%d]"), fetchLastErrString, fetchLastErrCode);
RET_ERR(PM_ERR_DB_SYNC, -1);
} else {
if(strlen(newmtime)) {
_alpm_log(PM_LOG_DEBUG, _("sync: new mtime for %s: %s\n"), db->treename, newmtime);
_alpm_log(PM_LOG_DEBUG, _("sync: new mtime for %s: %s"), db->treename, newmtime);
_alpm_db_setlastupdate(db, newmtime);
}
snprintf(path, PATH_MAX, "%s%s/%s" PM_EXT_DB, handle->root, handle->dbpath, db->treename);
@ -619,7 +619,7 @@ int alpm_pkg_checksha1sum(pmpkg_t *pkg)
sha1sum = _alpm_SHAFile(path);
if(sha1sum == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not get sha1 checksum for package %s-%s\n"),
_alpm_log(PM_LOG_ERROR, _("could not get sha1 checksum for package %s-%s"),
pkg->name, pkg->version);
pm_errno = PM_ERR_NOT_A_FILE;
retval = -1;
@ -633,7 +633,7 @@ int alpm_pkg_checksha1sum(pmpkg_t *pkg)
_alpm_log(PM_LOG_FLOW1, _("checksums for package %s-%s are matching"),
pkg->name, pkg->version);
} else {
_alpm_log(PM_LOG_ERROR, _("sha1sums do not match for package %s-%s\n"),
_alpm_log(PM_LOG_ERROR, _("sha1sums do not match for package %s-%s"),
pkg->name, pkg->version);
pm_errno = PM_ERR_PKG_INVALID;
retval = -1;
@ -666,7 +666,7 @@ int alpm_pkg_checkmd5sum(pmpkg_t *pkg)
md5sum = _alpm_MDFile(path);
if(md5sum == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not get md5 checksum for package %s-%s\n"),
_alpm_log(PM_LOG_ERROR, _("could not get md5 checksum for package %s-%s"),
pkg->name, pkg->version);
pm_errno = PM_ERR_NOT_A_FILE;
retval = -1;
@ -680,7 +680,7 @@ int alpm_pkg_checkmd5sum(pmpkg_t *pkg)
_alpm_log(PM_LOG_FLOW1, _("checksums for package %s-%s are matching"),
pkg->name, pkg->version);
} else {
_alpm_log(PM_LOG_ERROR, _("md5sums do not match for package %s-%s\n"),
_alpm_log(PM_LOG_ERROR, _("md5sums do not match for package %s-%s"),
pkg->name, pkg->version);
pm_errno = PM_ERR_PKG_INVALID;
retval = -1;
@ -1200,7 +1200,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
ptr++;
strncpy(section, ptr, min(255, strlen(ptr)-1));
section[min(255, strlen(ptr)-1)] = '\0';
_alpm_log(PM_LOG_DEBUG, _("config: new section '%s'\n"), section);
_alpm_log(PM_LOG_DEBUG, _("config: new section '%s'"), section);
if(!strlen(section)) {
RET_ERR(PM_ERR_CONF_BAD_SECTION, -1);
}
@ -1231,7 +1231,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
alpm_set_option(PM_OPT_NOPASSIVEFTP, (long)1);
} else if(!strcmp(key, "USESYSLOG")) {
alpm_set_option(PM_OPT_USESYSLOG, (long)1);
_alpm_log(PM_LOG_DEBUG, _("config: usesyslog\n"));
_alpm_log(PM_LOG_DEBUG, _("config: usesyslog"));
} else if(!strcmp(key, "ILOVECANDY")) {
alpm_set_option(PM_OPT_CHOMP, (long)1);
} else {
@ -1242,7 +1242,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
if(!strcmp(key, "INCLUDE")) {
char conf[PATH_MAX];
strncpy(conf, ptr, PATH_MAX);
_alpm_log(PM_LOG_DEBUG, _("config: including %s\n"), conf);
_alpm_log(PM_LOG_DEBUG, _("config: including %s"), conf);
alpm_parse_config(conf, callback, section);
} else if(!strcmp(section, "options")) {
if(!strcmp(key, "NOUPGRADE")) {
@ -1254,7 +1254,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: noupgrade: %s\n"), p);
_alpm_log(PM_LOG_DEBUG, _("config: noupgrade: %s"), p);
p = q;
p++;
}
@ -1262,7 +1262,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: noupgrade: %s\n"), p);
_alpm_log(PM_LOG_DEBUG, _("config: noupgrade: %s"), p);
} else if(!strcmp(key, "NOEXTRACT")) {
char *p = ptr;
char *q;
@ -1272,7 +1272,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: noextract: %s\n"), p);
_alpm_log(PM_LOG_DEBUG, _("config: noextract: %s"), p);
p = q;
p++;
}
@ -1280,7 +1280,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: noextract: %s\n"), p);
_alpm_log(PM_LOG_DEBUG, _("config: noextract: %s"), p);
} else if(!strcmp(key, "IGNOREPKG")) {
char *p = ptr;
char *q;
@ -1290,7 +1290,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: ignorepkg: %s\n"), p);
_alpm_log(PM_LOG_DEBUG, _("config: ignorepkg: %s"), p);
p = q;
p++;
}
@ -1298,7 +1298,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: ignorepkg: %s\n"), p);
_alpm_log(PM_LOG_DEBUG, _("config: ignorepkg: %s"), p);
} else if(!strcmp(key, "HOLDPKG")) {
char *p = ptr;
char *q;
@ -1308,7 +1308,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: holdpkg: %s\n"), p);
_alpm_log(PM_LOG_DEBUG, _("config: holdpkg: %s"), p);
p = q;
p++;
}
@ -1316,7 +1316,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: holdpkg: %s\n"), p);
_alpm_log(PM_LOG_DEBUG, _("config: holdpkg: %s"), p);
} else if(!strcmp(key, "DBPATH")) {
/* shave off the leading slash, if there is one */
if(*ptr == '/') {
@ -1326,7 +1326,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: dbpath: %s\n"), ptr);
_alpm_log(PM_LOG_DEBUG, _("config: dbpath: %s"), ptr);
} else if(!strcmp(key, "CACHEDIR")) {
/* shave off the leading slash, if there is one */
if(*ptr == '/') {
@ -1336,13 +1336,13 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: cachedir: %s\n"), ptr);
_alpm_log(PM_LOG_DEBUG, _("config: cachedir: %s"), ptr);
} else if (!strcmp(key, "LOGFILE")) {
if(alpm_set_option(PM_OPT_LOGFILE, (long)ptr) == -1) {
/* pm_errno is set by alpm_set_option */
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("config: log file: %s\n"), ptr);
_alpm_log(PM_LOG_DEBUG, _("config: log file: %s"), ptr);
} else if (!strcmp(key, "XFERCOMMAND")) {
if(alpm_set_option(PM_OPT_XFERCOMMAND, (long)ptr) == -1) {
/* pm_errno is set by alpm_set_option */
@ -1350,7 +1350,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
}
} else if (!strcmp(key, "UPGRADEDELAY")) {
/* The config value is in days, we use seconds */
_alpm_log(PM_LOG_DEBUG, _("config: UpgradeDelay: %i\n"), (60*60*24) * atol(ptr));
_alpm_log(PM_LOG_DEBUG, _("config: UpgradeDelay: %i"), (60*60*24) * atol(ptr));
if(alpm_set_option(PM_OPT_UPGRADEDELAY, (60*60*24) * atol(ptr)) == -1) {
/* pm_errno is set by alpm_set_option */
return(-1);

View File

@ -72,6 +72,7 @@ int alpm_release(void);
#define PM_LOG_FLOW1 0x08
#define PM_LOG_FLOW2 0x10
#define PM_LOG_FUNCTION 0x20
#define PM_LOG_FETCH 0x40
int alpm_logaction(char *fmt, ...);

View File

@ -193,6 +193,13 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
return(-1);
}
if(info->origin == PKG_FROM_FILE) {
_alpm_log(PM_LOG_DEBUG, _("request to read database info for a file-based package '%s', skipping..."), info->name);
return(-1);
}
_alpm_log(PM_LOG_FUNCTION, _("loading package data for %s : level=%d"), info->name, inforeq);
snprintf(path, PATH_MAX, "%s/%s-%s", db->path, info->name, info->version);
if(stat(path, &buf)) {
/* directory doesn't exist or can't be opened */

View File

@ -60,7 +60,7 @@ int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel)
while((info = _alpm_db_scan(db, NULL, infolevel)) != NULL) {
info->origin = PKG_FROM_CACHE;
info->data = db;
/* add to the collective */
/* add to the collection */
db->pkgcache = _alpm_list_add_sorted(db->pkgcache, info, _alpm_pkg_cmp);
}

View File

@ -107,7 +107,7 @@ pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles)
continue;
}
targ = strdup(i->data);
_alpm_log(PM_LOG_DEBUG, "searching for target '%s'\n", targ);
_alpm_log(PM_LOG_DEBUG, "searching for target '%s'", targ);
for(j = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS); j; j = j->next) {
pmpkg_t *pkg = j->data;
@ -176,7 +176,7 @@ pmdb_t *_alpm_db_register(char *treename, alpm_cb_db_register callback)
if(strcmp(treename, "local") == 0) {
if(handle->db_local != NULL) {
_alpm_log(PM_LOG_WARNING, _("attempt to re-register the 'local' DB\n"));
_alpm_log(PM_LOG_WARNING, _("attempt to re-register the 'local' DB"));
RET_ERR(PM_ERR_DB_NOT_NULL, NULL);
}
} else {
@ -184,7 +184,7 @@ pmdb_t *_alpm_db_register(char *treename, alpm_cb_db_register callback)
for(i = handle->dbs_sync; i; i = i->next) {
pmdb_t *sdb = i->data;
if(strcmp(treename, sdb->treename) == 0) {
_alpm_log(PM_LOG_DEBUG, _("attempt to re-register the '%s' databse, using existing\n"), sdb->treename);
_alpm_log(PM_LOG_DEBUG, _("attempt to re-register the '%s' databse, using existing"), sdb->treename);
return sdb;
}
}

View File

@ -150,7 +150,7 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
int chk_resume = 0;
if(stat(output, &st) == 0 && st.st_size > 0) {
_alpm_log(PM_LOG_DEBUG, _("existing file found, using it\n"));
_alpm_log(PM_LOG_DEBUG, _("existing file found, using it"));
server->s_url->offset = (off_t)st.st_size;
dltotal_bytes = st.st_size;
localf = fopen(output, "a");
@ -172,14 +172,16 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
fetchTimeout = 10000;
/* Make libfetch super verbose... worthwhile for testing */
if(pm_logmask & PM_LOG_DEBUG) {
if(pm_logmask & PM_LOG_FETCH) {
fetchDebug = 1;
}
if(pm_logmask & PM_LOG_DEBUG) {
dlf = fetchXGet(server->s_url, &ust, (handle->nopassiveftp ? "v" : "vp"));
} else {
dlf = fetchXGet(server->s_url, &ust, (handle->nopassiveftp ? "" : "p"));
}
if(fetchLastErrCode != 0 || dlf == NULL) {
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from '%s://%s%s', %d : %s\n"), fn,
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from '%s://%s%s', %d : %s"), fn,
server->s_url->scheme, server->s_url->host, server->s_url->doc, fetchLastErrCode,
fetchLastErrString);
if(localf != NULL) {
@ -195,7 +197,7 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
char strtime[15];
_alpm_time2string(ust.mtime, strtime);
if(strcmp(mtime1, strtime) == 0) {
_alpm_log(PM_LOG_DEBUG, _("mtimes are identical, skipping %s\n"), fn);
_alpm_log(PM_LOG_DEBUG, _("mtimes are identical, skipping %s"), fn);
complete = _alpm_list_add(complete, fn);
if(localf != NULL) {
fclose(localf);
@ -280,18 +282,18 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
/* cwd to the download directory */
getcwd(cwd, PATH_MAX);
if(chdir(localpath)) {
_alpm_log(PM_LOG_WARNING, _("could not chdir to %s\n"), localpath);
_alpm_log(PM_LOG_WARNING, _("could not chdir to %s"), localpath);
return(PM_ERR_CONNECT_FAILED);
}
/* execute the parsed command via /bin/sh -c */
_alpm_log(PM_LOG_DEBUG, _("running command: %s\n"), parsedCmd);
_alpm_log(PM_LOG_DEBUG, _("running command: %s"), parsedCmd);
ret = system(parsedCmd);
if(ret == -1) {
_alpm_log(PM_LOG_WARNING, _("running XferCommand: fork failed!\n"));
_alpm_log(PM_LOG_WARNING, _("running XferCommand: fork failed!"));
return(PM_ERR_FORK_FAILED);
} else if(ret != 0) {
/* download failed */
_alpm_log(PM_LOG_DEBUG, _("XferCommand command returned non-zero status code (%d)\n"), ret);
_alpm_log(PM_LOG_DEBUG, _("XferCommand command returned non-zero status code (%d)"), ret);
} else {
/* download was successful */
complete = _alpm_list_add(complete, fn);
@ -316,6 +318,7 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
char *_alpm_fetch_pkgurl(char *target)
{
char *p = NULL;
struct stat st;
struct url *s_url;
@ -336,7 +339,7 @@ char *_alpm_fetch_pkgurl(char *target)
/* do not download the file if it exists in the current dir */
if(stat(s_url->doc, &st) == 0) {
_alpm_log(PM_LOG_DEBUG, _(" %s is already in the current directory\n"), s_url->doc);
_alpm_log(PM_LOG_DEBUG, _(" %s is already in the current directory"), s_url->doc);
} else {
pmserver_t *server;
pmlist_t *servers = NULL;
@ -346,21 +349,28 @@ char *_alpm_fetch_pkgurl(char *target)
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmserver_t));
return(NULL);
}
server->s_url = s_url;
server->path = strdup(s_url->doc);
servers = _alpm_list_add(servers, server);
if(s_url->doc && (p = strrchr(s_url->doc,'/'))) {
*p++ = '\0';
_alpm_log(PM_LOG_DEBUG, _("fetching '%s' from '%s://%s%s"), p, s_url->scheme, s_url->host, s_url->doc);
files = _alpm_list_add(NULL, s_url->doc);
if(_alpm_downloadfiles(servers, ".", files)) {
_alpm_log(PM_LOG_WARNING, _("failed to download %s\n"), target);
return(NULL);
server->s_url = s_url;
server->path = strdup(s_url->doc);
servers = _alpm_list_add(servers, server);
files = _alpm_list_add(NULL, strdup(p));
if(_alpm_downloadfiles(servers, ".", files)) {
_alpm_log(PM_LOG_WARNING, _("failed to download %s"), target);
return(NULL);
}
FREELISTPTR(files);
FREELIST(servers);
}
FREELISTPTR(files);
FREELIST(servers);
}
fetchFreeURL(s_url);
/* return the target with the raw filename, no URL */
return(strdup(s_url->doc));
return(p ? strdup(p) : NULL);
}
/* vim: set ts=2 sw=2 noet: */

View File

@ -225,7 +225,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync
local->name, local->version, spkg->version);
} else if(istoonew(spkg)) {
/* package too new (UpgradeDelay) */
_alpm_log(PM_LOG_FLOW1, _("%s-%s: delaying upgrade of package (%s)\n"),
_alpm_log(PM_LOG_FLOW1, _("%s-%s: delaying upgrade of package (%s)"),
local->name, local->version, spkg->version);
/* check if spkg->name is already in the packages list. */
} else {