]> err.no Git - dpkg/commitdiff
Refactor post postinst script tasks into a new function
authorGuillem Jover <guillem@debian.org>
Fri, 28 Mar 2008 07:23:55 +0000 (09:23 +0200)
committerGuillem Jover <guillem@debian.org>
Sun, 30 Mar 2008 09:46:42 +0000 (12:46 +0300)
Based on a patch by Ian Jackson <ian@davenant.greenend.org.uk>.

ChangeLog
src/cleanup.c
src/configure.c
src/help.c
src/main.h

index da9ba16b69f1483d898f4cbdba694aac9611e755..122ac871125fbb7c06fd402c8b265d9f6eaa245e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-03-28  Ian Jackson  <ian@davenant.greenend.org.uk>,
+            Guillem Jover  <guillem@debian.org>
+
+       * src/main.h (post_postinst_tasks): New prototype.
+       * src/help.c (post_postinst_tasks): New function.
+       * src/cleanup.c (cu_prermupgrade): Use post_postinst_tasks instead of
+       duplicate code.
+       (cu_prermdeconfigure): Likewise.
+       (cu_prerminfavour): Likewise.
+       (cu_prermremove): Likewise.
+       * src/configure.c (deferred_configure): Likewise.
+
 2008-03-28  Guillem Jover  <guillem@debian.org>
 
        * src/packages.c (process_queue): Fix typo in comment.
index d1ebb68aacae4a7262d3bfba52b5ea233d447b99..0a9ffad189b2a9edb9060942730475cd7d3d6194 100644 (file)
@@ -112,9 +112,8 @@ void cu_prermupgrade(int argc, void **argv) {
                               versiondescribe(&pkg->available.version,
                                               vdew_nonambig),
                               NULL);
-  pkg->status= stat_installed;
   pkg->eflag &= ~eflagf_reinstreq;
-  modstatdb_note(pkg);
+  post_postinst_tasks(pkg, stat_installed);
   cleanup_pkg_failed--;
 }
 
@@ -151,8 +150,7 @@ void cu_prermdeconfigure(int argc, void **argv) {
                                 NULL);
   }
 
-  deconf->status= stat_installed;
-  modstatdb_note(deconf);
+  post_postinst_tasks(deconf, stat_installed);
 }
 
 void cu_prerminfavour(int argc, void **argv) {
@@ -165,9 +163,8 @@ void cu_prerminfavour(int argc, void **argv) {
                               versiondescribe(&infavour->available.version,
                                               vdew_nonambig),
                               NULL);
-  conflictor->status= stat_installed;
   conflictor->eflag &= ~eflagf_reinstreq;
-  modstatdb_note(conflictor);
+  post_postinst_tasks(conflictor, stat_installed);
   cleanup_conflictor_failed--;
 }
 
@@ -238,8 +235,7 @@ void cu_prermremove(int argc, void **argv) {
   if (cleanup_pkg_failed++) return;
   maintainer_script_installed(pkg,POSTINSTFILE,"post-installation",
                               "abort-remove", NULL);
-  pkg->status= *oldpkgstatus;
   pkg->eflag &= ~eflagf_reinstreq;
-  modstatdb_note(pkg);
+  post_postinst_tasks(pkg, *oldpkgstatus);
   cleanup_pkg_failed--;
 }
index 4fbdc74c05b2ba145c200d68baf54304dc1202e9..12ffdb1ead082a64af5540e3af33e2ef90c89a5f 100644 (file)
@@ -303,9 +303,8 @@ void deferred_configure(struct pkginfo *pkg) {
                                                    vdew_nonambig) : "",
                                    NULL);
 
-       pkg->status= stat_installed;
        pkg->eflag= eflagv_ok;
-       modstatdb_note(pkg);
+       post_postinst_tasks(pkg, stat_installed);
 }
 
 
index e09c348d58ecff1bdfba55a9382002ee781cdacb..e74d51b7a2ade3a9c30efbb200837fbadffedf0d 100644 (file)
@@ -217,6 +217,13 @@ static void script_catchsignals(void) {
   onerr_abort--;
 }
 
+void
+post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status)
+{
+  pkg->status = new_status;
+  modstatdb_note(pkg);
+}
+
 static void setexecute(const char *path, struct stat *stab) {
   if ((stab->st_mode & 0555) == 0555) return;
   if (!chmod(path,0755)) return;
index 63348850808ddf4ce76fda8e7599f6369273e2f9..5c5034364751dc9877a093ace75be34db8e388d0 100644 (file)
@@ -214,6 +214,8 @@ int maintainer_script_alternative(struct pkginfo *pkg,
                                   const char *scriptname, const char *description,
                                   const char *cidir, char *cidirrest,
                                   const char *ifok, const char *iffallback);
+void post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status);
+
 void clear_istobes(void);
 int isdirectoryinuse(struct filenamenode *namenode, struct pkginfo *pkg);
 int hasdirectoryconffiles(struct filenamenode *namenode, struct pkginfo *pkg);