Some times we need to write back the status file, but not the available file. Add a new flag to handle those cases. Based-on-patch-by: Michel Lespinasse <walken@zoy.org>
@@ -41,7 +41,7 @@ dpkg (1.16.0) UNRELEASED; urgency=low
instead of the last file acted on that directory.
* Document in dpkg-query --help output and man page that --list and --show
arguments are optionsl.
- * Do not read the available file unnecessarily.
+ * Do not read and write the available file unnecessarily.
Thanks to Michel Lespinasse <walken@zoy.org>. Closes: #397121
[ Raphaël Hertzog ]
@@ -361,7 +361,7 @@ extern void operator delete(void *p) {
urqresult urq_list(void) {
readwrite = modstatdb_init(admindir, (modstatdb_rw)(msdbrw_writeifposs |
- msdbrw_available));
+ msdbrw_available_readonly));
curseson();
@@ -285,7 +285,7 @@ void modstatdb_shutdown(void) {
switch (cstatus) {
case msdbrw_write:
modstatdb_checkpoint();
- if (cflags & msdbrw_available)
+ if (cflags & msdbrw_available && !(cflags & msdbrw_available_readonly))
writedb(availablefile, 1, 0);
/* Tidy up a bit, but don't worry too much about failure. */
fclose(importanttmp);
@@ -219,6 +219,7 @@ enum modstatdb_rw {
msdbrw_flagsmask= ~077,
/* Flags start at 0100. */
msdbrw_available = 0100,
+ msdbrw_available_readonly = 0200,
};
bool modstatdb_is_locked(const char *admindir);
@@ -91,7 +91,7 @@ void setselections(const char *const *argv) {
if (*argv)
badusage(_("--%s takes no arguments"), cipaction->olong);
- modstatdb_init(admindir, msdbrw_write | msdbrw_available);
+ modstatdb_init(admindir, msdbrw_write | msdbrw_available_readonly);
lno= 1;
for (;;) {