From b77330f6fbe386fe2dde014b6010cd1d3283b9ae Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 6 Jul 2008 21:34:54 +0300 Subject: [PATCH] dpkg: Move trig_file_activate call from namenodetouse to its callers --- ChangeLog | 9 +++++++++ src/archives.c | 6 +++++- src/help.c | 4 +--- src/main.h | 3 --- src/processarc.c | 7 ++++++- src/remove.c | 15 +++++++++++++-- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9962ff4d..4ddf9622 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-07-06 Guillem Jover + + * src/main.h: Remove comment about side effect in namenodetouse. + * src/help.c (namenodetouse): Move call to trig_file_activate to ... + * src/archives.c (tarobject): ... here. + * src/processarc.c (process_archive): Likewise. + * src/remove.c (removal_bulk_remove_files): Likewise. + (removal_bulk_remove_leftover_dirs): Likewise. + 2008-07-06 Michel Lespinasse * dselect/baselist.cc (baselist::startdisplay): Create the diff --git a/src/archives.c b/src/archives.c index 2c7c248d..70fe4c5a 100644 --- a/src/archives.c +++ b/src/archives.c @@ -400,6 +400,7 @@ int tarobject(struct TarInfo *ti) { static struct varbuf conffderefn, hardlinkfn, symlinkfn; static int fd; const char *usename; + struct filenamenode *usenode; struct conffile *conff; struct tarcontext *tc= (struct tarcontext*)ti->UserData; @@ -450,7 +451,10 @@ int tarobject(struct TarInfo *ti) { } } - usename= namenodetouse(nifd->namenode,tc->pkg)->name + 1; /* Skip the leading `/' */ + usenode = namenodetouse(nifd->namenode, tc->pkg); + usename = usenode->name + 1; /* Skip the leading '/'. */ + + trig_file_activate(usenode, tc->pkg); if (nifd->namenode->flags & fnnf_new_conff) { /* If it's a conffile we have to extract it next to the installed diff --git a/src/help.c b/src/help.c index 26385cb5..9c9030e3 100644 --- a/src/help.c +++ b/src/help.c @@ -53,7 +53,7 @@ struct filenamenode *namenodetouse(struct filenamenode *namenode, struct pkginfo if (!namenode->divert) { r = namenode; - goto found; + return r; } debug(dbg_eachfile,"namenodetouse namenode=`%s' pkg=%s", @@ -70,8 +70,6 @@ struct filenamenode *namenodetouse(struct filenamenode *namenode, struct pkginfo namenode->divert->pkg ? namenode->divert->pkg->name : "", r->name); - found: - trig_file_activate(r, pkg); return r; } diff --git a/src/main.h b/src/main.h index 49a19736..a1a30c0f 100644 --- a/src/main.h +++ b/src/main.h @@ -208,9 +208,6 @@ int chmodsafe_unlink_statted(const char *pathname, const struct stat *stab, const char **failed); void checkpath(void); -/* NB side effect! This not only computes the appropriate filename - * to use including thinking about any diversions, but also activates - * any file triggers. */ struct filenamenode *namenodetouse(struct filenamenode*, struct pkginfo*); /* all ...'s are const char*'s ... */ diff --git a/src/processarc.c b/src/processarc.c index a3b455d4..b0582b9b 100644 --- a/src/processarc.c +++ b/src/processarc.c @@ -632,12 +632,17 @@ void process_archive(const char *filename) { */ reversefilelist_init(&rlistit,pkg->clientdata->files); while ((namenode= reversefilelist_next(&rlistit))) { + struct filenamenode *usenode; + if ((namenode->flags & fnnf_new_conff) || (namenode->flags & fnnf_new_inarchive)) continue; + usenode = namenodetouse(namenode, pkg); + trig_file_activate(usenode, pkg); + fnamevb.used= fnameidlu; - varbufaddstr(&fnamevb, namenodetouse(namenode,pkg)->name); + varbufaddstr(&fnamevb, usenode->name); varbufaddc(&fnamevb,0); if (!stat(namenode->name,&stab) && S_ISDIR(stab.st_mode)) { diff --git a/src/remove.c b/src/remove.c index 1f80a4a8..679441e6 100644 --- a/src/remove.c +++ b/src/remove.c @@ -213,15 +213,21 @@ static void removal_bulk_remove_files( reversefilelist_init(&rlistit,pkg->clientdata->files); leftover = NULL; while ((namenode= reversefilelist_next(&rlistit))) { + struct filenamenode *usenode; + debug(dbg_eachfile, "removal_bulk `%s' flags=%o", namenode->name, namenode->flags); if (namenode->flags & fnnf_old_conff) { push_leftover(&leftover,namenode); continue; } + + usenode = namenodetouse(namenode, pkg); + trig_file_activate(usenode, pkg); + varbufreset(&fnvb); varbufaddstr(&fnvb,instdir); - varbufaddstr(&fnvb,namenodetouse(namenode,pkg)->name); + varbufaddstr(&fnvb, usenode->name); before= fnvb.used; varbufaddstr(&fnvb,DPKGTEMPEXT); @@ -340,6 +346,8 @@ static void removal_bulk_remove_leftover_dirs(struct pkginfo *pkg) { reversefilelist_init(&rlistit,pkg->clientdata->files); leftover = NULL; while ((namenode= reversefilelist_next(&rlistit))) { + struct filenamenode *usenode; + debug(dbg_eachfile, "removal_bulk `%s' flags=%o", namenode->name, namenode->flags); if (namenode->flags & fnnf_old_conff) { @@ -347,9 +355,12 @@ static void removal_bulk_remove_leftover_dirs(struct pkginfo *pkg) { continue; } + usenode = namenodetouse(namenode, pkg); + trig_file_activate(usenode, pkg); + varbufreset(&fnvb); varbufaddstr(&fnvb,instdir); - varbufaddstr(&fnvb,namenodetouse(namenode,pkg)->name); + varbufaddstr(&fnvb, usenode->name); varbufaddc(&fnvb,0); if (!stat(fnvb.buf,&stab) && S_ISDIR(stab.st_mode)) { -- 2.39.5