summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2018-05-04 05:22:32 +0200
committerGuillem Jover <guillem@debian.org>2018-08-30 03:14:08 +0200
commita9663b000b9c96030c7062fa01c0bee038cd11f9 (patch)
tree528e13d9c9743af2a97887e93f629cee713b133b /src
parentabcf523423776b2042a10bf2e05c93475f6eb1ea (diff)
downloaddpkg-a9663b000b9c96030c7062fa01c0bee038cd11f9.tar.gz
libdpkg: Move files list information from dpkg clientdata to pkginfo
This will make it possible to move the fsys database parsing and dumping code out from dpkg into libdpkg. This is general package information, even if some clients might not be interested in its contents, such as frontends that just manage metadata and drive dpkg itself.
Diffstat (limited to 'src')
-rw-r--r--src/archives.c2
-rw-r--r--src/filesdb.c47
-rw-r--r--src/main.h13
-rw-r--r--src/querycmd.c2
-rw-r--r--src/remove.c8
-rw-r--r--src/unpack.c17
-rw-r--r--src/verify.c2
7 files changed, 32 insertions, 59 deletions
diff --git a/src/archives.c b/src/archives.c
index 9b736a5d9..c80db7fcd 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -198,7 +198,7 @@ filesavespackage(struct fileinlist *file,
* we shouldn't try to make it take over this shared directory. */
debug(dbg_eachfiledetail,"filesavespackage ... is 3rd package");
- if (!thirdpkg->clientdata->fileslistvalid) {
+ if (!thirdpkg->files_list_valid) {
debug(dbg_eachfiledetail, "process_archive ... already disappeared!");
continue;
}
diff --git a/src/filesdb.c b/src/filesdb.c
index 8ca613e24..22aad89e0 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -67,18 +67,14 @@ ensure_package_clientdata(struct pkginfo *pkg)
pkg->clientdata->istobe = PKG_ISTOBE_NORMAL;
pkg->clientdata->color = PKG_CYCLE_WHITE;
pkg->clientdata->enqueued = false;
- pkg->clientdata->fileslistvalid = false;
- pkg->clientdata->files = NULL;
pkg->clientdata->replacingfilesandsaid = 0;
pkg->clientdata->cmdline_seen = 0;
- pkg->clientdata->listfile_phys_offs = 0;
pkg->clientdata->trigprocdeferred = NULL;
}
void note_must_reread_files_inpackage(struct pkginfo *pkg) {
allpackagesdone = false;
- ensure_package_clientdata(pkg);
- pkg->clientdata->fileslistvalid = false;
+ pkg->files_list_valid = false;
}
enum pkg_filesdb_load_status {
@@ -97,11 +93,7 @@ pkg_files_blank(struct pkginfo *pkg)
{
struct fileinlist *current;
- /* Anything to empty? */
- if (!pkg->clientdata)
- return;
-
- for (current= pkg->clientdata->files;
+ for (current = pkg->files;
current;
current= current->next) {
struct pkg_list *pkg_node, *pkg_prev = NULL;
@@ -125,7 +117,7 @@ pkg_files_blank(struct pkginfo *pkg)
pkg_prev = pkg_node;
}
}
- pkg->clientdata->files = NULL;
+ pkg->files = NULL;
}
static struct fileinlist **
@@ -135,10 +127,8 @@ pkg_files_add_file(struct pkginfo *pkg, struct filenamenode *namenode,
struct fileinlist *newent;
struct pkg_list *pkg_node;
- ensure_package_clientdata(pkg);
-
if (file_tail == NULL)
- file_tail = &pkg->clientdata->files;
+ file_tail = &pkg->files;
/* Make sure we're at the end. */
while ((*file_tail) != NULL) {
@@ -175,16 +165,15 @@ ensure_packagefiles_available(struct pkginfo *pkg)
struct stat stat_buf;
char *loaded_list, *loaded_list_end, *thisline, *nextline, *ptr;
- if (pkg->clientdata && pkg->clientdata->fileslistvalid)
+ if (pkg->files_list_valid)
return;
- ensure_package_clientdata(pkg);
/* Throw away any stale data, if there was any. */
pkg_files_blank(pkg);
/* Packages which aren't installed don't have a files list. */
if (pkg->status == PKG_STAT_NOTINSTALLED) {
- pkg->clientdata->fileslistvalid = true;
+ pkg->files_list_valid = true;
return;
}
@@ -205,8 +194,8 @@ ensure_packagefiles_available(struct pkginfo *pkg)
"package has no files currently installed"),
pkg_name(pkg, pnaw_nonambig));
}
- pkg->clientdata->files = NULL;
- pkg->clientdata->fileslistvalid = true;
+ pkg->files = NULL;
+ pkg->files_list_valid = true;
return;
}
@@ -228,7 +217,7 @@ ensure_packagefiles_available(struct pkginfo *pkg)
ohshite(_("reading files list for package '%.250s'"),
pkg_name(pkg, pnaw_nonambig));
- lendp= &pkg->clientdata->files;
+ lendp = &pkg->files;
thisline = loaded_list;
while (thisline < loaded_list_end) {
struct filenamenode *namenode;
@@ -259,21 +248,21 @@ ensure_packagefiles_available(struct pkginfo *pkg)
onerr_abort--;
- pkg->clientdata->fileslistvalid = true;
+ pkg->files_list_valid = true;
}
#if defined(HAVE_LINUX_FIEMAP_H)
static int
-pkg_sorter_by_listfile_phys_offs(const void *a, const void *b)
+pkg_sorter_by_files_list_phys_offs(const void *a, const void *b)
{
const struct pkginfo *pa = *(const struct pkginfo **)a;
const struct pkginfo *pb = *(const struct pkginfo **)b;
/* We can't simply subtract, because the difference may be greater than
* INT_MAX. */
- if (pa->clientdata->listfile_phys_offs < pb->clientdata->listfile_phys_offs)
+ if (pa->files_list_phys_offs < pb->files_list_phys_offs)
return -1;
- else if (pa->clientdata->listfile_phys_offs > pb->clientdata->listfile_phys_offs)
+ else if (pa->files_list_phys_offs > pb->files_list_phys_offs)
return 1;
else
return 0;
@@ -300,13 +289,11 @@ pkg_files_optimize_load(struct pkg_array *array)
const char *listfile;
int fd;
- ensure_package_clientdata(pkg);
-
if (pkg->status == PKG_STAT_NOTINSTALLED ||
- pkg->clientdata->listfile_phys_offs != 0)
+ pkg->files_list_phys_offs != 0)
continue;
- pkg->clientdata->listfile_phys_offs = -1;
+ pkg->files_list_phys_offs = -1;
listfile = pkg_infodb_get_file(pkg, &pkg->installed, LISTFILE);
@@ -321,12 +308,12 @@ pkg_files_optimize_load(struct pkg_array *array)
fm.fiemap.fm_extent_count = 1;
if (ioctl(fd, FS_IOC_FIEMAP, (unsigned long)&fm) == 0)
- pkg->clientdata->listfile_phys_offs = fm.fiemap.fm_extents[0].fe_physical;
+ pkg->files_list_phys_offs = fm.fiemap.fm_extents[0].fe_physical;
close(fd);
}
- pkg_array_sort(array, pkg_sorter_by_listfile_phys_offs);
+ pkg_array_sort(array, pkg_sorter_by_files_list_phys_offs);
}
#elif defined(HAVE_POSIX_FADVISE)
static void
diff --git a/src/main.h b/src/main.h
index 1600abc25..f5695aeea 100644
--- a/src/main.h
+++ b/src/main.h
@@ -56,22 +56,9 @@ struct perpackagestate {
bool enqueued;
- /**
- * filelistvalid files Meaning
- * ------------- ----- -------
- * false NULL Not read yet, must do so if want them.
- * false !NULL Read, but rewritten and now out of date. If want
- * info must throw away old and reread file.
- * true !NULL Read, all is OK.
- * true NULL Read OK, but, there were no files.
- */
- bool fileslistvalid;
- struct fileinlist *files;
int replacingfilesandsaid;
int cmdline_seen;
- off_t listfile_phys_offs;
-
/** Non-NULL iff in trigproc.c:deferred. */
struct pkg_list *trigprocdeferred;
};
diff --git a/src/querycmd.c b/src/querycmd.c
index 0c637bed7..555bccd3e 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -490,7 +490,7 @@ enqperpackage(const char *const *argv)
default:
ensure_packagefiles_available(pkg);
ensure_diversions();
- file= pkg->clientdata->files;
+ file = pkg->files;
if (!file) {
printf(_("Package '%s' does not contain any files (!)\n"),
pkg_name(pkg, pnaw_nonambig));
diff --git a/src/remove.c b/src/remove.c
index 6eb2e5d90..735c9e0f3 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -266,7 +266,7 @@ removal_bulk_remove_files(struct pkginfo *pkg)
modstatdb_note(pkg);
push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
- reversefilelist_init(&rev_iter, pkg->clientdata->files);
+ reversefilelist_init(&rev_iter, pkg->files);
leftover = NULL;
while ((namenode = reversefilelist_next(&rev_iter))) {
struct filenamenode *usenode;
@@ -389,7 +389,7 @@ static void removal_bulk_remove_leftover_dirs(struct pkginfo *pkg) {
modstatdb_note(pkg);
push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
- reversefilelist_init(&rev_iter, pkg->clientdata->files);
+ reversefilelist_init(&rev_iter, pkg->files);
leftover = NULL;
while ((namenode = reversefilelist_next(&rev_iter))) {
struct filenamenode *usenode;
@@ -498,7 +498,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
* are involved in diversions, except if we are the package doing the
* diverting. */
for (lconffp = &pkg->installed.conffiles; (conff = *lconffp) != NULL; ) {
- for (searchfile= pkg->clientdata->files;
+ for (searchfile = pkg->files;
searchfile && strcmp(searchfile->namenode->name,conff->name);
searchfile= searchfile->next);
if (!searchfile) {
@@ -605,7 +605,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
}
/* Remove the conffiles from the file list file. */
- write_filelist_except(pkg, &pkg->installed, pkg->clientdata->files,
+ write_filelist_except(pkg, &pkg->installed, pkg->files,
fnnf_old_conff);
pkg->installed.conffiles = NULL;
diff --git a/src/unpack.c b/src/unpack.c
index 970871a3a..2fb138691 100644
--- a/src/unpack.c
+++ b/src/unpack.c
@@ -563,7 +563,7 @@ pkg_remove_old_files(struct pkginfo *pkg,
struct filenamenode *namenode;
struct stat stab, oldfs;
- reversefilelist_init(&rev_iter, pkg->clientdata->files);
+ reversefilelist_init(&rev_iter, pkg->files);
while ((namenode = reversefilelist_next(&rev_iter))) {
struct filenamenode *usenode;
@@ -824,7 +824,7 @@ pkg_disappear(struct pkginfo *pkg, struct pkginfo *infavour)
dpkg_version_blank(&pkg->configversion);
pkgbin_blank(&pkg->installed);
- pkg->clientdata->fileslistvalid = false;
+ pkg->files_list_valid = false;
modstatdb_note(pkg);
}
@@ -847,7 +847,7 @@ pkg_disappear_others(struct pkginfo *pkg)
otherpkg->status == PKG_STAT_NOTINSTALLED ||
otherpkg->status == PKG_STAT_CONFIGFILES ||
otherpkg->clientdata->istobe == PKG_ISTOBE_REMOVE ||
- !otherpkg->clientdata->files)
+ !otherpkg->files)
continue;
/* Do not try to disappear other packages from the same set
@@ -866,14 +866,14 @@ pkg_disappear_others(struct pkginfo *pkg)
"is to be %d",
pkg_name(otherpkg, pnaw_always), otherpkg->clientdata->istobe);
- for (cfile = otherpkg->clientdata->files;
+ for (cfile = otherpkg->files;
cfile && strcmp(cfile->namenode->name, "/.") == 0;
cfile = cfile->next);
if (!cfile) {
debug(dbg_stupidlyverbose, "process_archive no non-root, no disappear");
continue;
}
- for (cfile = otherpkg->clientdata->files;
+ for (cfile = otherpkg->files;
cfile && !filesavespackage(cfile, otherpkg, pkg);
cfile = cfile->next);
if (cfile)
@@ -1012,18 +1012,17 @@ pkg_remove_files_from_others(struct pkginfo *pkg, struct fileinlist *newfileslis
if (cfile->namenode->flags & fnnf_new_conff)
conffile_mark_obsolete(otherpkg, cfile->namenode);
- /* If !fileslistvalid then it's one of the disappeared packages above
+ /* If !files_list_valid then it's one of the disappeared packages above
* or we have already updated the files list file, and we don't bother
* with it here, clearly. */
- if (!otherpkg->clientdata->fileslistvalid)
+ if (!otherpkg->files_list_valid)
continue;
/* Found one. We delete the list entry for this file,
* (and any others in the same package) and then mark the package
* as requiring a reread. */
write_filelist_except(otherpkg, &otherpkg->installed,
- otherpkg->clientdata->files, fnnf_elide_other_lists);
- ensure_package_clientdata(otherpkg);
+ otherpkg->files, fnnf_elide_other_lists);
debug(dbg_veryverbose, "process_archive overwrote from %s",
pkg_name(otherpkg, pnaw_always));
}
diff --git a/src/verify.c b/src/verify.c
index 2698fc216..a4eb86ae7 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -102,7 +102,7 @@ verify_package(struct pkginfo *pkg)
parse_filehash(pkg, &pkg->installed);
pkg_conffiles_mark_old(pkg);
- for (file = pkg->clientdata->files; file; file = file->next) {
+ for (file = pkg->files; file; file = file->next) {
struct verify_checks checks;
struct filenamenode *fnn;
char hash[MD5HASHLEN + 1];