瀏覽代碼

libdpkg: Change dpkg_arch_remove() to just unmark foreign architectures

There's no point in removing the architecture from the actual list, as
dpkg_arch_save() will only write out foreign architectures, and if code
later looks for it, then it will be reintroduced. Rename the function
to dpkg_arch_unmark() so that the name makes more sense.
Guillem Jover 14 年之前
父節點
當前提交
7ac9650539
共有 4 個文件被更改,包括 11 次插入11 次删除
  1. 7 7
      lib/dpkg/arch.c
  2. 2 2
      lib/dpkg/arch.h
  3. 1 1
      lib/dpkg/libdpkg.map
  4. 1 1
      src/main.c

+ 7 - 7
lib/dpkg/arch.c

@@ -4,7 +4,7 @@
  *
  * Copyright © 2011 Linaro Limited
  * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
- * Copyright © 2011 Guillem Jover <guillem@debian.org>
+ * Copyright © 2011-2012 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -242,19 +242,19 @@ dpkg_arch_add(const char *name)
 }
 
 /**
- * Remove a foreign dpkg_arch architecture.
+ * Unmark a foreign dpkg_arch architecture.
  */
 void
-dpkg_arch_remove(struct dpkg_arch *arch_remove)
+dpkg_arch_unmark(struct dpkg_arch *arch_remove)
 {
 	struct dpkg_arch *arch;
 
-	for (arch = arch_builtin_tail; arch && arch->next; arch = arch->next) {
-		if (arch->next->type != arch_foreign)
+	for (arch = arch_builtin_tail->next; arch; arch = arch->next) {
+		if (arch->type != arch_foreign)
 			continue;
 
-		if (arch->next == arch_remove) {
-			arch->next = arch->next->next;
+		if (arch == arch_remove) {
+			arch->type = arch_unknown;
 			arch_list_dirty = true;
 		}
 	}

+ 2 - 2
lib/dpkg/arch.h

@@ -4,7 +4,7 @@
  *
  * Copyright © 2011 Linaro Limited
  * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
- * Copyright © 2011 Guillem Jover <guillem@debian.org>
+ * Copyright © 2011-2012 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -52,7 +52,7 @@ struct dpkg_arch *dpkg_arch_get_list(void);
 void dpkg_arch_reset_list(void);
 
 struct dpkg_arch *dpkg_arch_add(const char *name);
-void dpkg_arch_remove(struct dpkg_arch *arch);
+void dpkg_arch_unmark(struct dpkg_arch *arch);
 void dpkg_arch_load_list(void);
 void dpkg_arch_save_list(void);
 

+ 1 - 1
lib/dpkg/libdpkg.map

@@ -192,7 +192,7 @@ LIBDPKG_PRIVATE {
 	dpkg_arch_get_list;
 	dpkg_arch_reset_list;
 	dpkg_arch_add;
-	dpkg_arch_remove;
+	dpkg_arch_unmark;
 	dpkg_arch_load_list;
 	dpkg_arch_save_list;
 

+ 1 - 1
src/main.c

@@ -535,7 +535,7 @@ arch_remove(const char *const *argv)
   }
   pkg_db_iter_free(iter);
 
-  dpkg_arch_remove(arch);
+  dpkg_arch_unmark(arch);
   dpkg_arch_save_list();
 
   modstatdb_shutdown();