From ad87360a71927f2afb3f91f13005b3c477f82acf Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Wed, 4 Aug 2004 06:49:31 +0000 Subject: Imported from pacman-2.8.3.tar.gz --- src/db.c | 91 +++++------------------------------------------------------- src/pacman.c | 73 +++++++++++++++++++++++++++++++----------------- src/pacman.h | 4 +-- 3 files changed, 56 insertions(+), 112 deletions(-) (limited to 'src') diff --git a/src/db.c b/src/db.c index 0442eb55..0d177e6a 100644 --- a/src/db.c +++ b/src/db.c @@ -540,9 +540,8 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root) char *filestr = NULL; char path[PATH_MAX+1]; char *str = NULL; - struct stat buf; + struct stat buf, buf2; PMList *conflicts = NULL; - char *sym = NULL, *symw = NULL, *symlink = NULL, *tempsym = NULL; /* CHECK 1: check every db package against every target package */ /* XXX: I've disabled the database-against-targets check for now, as the @@ -623,88 +622,15 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root) */ /* Check if any part of the conflicting file's path is a symlink */ if(dbpkg && !ok) { - if(!sym) MALLOC(sym, PATH_MAX); - if(!symlink) MALLOC(symlink, PATH_MAX); - if(!tempsym) MALLOC(tempsym, PATH_MAX); - - strncpy(sym, path, PATH_MAX); - symw = sym; - do { - /* Is it a symlink? */ - if(!lstat(sym, &buf) && S_ISLNK(buf.st_mode)) { - memset(symlink, 0, PATH_MAX); - readlink(sym, symlink, PATH_MAX); - if(symlink[0] != '/') { - char *temp = strdup(sym); - strncpy(tempsym, symlink, PATH_MAX); - snprintf(symlink, PATH_MAX, "%s/%s", dirname(temp), tempsym); - FREE(temp); - } - /* If it's a directory, tack on a '/' */ - if(!stat(symlink, &buf) && S_ISDIR(buf.st_mode)) { - strcat(symlink, "/"); - } - if(strstr(symlink, root) == symlink) { - strncpy(tempsym, symlink+strlen(root), PATH_MAX-strlen(root)); - /* If that part of the path used to exist in the package */ - if(is_in(tempsym, dbpkg->files)) { - /* See if the modified path used to */ - snprintf(tempsym, PATH_MAX, "%s%s", symlink+strlen(root), path+strlen(sym)+strlen(root)); - if(is_in(tempsym, dbpkg->files)) { - ok = 1; - break; - } - } - strncpy(tempsym, symlink, PATH_MAX); - snprintf(symlink, PATH_MAX, "%s/", tempsym); - strncpy(tempsym, symlink+strlen(root), PATH_MAX-strlen(root)); - /* If that part of the path (explicitly check for directory) used to exist in the package */ - if(is_in(tempsym, dbpkg->files)) { - /* See if the modified path used to */ - snprintf(tempsym, PATH_MAX, "%s%s", symlink+strlen(root), path+strlen(sym)+strlen(root)); - if(is_in(tempsym, dbpkg->files)) { - ok = 1; - break; - } - } - } - } - symw = dirname(sym); - strncpy(sym, symw, PATH_MAX); - } while (strncmp(sym, root, PATH_MAX)); - } - if(dbpkg && !ok) { - if(!sym) MALLOC(sym, PATH_MAX); - if(!symlink) MALLOC(symlink, PATH_MAX); - if(!tempsym) MALLOC(tempsym, PATH_MAX); + MALLOC(str, PATH_MAX); for(k = dbpkg->files; k; k = k->next) { - snprintf(sym, PATH_MAX, "%s%s", root, (char *)k->data); - /* If the last part of the path is '/' then toss it */ - if(rindex(sym, '/') == sym+strlen(sym)-1) { - sym[strlen(sym)-1] = '\0'; - } - - /* Is that a symlink? */ - if(!lstat(sym, &buf) && S_ISLNK(buf.st_mode)) { - memset(symlink, 0, PATH_MAX); - readlink(sym, symlink, PATH_MAX); - /* It's not an absolute symlink, make it one */ - if(symlink[0] != '/') { - strncpy(tempsym, symlink, PATH_MAX); - snprintf(symlink, PATH_MAX, "%s/%s", dirname(sym), tempsym); - } - /* Does the symlink point to a part of the conflicting path? */ - if(strstr(path, symlink) == path) - { - /* Replace one with the other and check if it really did exist in the old package */ - snprintf(tempsym, PATH_MAX, "%s%s", symlink, path+strlen(symlink)); - if(!strncmp(tempsym, path, PATH_MAX)) { - ok = 1; - break; - } - } + snprintf(str, PATH_MAX, "%s%s", root, (char*)k->data); + stat(str, &buf2); + if(buf.st_ino == buf2.st_ino) { + ok = 1; } } + FREE(str); } /* Check if the conflicting file has been moved to another package/target */ if(!ok) { @@ -733,9 +659,6 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root) FREEPKG(dbpkg); } - if(sym) FREE(sym); - if(symlink) FREE(symlink); - if(tempsym) FREE(tempsym); return(conflicts); } diff --git a/src/pacman.c b/src/pacman.c index c8f46fcd..4d06dd32 100644 --- a/src/pacman.c +++ b/src/pacman.c @@ -83,6 +83,7 @@ unsigned short pmo_s_clean = 0; unsigned short pmo_group = 0; /* configuration file options */ char *pmo_dbpath = NULL; +char *pmo_configfile = NULL; char *pmo_logfile = NULL; char *pmo_proxyhost = NULL; unsigned short pmo_proxyport = 0; @@ -112,7 +113,6 @@ int main(int argc, char *argv[]) { int ret = 0; char *ptr = NULL; - char path[PATH_MAX]; pacdb_t *db_local = NULL; char *cenv = NULL; @@ -132,6 +132,9 @@ int main(int argc, char *argv[]) /* default dbpath */ MALLOC(pmo_dbpath, PATH_MAX); strcpy(pmo_dbpath, PKGDIR); + /* default configuration file */ + MALLOC(pmo_configfile, PATH_MAX); + strcpy(pmo_configfile, PACCONF); /* parse the command line */ ret = parseargs(PM_ADD, argc, argv); @@ -168,8 +171,7 @@ int main(int argc, char *argv[]) signal(SIGTERM, cleanup); /* parse the system-wide config file */ - snprintf(path, PATH_MAX, "/%s", PACCONF); - if(parseconfig(path)) { + if(parseconfig(pmo_configfile)) { cleanup(1); } @@ -2709,7 +2711,6 @@ int resolvedeps(pacdb_t *local, PMList *databases, syncpkg_t *syncpkg, PMList *l /* find the package in one of the repositories */ for(j = databases; !found && j; j = j->next) { - PMList *provides; dbsync_t *dbs = (dbsync_t*)j->data; /* check literals */ for(k = dbs->pkgcache; !found && k; k = k->next) { @@ -2721,17 +2722,19 @@ int resolvedeps(pacdb_t *local, PMList *databases, syncpkg_t *syncpkg, PMList *l sync->dbs = dbs; } } + } + for(j = databases; !found && j; j = j->next) { + PMList *provides; + dbsync_t *dbs = (dbsync_t*)j->data; /* check provides */ - if(!found) { - provides = whatprovides(dbs->db, miss->depend.name); - if(provides) { - found = 1; - /* re-fetch the package record with dependency info */ - sync->pkg = db_scan(dbs->db, provides->data, INFRQ_DESC | INFRQ_DEPENDS); - sync->dbs = dbs; - } - list_free(provides); + provides = whatprovides(dbs->db, miss->depend.name); + if(provides) { + found = 1; + /* re-fetch the package record with dependency info */ + sync->pkg = db_scan(dbs->db, provides->data, INFRQ_DESC | INFRQ_DEPENDS); + sync->dbs = dbs; } + list_free(provides); } if(!found) { fprintf(stderr, "error: cannot resolve dependencies for \"%s\":\n", miss->target); @@ -3257,7 +3260,8 @@ int parseargs(int op, int argc, char **argv) {"cascade", no_argument, 0, 'c'}, {"recursive", no_argument, 0, 's'}, {"groups", no_argument, 0, 'g'}, - {"noconfirm", no_argument, 0, 999}, + {"noconfirm", no_argument, 0, 1000}, + {"config", required_argument, 0, 1001}, {0, 0, 0, 0} }; @@ -3267,7 +3271,8 @@ int parseargs(int op, int argc, char **argv) } switch(opt) { case 0: break; - case 999: pmo_noconfirm = 1; break; + case 1000: pmo_noconfirm = 1; break; + case 1001: strcpy(pmo_configfile, optarg); break; case 'A': pmo_op = (pmo_op != PM_MAIN ? 0 : PM_ADD); break; case 'R': pmo_op = (pmo_op != PM_MAIN ? 0 : PM_REMOVE); break; case 'U': pmo_op = (pmo_op != PM_MAIN ? 0 : PM_UPGRADE); break; @@ -3362,23 +3367,29 @@ int parseconfig(char *configfile) return(1); } if(!strcmp(section, "local")) { - fprintf(stderr, "config: line %d: %s is reserved and cannot be used as a package tree\n", + fprintf(stderr, "config: line %d: '%s' is reserved and cannot be used as a package tree\n", linenum, section); return(1); } if(strcmp(section, "options")) { - /* start a new sync record */ - MALLOC(sync, sizeof(sync_t)); - sync->treename = strdup(section); - sync->servers = NULL; - pmc_syncs = list_add(pmc_syncs, sync); + PMList *i; + int found = 0; + for(i = pmc_syncs; i && !found; i = i->next) { + sync = (sync_t*)i->data; + if(!strcmp(sync->treename, section)) { + found = 1; + } + } + if(!found) { + /* start a new sync record */ + MALLOC(sync, sizeof(sync_t)); + sync->treename = strdup(section); + sync->servers = NULL; + pmc_syncs = list_add(pmc_syncs, sync); + } } } else { /* directive */ - if(!strlen(section)) { - fprintf(stderr, "config: line %d: all directives must belong to a section\n", linenum); - return(1); - } ptr = line; key = strsep(&ptr, "="); if(key == NULL) { @@ -3387,6 +3398,10 @@ int parseconfig(char *configfile) } trim(key); key = strtoupper(key); + if(!strlen(section) && strcmp(key, "INCLUDE")) { + fprintf(stderr, "config: line %d: all directives must belong to a section\n", linenum); + return(1); + } if(ptr == NULL) { if(!strcmp(key, "NOPASSIVEFTP")) { pmo_nopassiveftp = 1; @@ -3400,7 +3415,12 @@ int parseconfig(char *configfile) } } else { trim(ptr); - if(!strcmp(section, "options")) { + if(!strcmp(key, "INCLUDE")) { + char conf[PATH_MAX]; + strncpy(conf, ptr, PATH_MAX); + vprint("config: including %s\n", conf); + parseconfig(conf); + } else if(!strcmp(section, "options")) { if(!strcmp(key, "NOUPGRADE")) { char *p = ptr; char *q; @@ -3610,6 +3630,7 @@ void usage(int op, char *myname) printf(" -w, --downloadonly download packages but do not install/upgrade anything\n"); printf(" -y, --refresh download fresh package databases from the server\n"); } + printf(" --config set an alternate configuration file\n"); printf(" --noconfirm do not ask for any confirmation\n"); printf(" -v, --verbose be verbose\n"); printf(" -r, --root set an alternate installation root\n"); diff --git a/src/pacman.h b/src/pacman.h index 2c8ddd09..157cb623 100644 --- a/src/pacman.h +++ b/src/pacman.h @@ -22,7 +22,7 @@ #define _PAC_PACMAN_H #ifndef PACVER -#define PACVER "2.8.2" +#define PACVER "2.8.3" #endif #ifndef PKGDIR @@ -30,7 +30,7 @@ #endif #ifndef PACCONF -#define PACCONF "etc/pacman.conf" +#define PACCONF "/etc/pacman.conf" #endif #ifndef CACHEDIR -- cgit v1.2.3-24-g4f1b