Fix to make preinst run when required, from Stefan Soucek
authorGlenn L McGrath <bug1@ihug.co.nz>
Fri, 21 Sep 2001 05:07:47 +0000 (05:07 -0000)
committerGlenn L McGrath <bug1@ihug.co.nz>
Fri, 21 Sep 2001 05:07:47 +0000 (05:07 -0000)
archival/dpkg.c
dpkg.c

index e58052d8b581f45ad194cfa89509adf8070d7213..437b50d3b7914e360976ce4d65e028b439757bae 100644 (file)
@@ -1265,6 +1265,7 @@ void unpack_package(deb_file_t *deb_file)
 
        FILE *out_stream;
        char *info_prefix;
+       int return_value;
 
        /* If existing version, remove it first */
        if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) {
@@ -1282,6 +1283,16 @@ void unpack_package(deb_file_t *deb_file)
        sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name);
        deb_extract(deb_file->filename, stdout, (extract_quiet | extract_control_tar_gz | extract_all_to_fs), info_prefix, NULL);
 
+       /* Run the preinst prior to extracting */
+       return_value = run_package_script(package_name, "preinst");
+       if (return_value == -1) {
+           error_msg_and_die("could not execute pre-installation script.");
+       }
+       if (return_value != 0) {
+               /* when preinst returns exit code != 0 then quit installation process */
+               error_msg_and_die("subprocess pre-installation script returned error.");
+       }       
+
        /* Extract data.tar.gz to the root directory */
        deb_extract(deb_file->filename, stdout, (extract_quiet | extract_data_tar_gz | extract_all_to_fs), "/", NULL);
 
@@ -1307,7 +1318,7 @@ void configure_package(deb_file_t *deb_file)
 
        printf("Setting up %s (%s)\n", package_name, package_version);
 
-       /* Run the preinst prior to extracting */
+       /* Run the postinst script */
        return_value = run_package_script(package_name, "postinst");
        if (return_value == -1) {
                /* TODO: handle failure gracefully */
diff --git a/dpkg.c b/dpkg.c
index e58052d8b581f45ad194cfa89509adf8070d7213..437b50d3b7914e360976ce4d65e028b439757bae 100644 (file)
--- a/dpkg.c
+++ b/dpkg.c
@@ -1265,6 +1265,7 @@ void unpack_package(deb_file_t *deb_file)
 
        FILE *out_stream;
        char *info_prefix;
+       int return_value;
 
        /* If existing version, remove it first */
        if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) {
@@ -1282,6 +1283,16 @@ void unpack_package(deb_file_t *deb_file)
        sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name);
        deb_extract(deb_file->filename, stdout, (extract_quiet | extract_control_tar_gz | extract_all_to_fs), info_prefix, NULL);
 
+       /* Run the preinst prior to extracting */
+       return_value = run_package_script(package_name, "preinst");
+       if (return_value == -1) {
+           error_msg_and_die("could not execute pre-installation script.");
+       }
+       if (return_value != 0) {
+               /* when preinst returns exit code != 0 then quit installation process */
+               error_msg_and_die("subprocess pre-installation script returned error.");
+       }       
+
        /* Extract data.tar.gz to the root directory */
        deb_extract(deb_file->filename, stdout, (extract_quiet | extract_data_tar_gz | extract_all_to_fs), "/", NULL);
 
@@ -1307,7 +1318,7 @@ void configure_package(deb_file_t *deb_file)
 
        printf("Setting up %s (%s)\n", package_name, package_version);
 
-       /* Run the preinst prior to extracting */
+       /* Run the postinst script */
        return_value = run_package_script(package_name, "postinst");
        if (return_value == -1) {
                /* TODO: handle failure gracefully */