summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2010-10-30 15:35:43 +1000
committerDan McGee <dan@archlinux.org>2010-12-12 21:42:41 -0600
commit21833d90e26635fdd2c6af247790a9bf374b4d80 (patch)
tree3f386dc01e2016c2c9c7003ec2590d4931769259
parent209d0643e5fd38f8add70cfb3651012993d861f1 (diff)
downloadpacman-21833d90e26635fdd2c6af247790a9bf374b4d80.tar.xz
Merge desc and depends files in local db
Whenever depends is needed from the local db, so is desc. The only disadvantage to merging them is the additional time taken to read the depends entries when they are not needed. As depends is in general relatively small, the additional time taken to read it in will be negligable. Also, merging these files will speed up local database access due to less file seeks. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/be_local.c144
-rw-r--r--lib/libalpm/be_package.c2
-rw-r--r--lib/libalpm/db.h9
3 files changed, 61 insertions, 94 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 988248d8..9dce66df 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -165,25 +165,25 @@ int _cache_get_epoch(pmpkg_t *pkg)
alpm_list_t *_cache_get_depends(pmpkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DEPENDS, NULL);
+ LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->depends;
}
alpm_list_t *_cache_get_optdepends(pmpkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DEPENDS, NULL);
+ LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->optdepends;
}
alpm_list_t *_cache_get_conflicts(pmpkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DEPENDS, NULL);
+ LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->conflicts;
}
alpm_list_t *_cache_get_provides(pmpkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DEPENDS, NULL);
+ LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->provides;
}
@@ -614,32 +614,28 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
if(!info->epoch) {
info->epoch = 1;
}
- }
- }
- fclose(fp);
- fp = NULL;
- }
-
- /* FILES */
- if(inforeq & INFRQ_FILES) {
- snprintf(path, PATH_MAX, "%sfiles", pkgpath);
- if((fp = fopen(path, "r")) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
- goto error;
- }
- while(fgets(line, sizeof(line), fp)) {
- _alpm_strtrim(line);
- if(strcmp(line, "%FILES%") == 0) {
+ } else if(strcmp(line, "%DEPENDS%") == 0) {
+ while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
+ pmdepend_t *dep = _alpm_splitdep(_alpm_strtrim(line));
+ info->depends = alpm_list_add(info->depends, dep);
+ }
+ } else if(strcmp(line, "%OPTDEPENDS%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
STRDUP(linedup, _alpm_strtrim(line), goto error);
- info->files = alpm_list_add(info->files, linedup);
+ info->optdepends = alpm_list_add(info->optdepends, linedup);
}
- } else if(strcmp(line, "%BACKUP%") == 0) {
+ } else if(strcmp(line, "%CONFLICTS%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
STRDUP(linedup, _alpm_strtrim(line), goto error);
- info->backup = alpm_list_add(info->backup, linedup);
+ info->conflicts = alpm_list_add(info->conflicts, linedup);
+ }
+ } else if(strcmp(line, "%PROVIDES%") == 0) {
+ while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
+ char *linedup;
+ STRDUP(linedup, _alpm_strtrim(line), goto error);
+ info->provides = alpm_list_add(info->provides, linedup);
}
}
}
@@ -647,40 +643,26 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
fp = NULL;
}
- /* DEPENDS */
- if(inforeq & INFRQ_DEPENDS) {
- snprintf(path, PATH_MAX, "%sdepends", pkgpath);
+ /* FILES */
+ if(inforeq & INFRQ_FILES) {
+ snprintf(path, PATH_MAX, "%sfiles", pkgpath);
if((fp = fopen(path, "r")) == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
goto error;
}
- while(!feof(fp)) {
- if(fgets(line, sizeof(line), fp) == NULL) {
- break;
- }
+ while(fgets(line, sizeof(line), fp)) {
_alpm_strtrim(line);
- if(strcmp(line, "%DEPENDS%") == 0) {
- while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
- pmdepend_t *dep = _alpm_splitdep(_alpm_strtrim(line));
- info->depends = alpm_list_add(info->depends, dep);
- }
- } else if(strcmp(line, "%OPTDEPENDS%") == 0) {
- while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
- char *linedup;
- STRDUP(linedup, _alpm_strtrim(line), goto error);
- info->optdepends = alpm_list_add(info->optdepends, linedup);
- }
- } else if(strcmp(line, "%CONFLICTS%") == 0) {
+ if(strcmp(line, "%FILES%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
STRDUP(linedup, _alpm_strtrim(line), goto error);
- info->conflicts = alpm_list_add(info->conflicts, linedup);
+ info->files = alpm_list_add(info->files, linedup);
}
- } else if(strcmp(line, "%PROVIDES%") == 0) {
+ } else if(strcmp(line, "%BACKUP%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
STRDUP(linedup, _alpm_strtrim(line), goto error);
- info->provides = alpm_list_add(info->provides, linedup);
+ info->backup = alpm_list_add(info->backup, linedup);
}
}
}
@@ -828,49 +810,6 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
fprintf(fp, "%%REASON%%\n"
"%u\n\n", info->reason);
}
-
- fclose(fp);
- fp = NULL;
- }
-
- /* FILES */
- if(inforeq & INFRQ_FILES) {
- _alpm_log(PM_LOG_DEBUG, "writing %s-%s FILES information back to db\n",
- info->name, info->version);
- snprintf(path, PATH_MAX, "%sfiles", pkgpath);
- if((fp = fopen(path, "w")) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
- retval = -1;
- goto cleanup;
- }
- if(info->files) {
- fprintf(fp, "%%FILES%%\n");
- for(lp = info->files; lp; lp = lp->next) {
- fprintf(fp, "%s\n", (char *)lp->data);
- }
- fprintf(fp, "\n");
- }
- if(info->backup) {
- fprintf(fp, "%%BACKUP%%\n");
- for(lp = info->backup; lp; lp = lp->next) {
- fprintf(fp, "%s\n", (char *)lp->data);
- }
- fprintf(fp, "\n");
- }
- fclose(fp);
- fp = NULL;
- }
-
- /* DEPENDS */
- if(inforeq & INFRQ_DEPENDS) {
- _alpm_log(PM_LOG_DEBUG, "writing %s-%s DEPENDS information back to db\n",
- info->name, info->version);
- snprintf(path, PATH_MAX, "%sdepends", pkgpath);
- if((fp = fopen(path, "w")) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
- retval = -1;
- goto cleanup;
- }
if(info->depends) {
fputs("%DEPENDS%\n", fp);
for(lp = info->depends; lp; lp = lp->next) {
@@ -901,6 +840,35 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
}
fprintf(fp, "\n");
}
+
+ fclose(fp);
+ fp = NULL;
+ }
+
+ /* FILES */
+ if(inforeq & INFRQ_FILES) {
+ _alpm_log(PM_LOG_DEBUG, "writing %s-%s FILES information back to db\n",
+ info->name, info->version);
+ snprintf(path, PATH_MAX, "%sfiles", pkgpath);
+ if((fp = fopen(path, "w")) == NULL) {
+ _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
+ retval = -1;
+ goto cleanup;
+ }
+ if(info->files) {
+ fprintf(fp, "%%FILES%%\n");
+ for(lp = info->files; lp; lp = lp->next) {
+ fprintf(fp, "%s\n", (char *)lp->data);
+ }
+ fprintf(fp, "\n");
+ }
+ if(info->backup) {
+ fprintf(fp, "%%BACKUP%%\n");
+ for(lp = info->backup; lp; lp = lp->next) {
+ fprintf(fp, "%s\n", (char *)lp->data);
+ }
+ fprintf(fp, "\n");
+ }
fclose(fp);
fp = NULL;
}
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index a0a657db..ae951945 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -362,7 +362,7 @@ static pmpkg_t *pkg_load(const char *pkgfile, int full)
} else {
/* get rid of any partial filelist we may have collected, it is invalid */
FREELIST(newpkg->files);
- newpkg->infolevel = INFRQ_BASE | INFRQ_DESC | INFRQ_DEPENDS;
+ newpkg->infolevel = INFRQ_BASE | INFRQ_DESC;
}
return(newpkg);
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 5352e9ee..133b0959 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -34,12 +34,11 @@
typedef enum _pmdbinfrq_t {
INFRQ_BASE = 1,
INFRQ_DESC = (1 << 1),
- INFRQ_DEPENDS = (1 << 2),
- INFRQ_FILES = (1 << 3),
- INFRQ_SCRIPTLET = (1 << 4),
- INFRQ_DSIZE = (1 << 5),
+ INFRQ_FILES = (1 << 2),
+ INFRQ_SCRIPTLET = (1 << 3),
+ INFRQ_DSIZE = (1 << 4),
/* ALL should be info stored in the package or database */
- INFRQ_ALL = 0x3F
+ INFRQ_ALL = 0x1F
} pmdbinfrq_t;
struct db_operations {