diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2001-09-21 05:07:47 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2001-09-21 05:07:47 +0000 |
commit | 48cc89b7381d255299229402b72c6ccc838515f0 (patch) | |
tree | 9d1b32300925d92110a2b3d407651608b52a76dc | |
parent | e73866181f553067cae3411608f3cf1677d63a8b (diff) | |
download | busybox-w32-48cc89b7381d255299229402b72c6ccc838515f0.tar.gz busybox-w32-48cc89b7381d255299229402b72c6ccc838515f0.tar.bz2 busybox-w32-48cc89b7381d255299229402b72c6ccc838515f0.zip |
Fix to make preinst run when required, from Stefan Soucek
-rw-r--r-- | archival/dpkg.c | 13 | ||||
-rw-r--r-- | dpkg.c | 13 |
2 files changed, 24 insertions, 2 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c index e58052d8b..437b50d3b 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -1265,6 +1265,7 @@ void unpack_package(deb_file_t *deb_file) | |||
1265 | 1265 | ||
1266 | FILE *out_stream; | 1266 | FILE *out_stream; |
1267 | char *info_prefix; | 1267 | char *info_prefix; |
1268 | int return_value; | ||
1268 | 1269 | ||
1269 | /* If existing version, remove it first */ | 1270 | /* If existing version, remove it first */ |
1270 | if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) { | 1271 | if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) { |
@@ -1282,6 +1283,16 @@ void unpack_package(deb_file_t *deb_file) | |||
1282 | sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name); | 1283 | sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name); |
1283 | deb_extract(deb_file->filename, stdout, (extract_quiet | extract_control_tar_gz | extract_all_to_fs), info_prefix, NULL); | 1284 | deb_extract(deb_file->filename, stdout, (extract_quiet | extract_control_tar_gz | extract_all_to_fs), info_prefix, NULL); |
1284 | 1285 | ||
1286 | /* Run the preinst prior to extracting */ | ||
1287 | return_value = run_package_script(package_name, "preinst"); | ||
1288 | if (return_value == -1) { | ||
1289 | error_msg_and_die("could not execute pre-installation script."); | ||
1290 | } | ||
1291 | if (return_value != 0) { | ||
1292 | /* when preinst returns exit code != 0 then quit installation process */ | ||
1293 | error_msg_and_die("subprocess pre-installation script returned error."); | ||
1294 | } | ||
1295 | |||
1285 | /* Extract data.tar.gz to the root directory */ | 1296 | /* Extract data.tar.gz to the root directory */ |
1286 | deb_extract(deb_file->filename, stdout, (extract_quiet | extract_data_tar_gz | extract_all_to_fs), "/", NULL); | 1297 | deb_extract(deb_file->filename, stdout, (extract_quiet | extract_data_tar_gz | extract_all_to_fs), "/", NULL); |
1287 | 1298 | ||
@@ -1307,7 +1318,7 @@ void configure_package(deb_file_t *deb_file) | |||
1307 | 1318 | ||
1308 | printf("Setting up %s (%s)\n", package_name, package_version); | 1319 | printf("Setting up %s (%s)\n", package_name, package_version); |
1309 | 1320 | ||
1310 | /* Run the preinst prior to extracting */ | 1321 | /* Run the postinst script */ |
1311 | return_value = run_package_script(package_name, "postinst"); | 1322 | return_value = run_package_script(package_name, "postinst"); |
1312 | if (return_value == -1) { | 1323 | if (return_value == -1) { |
1313 | /* TODO: handle failure gracefully */ | 1324 | /* TODO: handle failure gracefully */ |
@@ -1265,6 +1265,7 @@ void unpack_package(deb_file_t *deb_file) | |||
1265 | 1265 | ||
1266 | FILE *out_stream; | 1266 | FILE *out_stream; |
1267 | char *info_prefix; | 1267 | char *info_prefix; |
1268 | int return_value; | ||
1268 | 1269 | ||
1269 | /* If existing version, remove it first */ | 1270 | /* If existing version, remove it first */ |
1270 | if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) { | 1271 | if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) { |
@@ -1282,6 +1283,16 @@ void unpack_package(deb_file_t *deb_file) | |||
1282 | sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name); | 1283 | sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name); |
1283 | deb_extract(deb_file->filename, stdout, (extract_quiet | extract_control_tar_gz | extract_all_to_fs), info_prefix, NULL); | 1284 | deb_extract(deb_file->filename, stdout, (extract_quiet | extract_control_tar_gz | extract_all_to_fs), info_prefix, NULL); |
1284 | 1285 | ||
1286 | /* Run the preinst prior to extracting */ | ||
1287 | return_value = run_package_script(package_name, "preinst"); | ||
1288 | if (return_value == -1) { | ||
1289 | error_msg_and_die("could not execute pre-installation script."); | ||
1290 | } | ||
1291 | if (return_value != 0) { | ||
1292 | /* when preinst returns exit code != 0 then quit installation process */ | ||
1293 | error_msg_and_die("subprocess pre-installation script returned error."); | ||
1294 | } | ||
1295 | |||
1285 | /* Extract data.tar.gz to the root directory */ | 1296 | /* Extract data.tar.gz to the root directory */ |
1286 | deb_extract(deb_file->filename, stdout, (extract_quiet | extract_data_tar_gz | extract_all_to_fs), "/", NULL); | 1297 | deb_extract(deb_file->filename, stdout, (extract_quiet | extract_data_tar_gz | extract_all_to_fs), "/", NULL); |
1287 | 1298 | ||
@@ -1307,7 +1318,7 @@ void configure_package(deb_file_t *deb_file) | |||
1307 | 1318 | ||
1308 | printf("Setting up %s (%s)\n", package_name, package_version); | 1319 | printf("Setting up %s (%s)\n", package_name, package_version); |
1309 | 1320 | ||
1310 | /* Run the preinst prior to extracting */ | 1321 | /* Run the postinst script */ |
1311 | return_value = run_package_script(package_name, "postinst"); | 1322 | return_value = run_package_script(package_name, "postinst"); |
1312 | if (return_value == -1) { | 1323 | if (return_value == -1) { |
1313 | /* TODO: handle failure gracefully */ | 1324 | /* TODO: handle failure gracefully */ |