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

dpkg: Fix wanttoinstall() to use the new version from pkg->available

The code was mixing usages of the argument ver, with printing from
pkg->available.version, which is rather confusing. Just use the
available and installed pkg members instead.

This also will guarantee we'll never get a NULL version.
Guillem Jover лет назад: 15
Родитель
Сommit
f114b567dd
3 измененных файлов с 7 добавлено и 9 удалено
  1. 5 7
      src/archives.c
  2. 1 1
      src/main.h
  3. 1 1
      src/processarc.c

+ 5 - 7
src/archives.c

@@ -1327,14 +1327,13 @@ void archivefiles(const char *const *argv) {
 /**
  * Decide whether we want to install a new version of the package.
  *
- * ver is the version we might want to install. wanttoinstall() returns 0
- * if the package should be skipped and 1 if it should be installed.
+ * @param pkg The package with the version we might want to install
  *
- * ver may be 0, in which case wanttoinstall() may also return -1 to mean
- * it doesn't know because it would depend on the version number.
+ * @retval 0 If the package should be skipped.
+ * @retval 1 If the package should be installed.
  */
 int
-wanttoinstall(struct pkginfo *pkg, const struct versionrevision *ver)
+wanttoinstall(struct pkginfo *pkg)
 {
   int r;
 
@@ -1353,9 +1352,8 @@ wanttoinstall(struct pkginfo *pkg, const struct versionrevision *ver)
     return 1;
   if (pkg->status < stat_unpacked)
     return 1;
-  if (!ver) return -1;
 
-  r= versioncompare(ver,&pkg->installed.version);
+  r = versioncompare(&pkg->available.version, &pkg->installed.version);
   if (r > 0) {
     return 1;
   } else if (r == 0) {

+ 1 - 1
src/main.h

@@ -150,7 +150,7 @@ struct invoke_hook {
 
 void archivefiles(const char *const *argv);
 void process_archive(const char *filename);
-int wanttoinstall(struct pkginfo *pkg, const struct versionrevision *ver);
+int wanttoinstall(struct pkginfo *pkg);
 struct fileinlist *newconff_append(struct fileinlist ***newconffileslastp_io,
 				   struct filenamenode *namenode);
 

+ 1 - 1
src/processarc.c

@@ -297,7 +297,7 @@ void process_archive(const char *filename) {
   deconfigure = NULL;
   clear_istobes();
 
-  if (!wanttoinstall(pkg, &pkg->available.version)) {
+  if (!wanttoinstall(pkg)) {
       pop_cleanup(ehflag_normaltidy);
       return;
   }