summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2008-03-28 09:23:55 +0200
committerGuillem Jover <guillem@debian.org>2008-03-30 12:46:42 +0300
commit6a65c0a8d430c80bd800a0a3489d3dfbc5714eb2 (patch)
treed329a03698f0b1902dfbadb94044d4391774eb68 /src
parent9dbb169f8bab1dec67ef9db16edaf311798e6d69 (diff)
downloaddpkg-6a65c0a8d430c80bd800a0a3489d3dfbc5714eb2.tar.gz
Refactor post postinst script tasks into a new function
Based on a patch by Ian Jackson <ian@davenant.greenend.org.uk>.
Diffstat (limited to 'src')
-rw-r--r--src/cleanup.c12
-rw-r--r--src/configure.c3
-rw-r--r--src/help.c7
-rw-r--r--src/main.h2
4 files changed, 14 insertions, 10 deletions
diff --git a/src/cleanup.c b/src/cleanup.c
index d1ebb68aa..0a9ffad18 100644
--- a/src/cleanup.c
+++ b/src/cleanup.c
@@ -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--;
}
diff --git a/src/configure.c b/src/configure.c
index 4fbdc74c0..12ffdb1ea 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -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);
}
diff --git a/src/help.c b/src/help.c
index e09c348d5..e74d51b7a 100644
--- a/src/help.c
+++ b/src/help.c
@@ -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;
diff --git a/src/main.h b/src/main.h
index 633488508..5c5034364 100644
--- a/src/main.h
+++ b/src/main.h
@@ -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);