소스 검색

dpkg: Do not write the database when changing selections with --dry-run

Closes: #764673
Guillem Jover 11 년 전
부모
커밋
216c509b1d
2개의 변경된 파일17개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 0
      debian/changelog
  2. 15 2
      src/select.c

+ 2 - 0
debian/changelog

@@ -8,6 +8,8 @@ dpkg (1.17.17) UNRELEASED; urgency=low
   * Mark for translation and improve dselect method handling error messages.
   * Defer trigger processing if the package does not fulfill dependencies.
     Closes: #671711
+  * Do not write to the database when changing selections with --dry-run.
+    Closes: #764673
 
   [ Updated programs translations ]
   * German (Sven Joachim).

+ 15 - 2
src/select.c

@@ -109,6 +109,7 @@ getselections(const char *const *argv)
 int
 setselections(const char *const *argv)
 {
+  enum modstatdb_rw msdbflags;
   const struct namevalue *nv;
   struct pkginfo *pkg;
   int c, lno;
@@ -119,7 +120,13 @@ setselections(const char *const *argv)
   if (*argv)
     badusage(_("--%s takes no arguments"), cipaction->olong);
 
-  modstatdb_open(msdbrw_write | msdbrw_available_readonly);
+  msdbflags = msdbrw_available_readonly;
+  if (f_noact)
+    msdbflags |= msdbrw_readonly;
+  else
+    msdbflags |= msdbrw_write;
+
+  modstatdb_open(msdbflags);
   pkg_infodb_upgrade();
 
   lno= 1;
@@ -194,13 +201,19 @@ setselections(const char *const *argv)
 int
 clearselections(const char *const *argv)
 {
+  enum modstatdb_rw msdbflags;
   struct pkgiterator *it;
   struct pkginfo *pkg;
 
   if (*argv)
     badusage(_("--%s takes no arguments"), cipaction->olong);
 
-  modstatdb_open(msdbrw_write);
+  if (f_noact)
+    msdbflags = msdbrw_readonly;
+  else
+    msdbflags = msdbrw_write;
+
+  modstatdb_open(msdbflags);
   pkg_infodb_upgrade();
 
   it = pkg_db_iter_new();