Prechádzať zdrojové kódy

Make modstatdb available file options explicit

The options were either explicit or dependent on the main status
options, now they are always explicit. This detangles the actions
on the available file from the ones on the status file. Rename the
enum flags accordingly.
Guillem Jover 15 rokov pred
rodič
commit
6761f32a6b
5 zmenil súbory, kde vykonal 16 pridanie a 14 odobranie
  1. 7 5
      lib/dpkg/dbmodify.c
  2. 3 3
      lib/dpkg/dpkg-db.h
  3. 2 2
      src/archives.c
  4. 1 1
      src/enquiry.c
  5. 3 3
      src/querycmd.c

+ 7 - 5
lib/dpkg/dbmodify.c

@@ -209,8 +209,8 @@ modstatdb_init(const char *admindir, enum modstatdb_rw readwritereq)
     m_asprintf(fnip->store, "%s/%s", admindir, fnip->suffix);
     m_asprintf(fnip->store, "%s/%s", admindir, fnip->suffix);
   }
   }
 
 
-  cflags= readwritereq & msdbrw_flagsmask;
-  readwritereq &= ~msdbrw_flagsmask;
+  cflags = readwritereq & msdbrw_available_mask;
+  readwritereq &= ~msdbrw_available_mask;
 
 
   switch (readwritereq) {
   switch (readwritereq) {
   case msdbrw_needsuperuser:
   case msdbrw_needsuperuser:
@@ -244,7 +244,7 @@ modstatdb_init(const char *admindir, enum modstatdb_rw readwritereq)
 
 
   if (cstatus != msdbrw_needsuperuserlockonly) {
   if (cstatus != msdbrw_needsuperuserlockonly) {
     cleanupdates();
     cleanupdates();
-    if (cflags & msdbrw_available)
+    if (cflags >= msdbrw_available_readonly)
     parsedb(availablefile,
     parsedb(availablefile,
             pdb_recordavailable | pdb_rejectstatus | pdb_lax_parser,
             pdb_recordavailable | pdb_rejectstatus | pdb_lax_parser,
             NULL);
             NULL);
@@ -282,11 +282,13 @@ void modstatdb_checkpoint(void) {
 
 
 void modstatdb_shutdown(void) {
 void modstatdb_shutdown(void) {
   const struct fni *fnip;
   const struct fni *fnip;
+
+  if (cflags >= msdbrw_available_write)
+    writedb(availablefile, 1, 0);
+
   switch (cstatus) {
   switch (cstatus) {
   case msdbrw_write:
   case msdbrw_write:
     modstatdb_checkpoint();
     modstatdb_checkpoint();
-    if (cflags & msdbrw_available && !(cflags & msdbrw_available_readonly))
-      writedb(availablefile, 1, 0);
     /* Tidy up a bit, but don't worry too much about failure. */
     /* Tidy up a bit, but don't worry too much about failure. */
     fclose(importanttmp);
     fclose(importanttmp);
     unlink(importanttmpfile);
     unlink(importanttmpfile);

+ 3 - 3
lib/dpkg/dpkg-db.h

@@ -216,10 +216,10 @@ enum modstatdb_rw {
   msdbrw_write/*s*/, msdbrw_needsuperuser,
   msdbrw_write/*s*/, msdbrw_needsuperuser,
 
 
   /* Now some optional flags: */
   /* Now some optional flags: */
-  msdbrw_flagsmask= ~077,
+  msdbrw_available_mask= ~077,
   /* Flags start at 0100. */
   /* Flags start at 0100. */
-  msdbrw_available = 0100,
-  msdbrw_available_readonly = 0200,
+  msdbrw_available_readonly = 0100,
+  msdbrw_available_write = 0200,
 };
 };
 
 
 bool modstatdb_is_locked(const char *admindir);
 bool modstatdb_is_locked(const char *admindir);

+ 2 - 2
src/archives.c

@@ -1183,10 +1183,10 @@ void archivefiles(const char *const *argv) {
 
 
   modstatdb_init(admindir,
   modstatdb_init(admindir,
                  f_noact ?                          msdbrw_readonly :
                  f_noact ?                          msdbrw_readonly :
-                 (cipaction->arg_int == act_avail ? msdbrw_write :
+                 (cipaction->arg_int == act_avail ? msdbrw_readonly :
                   fc_nonroot ?                      msdbrw_write :
                   fc_nonroot ?                      msdbrw_write :
                                                     msdbrw_needsuperuser) |
                                                     msdbrw_needsuperuser) |
-                 msdbrw_available);
+                 msdbrw_available_write);
 
 
   checkpath();
   checkpath();
   log_message("startup archives %s", cipaction->olong);
   log_message("startup archives %s", cipaction->olong);

+ 1 - 1
src/enquiry.c

@@ -348,7 +348,7 @@ void predeppackage(const char *const *argv) {
   if (*argv)
   if (*argv)
     badusage(_("--%s takes no arguments"), cipaction->olong);
     badusage(_("--%s takes no arguments"), cipaction->olong);
 
 
-  modstatdb_init(admindir, msdbrw_readonly | msdbrw_available);
+  modstatdb_init(admindir, msdbrw_readonly | msdbrw_available_readonly);
   /* We use clientdata->istobe to detect loops. */
   /* We use clientdata->istobe to detect loops. */
   clear_istobes();
   clear_istobes();
 
 

+ 3 - 3
src/querycmd.c

@@ -204,7 +204,7 @@ listpackages(const char *const *argv)
   if (!*argv)
   if (!*argv)
     modstatdb_init(admindir, msdbrw_readonly);
     modstatdb_init(admindir, msdbrw_readonly);
   else
   else
-    modstatdb_init(admindir, msdbrw_readonly | msdbrw_available);
+    modstatdb_init(admindir, msdbrw_readonly | msdbrw_available_readonly);
 
 
   pkg_array_init_from_db(&array);
   pkg_array_init_from_db(&array);
   pkg_array_sort(&array, pkg_sorter_by_name);
   pkg_array_sort(&array, pkg_sorter_by_name);
@@ -372,7 +372,7 @@ enqperpackage(const char *const *argv)
     badusage(_("--%s needs at least one package name argument"), cipaction->olong);
     badusage(_("--%s needs at least one package name argument"), cipaction->olong);
 
 
   if (cipaction->arg_int == act_printavail)
   if (cipaction->arg_int == act_printavail)
-    modstatdb_init(admindir, msdbrw_readonly | msdbrw_available);
+    modstatdb_init(admindir, msdbrw_readonly | msdbrw_available_readonly);
   else
   else
     modstatdb_init(admindir, msdbrw_readonly);
     modstatdb_init(admindir, msdbrw_readonly);
 
 
@@ -472,7 +472,7 @@ showpackages(const char *const *argv)
   if (!*argv)
   if (!*argv)
     modstatdb_init(admindir, msdbrw_readonly);
     modstatdb_init(admindir, msdbrw_readonly);
   else
   else
-    modstatdb_init(admindir, msdbrw_readonly | msdbrw_available);
+    modstatdb_init(admindir, msdbrw_readonly | msdbrw_available_readonly);
 
 
   pkg_array_init_from_db(&array);
   pkg_array_init_from_db(&array);
   pkg_array_sort(&array, pkg_sorter_by_name);
   pkg_array_sort(&array, pkg_sorter_by_name);