The following commit has been merged in the master branch:
commit 25f368cb9756f4fe238aff9f0f7ee3b15e2e86a4
Author: Guillem Jover <[email protected]>
Date: Wed Sep 7 06:38:41 2011 +0200
dpkg: Refactor control directory creation on unpack
diff --git a/src/processarc.c b/src/processarc.c
index 811b5f2..09269b2 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -154,6 +154,45 @@ deb_verify(const char *filename)
}
}
+static char *
+get_control_dir(char *cidir)
+{
+ if (f_noact) {
+ char *tmpdir;
+
+ tmpdir = mkdtemp(path_make_temp_template("dpkg"));
+ if (tmpdir == NULL)
+ ohshite(_("unable to create temporary directory"));
+
+ cidir = m_realloc(cidir, strlen(tmpdir) + MAXCONTROLFILENAME + 10);
+
+ strcpy(cidir, tmpdir);
+
+ free(tmpdir);
+ } else {
+ const char *admindir;
+
+ admindir = dpkg_db_get_dir();
+
+ /* The admindir length is always constant on a dpkg execution run. */
+ if (cidir == NULL)
+ cidir = m_malloc(strlen(admindir) + sizeof(CONTROLDIRTMP) +
+ MAXCONTROLFILENAME + 10);
+
+ /* We want it to be on the same filesystem so that we can
+ * use rename(2) to install the postinst &c. */
+ strcpy(cidir, admindir);
+ strcat(cidir, "/" CONTROLDIRTMP);
+
+ /* Make sure the control information directory is empty. */
+ ensure_pathname_nonexisting(cidir);
+ }
+
+ strcat(cidir, "/");
+
+ return cidir;
+}
+
#define MAXCONFLICTORS 20
static struct pkginfo *conflictor[MAXCONFLICTORS];
@@ -381,38 +420,11 @@ void process_archive(const char *filename) {
if (!f_nodebsig)
deb_verify(filename);
- if (f_noact) {
- char *tmpdir;
-
- tmpdir = mkdtemp(path_make_temp_template("dpkg"));
- if (!tmpdir)
- ohshite(_("unable to create temporary directory"));
-
- cidir = m_realloc(cidir, strlen(tmpdir) + MAXCONTROLFILENAME + 10);
- strcpy(cidir, tmpdir);
- strcat(cidir,"/");
-
- cidirrest = cidir + strlen(cidir);
-
- free(tmpdir);
- } else {
- const char *admindir = dpkg_db_get_dir();
-
- /* We want it to be on the same filesystem so that we can
- * use rename(2) to install the postinst &c. */
- if (!cidir)
- cidir = m_malloc(strlen(admindir) + sizeof(CONTROLDIRTMP) +
- MAXCONTROLFILENAME + 10);
- strcpy(cidir,admindir);
- strcat(cidir, "/" CONTROLDIRTMP);
-
- ensure_pathname_nonexisting(cidir);
-
- strcat(cidir, "/");
- cidirrest = cidir + strlen(cidir);
- }
-
+ /* Get the control information directory. */
+ cidir = get_control_dir(cidir);
+ cidirrest = cidir + strlen(cidir);
push_cleanup(cu_cidir, ~0, NULL, 0, 2, (void *)cidir, (void *)cidirrest);
+
pid = subproc_fork();
if (pid == 0) {
cidirrest[-1] = '\0';
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]