Procházet zdrojové kódy

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 před 15 roky
rodič
revize
1e6861ddcc
2 změnil soubory, kde provedl 27 přidání a 0 odebrání
  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;
   int backendpipe;
   struct pkginfo *pkg;
   struct pkginfo *pkg;
   struct fileinlist **newfilesp;
   struct fileinlist **newfilesp;
+  /* Are all “Multi-arch: same” instances about to be in sync? */
+  bool pkgset_getting_in_sync;
 };
 };
 
 
 struct pkg_deconf_list {
 struct pkg_deconf_list {

+ 25 - 0
src/processarc.c

@@ -376,6 +376,30 @@ pkg_disappear(struct pkginfo *pkg, struct pkginfo *infavour)
   modstatdb_note(pkg);
   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) {
 void process_archive(const char *filename) {
   static const struct tar_operations tf = {
   static const struct tar_operations tf = {
     .read = tarfileread,
     .read = tarfileread,
@@ -896,6 +920,7 @@ void process_archive(const char *filename) {
   push_cleanup(cu_fileslist, ~0, NULL, 0, 0);
   push_cleanup(cu_fileslist, ~0, NULL, 0, 0);
   tc.pkg= pkg;
   tc.pkg= pkg;
   tc.backendpipe= p1[0];
   tc.backendpipe= p1[0];
+  tc.pkgset_getting_in_sync = pkgset_getting_in_sync(pkg);
 
 
   r = tar_extractor(&tc, &tf);
   r = tar_extractor(&tc, &tf);
   if (r) {
   if (r) {