mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 07:48:50 -05:00
Bring back db_scan() modifications from pacman 2.9.1
(to cope with .lastupdate files in the db path)
This commit is contained in:
parent
e1eff42fe1
commit
ad4ab9e50c
@ -141,6 +141,8 @@ void db_rewind(pmdb_t *db)
|
|||||||
pmpkg_t *db_scan(pmdb_t *db, char *target, unsigned int inforeq)
|
pmpkg_t *db_scan(pmdb_t *db, char *target, unsigned int inforeq)
|
||||||
{
|
{
|
||||||
struct dirent *ent = NULL;
|
struct dirent *ent = NULL;
|
||||||
|
struct stat sbuf;
|
||||||
|
char path[PATH_MAX];
|
||||||
char name[256];
|
char name[256];
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
int ret, found = 0;
|
int ret, found = 0;
|
||||||
@ -158,6 +160,11 @@ pmpkg_t *db_scan(pmdb_t *db, char *target, unsigned int inforeq)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
strncpy(name, ent->d_name, 255);
|
strncpy(name, ent->d_name, 255);
|
||||||
|
/* stat the entry, make sure it's a directory */
|
||||||
|
snprintf(path, PATH_MAX, "%s/%s", db->path, name);
|
||||||
|
if(stat(path, &sbuf) || !S_ISDIR(sbuf.st_mode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
/* truncate the string at the second-to-last hyphen, */
|
/* truncate the string at the second-to-last hyphen, */
|
||||||
/* which will give us the package name */
|
/* which will give us the package name */
|
||||||
if((ptr = rindex(name, '-'))) {
|
if((ptr = rindex(name, '-'))) {
|
||||||
@ -175,20 +182,20 @@ pmpkg_t *db_scan(pmdb_t *db, char *target, unsigned int inforeq)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* normal iteration */
|
/* normal iteration */
|
||||||
ent = readdir(db->dir);
|
int isdir = 0;
|
||||||
if(ent == NULL) {
|
while(!isdir) {
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
if(!strcmp(ent->d_name, ".")) {
|
|
||||||
ent = readdir(db->dir);
|
ent = readdir(db->dir);
|
||||||
if(ent == NULL) {
|
if(ent == NULL) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
/* stat the entry, make sure it's a directory */
|
||||||
if(!strcmp(ent->d_name, "..")) {
|
snprintf(path, PATH_MAX, "%s/%s", db->path, ent->d_name);
|
||||||
ent = readdir(db->dir);
|
if(!stat(path, &sbuf) && S_ISDIR(sbuf.st_mode)) {
|
||||||
if(ent == NULL) {
|
isdir = 1;
|
||||||
return(NULL);
|
}
|
||||||
|
if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
|
||||||
|
isdir = 0;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -669,7 +676,7 @@ PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root)
|
|||||||
}
|
}
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
MALLOC(str, 512);
|
MALLOC(str, 512);
|
||||||
snprintf(str, 512, "%s: exists in filesystem", path);
|
snprintf(str, 512, "%s: %s: exists in filesystem", p->name, path);
|
||||||
conflicts = pm_list_add(conflicts, str);
|
conflicts = pm_list_add(conflicts, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user