Просмотр исходного кода

dpkg: Use pkgadminfile() instead of varbuf_pkgadminfile()

This simplifies the API, and unifies the different call sites, the
extremely small performance penalty is irrelevant in these cases.
Guillem Jover лет назад: 15
Родитель
Сommit
869564af64
2 измененных файлов с 17 добавлено и 12 удалено
  1. 5 4
      src/filesdb.c
  2. 12 8
      src/remove.c

+ 5 - 4
src/filesdb.c

@@ -461,13 +461,14 @@ void
 write_filelist_except(struct pkginfo *pkg, struct fileinlist *list,
                       bool leaveout)
 {
-  static struct varbuf vb, newvb;
+  static struct varbuf newvb;
+  const char *listfile;
   FILE *file;
 
-  varbuf_pkgadminfile(&vb, pkg, LISTFILE);
+  listfile = pkgadminfile(pkg, LISTFILE);
 
   varbuf_reset(&newvb);
-  varbuf_add_str(&newvb, vb.buf);
+  varbuf_add_str(&newvb, listfile);
   varbuf_add_str(&newvb, NEWDBEXT);
   varbuf_add_char(&newvb, '\0');
 
@@ -491,7 +492,7 @@ write_filelist_except(struct pkginfo *pkg, struct fileinlist *list,
   pop_cleanup(ehflag_normaltidy); /* file = fopen() */
   if (fclose(file))
     ohshite(_("failed to close updated files list file for package %s"),pkg->name);
-  if (rename(newvb.buf,vb.buf))
+  if (rename(newvb.buf, listfile))
     ohshite(_("failed to install updated files list file for package %s"),pkg->name);
 
   dir_sync_path(pkgadmindir());

+ 12 - 8
src/remove.c

@@ -561,18 +561,22 @@ void removal_bulk(struct pkginfo *pkg) {
 
   /* I.e., either of the two branches above. */
   if (pkg->want == want_purge) {
-    static struct varbuf fnvb;
+    const char *filename;
 
     /* Retry empty directories, and warn on any leftovers that aren't. */
     removal_bulk_remove_leftover_dirs(pkg);
 
-    varbuf_pkgadminfile(&fnvb, pkg, LISTFILE);
-    debug(dbg_general, "removal_bulk purge done, removing list `%s'",fnvb.buf);
-    if (unlink(fnvb.buf) && errno != ENOENT) ohshite(_("cannot remove old files list"));
-
-    varbuf_pkgadminfile(&fnvb, pkg, POSTRMFILE);
-    debug(dbg_general, "removal_bulk purge done, removing postrm `%s'",fnvb.buf);
-    if (unlink(fnvb.buf) && errno != ENOENT) ohshite(_("can't remove old postrm script"));
+    filename = pkgadminfile(pkg, LISTFILE);
+    debug(dbg_general, "removal_bulk purge done, removing list `%s'",
+          filename);
+    if (unlink(filename) && errno != ENOENT)
+      ohshite(_("cannot remove old files list"));
+
+    filename = pkgadminfile(pkg, POSTRMFILE);
+    debug(dbg_general, "removal_bulk purge done, removing postrm `%s'",
+          filename);
+    if (unlink(filename) && errno != ENOENT)
+      ohshite(_("can't remove old postrm script"));
 
     pkg->status= stat_notinstalled;
     pkg->want = want_unknown;