Explorar el Código

dpkg: Store in tarcontext whether the pkgset is getting in sync

This will be used later by the extraction code to know whether it should
ensure consistency of shared files or not.

Based-on-patch-by: Raphaël Hertzog <hertzog@debian.org>
Patch-sponsored-by: Linaro Limited

Signed-off-by: Guillem Jover <guillem@debian.org>
Guillem Jover hace 15 años
padre
commit
1e6861ddcc
Se han modificado 2 ficheros con 27 adiciones y 0 borrados
  1. 2 0
      src/archives.h
  2. 25 0
      src/processarc.c

+ 2 - 0
src/archives.h

@@ -29,6 +29,8 @@ struct tarcontext {
   int backendpipe;
   struct pkginfo *pkg;
   struct fileinlist **newfilesp;
+  /* Are all “Multi-arch: same” instances about to be in sync? */
+  bool pkgset_getting_in_sync;
 };
 
 struct pkg_deconf_list {

+ 25 - 0
src/processarc.c

@@ -376,6 +376,30 @@ pkg_disappear(struct pkginfo *pkg, struct pkginfo *infavour)
   modstatdb_note(pkg);
 }
 
+/**
+ * Check if all instances of a pkgset are getting in sync.
+ *
+ * If that's the case, the extraction is going to ensure consistency
+ * of shared files.
+ */
+static bool
+pkgset_getting_in_sync(struct pkginfo *pkg)
+{
+  struct pkginfo *otherpkg;
+
+  for (otherpkg = &pkg->set->pkg; otherpkg; otherpkg = otherpkg->arch_next) {
+    if (otherpkg == pkg)
+      continue;
+    if (otherpkg->status <= stat_configfiles)
+      continue;
+    if (versioncompare(&pkg->available.version, &otherpkg->installed.version)) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
 void process_archive(const char *filename) {
   static const struct tar_operations tf = {
     .read = tarfileread,
@@ -896,6 +920,7 @@ void process_archive(const char *filename) {
   push_cleanup(cu_fileslist, ~0, NULL, 0, 0);
   tc.pkg= pkg;
   tc.backendpipe= p1[0];
+  tc.pkgset_getting_in_sync = pkgset_getting_in_sync(pkg);
 
   r = tar_extractor(&tc, &tf);
   if (r) {