diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2002-11-05 13:56:04 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2002-11-05 13:56:04 +0000 |
commit | d8d1191505d20bad3ccabf8e56b981ab8ef5abcd (patch) | |
tree | 09dbee0be1dae13a703bcbc3e972ae1c59dd6393 /archival | |
parent | 7f2a95319b640d8a40e370352cc4a8d8b8d63e0e (diff) | |
download | busybox-w32-d8d1191505d20bad3ccabf8e56b981ab8ef5abcd.tar.gz busybox-w32-d8d1191505d20bad3ccabf8e56b981ab8ef5abcd.tar.bz2 busybox-w32-d8d1191505d20bad3ccabf8e56b981ab8ef5abcd.zip |
Support for bziped debs, i.e. use .tar.bz2 instead .tar.gz internally
Diffstat (limited to 'archival')
-rw-r--r-- | archival/dpkg.c | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c index f921c43ee..937726a0c 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -1311,30 +1311,28 @@ void purge_package(const unsigned int package_num) | |||
1311 | set_status(status_num, "not-installed", 3); | 1311 | set_status(status_num, "not-installed", 3); |
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | static archive_handle_t *deb_extract(const char *filename, const char *ar_name, | 1314 | static archive_handle_t *deb_extract(const char *filename, const llist_t *accept_list, |
1315 | const char *tar_gz_name, char *prefix, void (*deb_action_data)(struct archive_handle_s *)) | 1315 | const char *tar_gz_name, char *prefix, void (*deb_action_data)(struct archive_handle_s *)) |
1316 | { | 1316 | { |
1317 | archive_handle_t *ar_archive; | 1317 | archive_handle_t *ar_archive; |
1318 | archive_handle_t *tar_gz_archive; | 1318 | archive_handle_t *tar_archive; |
1319 | 1319 | ||
1320 | /* Setup the tar archive handle */ | 1320 | /* Setup the tar archive handle */ |
1321 | tar_gz_archive = init_handle(); | 1321 | tar_archive = init_handle(); |
1322 | tar_gz_archive->filter = filter_accept_reject_list; | 1322 | tar_archive->filter = filter_accept_reject_list; |
1323 | tar_gz_archive->action_data = deb_action_data; | 1323 | tar_archive->action_data = deb_action_data; |
1324 | tar_gz_archive->buffer = prefix; | 1324 | tar_archive->buffer = prefix; |
1325 | if (tar_gz_name) { | 1325 | if (tar_gz_name) { |
1326 | tar_gz_archive->accept = add_to_list(NULL, tar_gz_name); | 1326 | tar_archive->accept = add_to_list(NULL, tar_gz_name); |
1327 | } | 1327 | } |
1328 | 1328 | ||
1329 | /* Setup an ar archive handle that refers to the gzip sub archive */ | 1329 | /* Setup an ar archive handle that refers to the gzip sub archive */ |
1330 | ar_archive = init_handle(); | 1330 | ar_archive = init_handle(); |
1331 | ar_archive->action_data_subarchive = get_header_tar_gz; | 1331 | ar_archive->sub_archive = tar_archive; |
1332 | ar_archive->sub_archive = tar_gz_archive; | 1332 | ar_archive->filter = filter_accept_list_reassign; |
1333 | ar_archive->filter = filter_accept_reject_list; | 1333 | ar_archive->accept = accept_list; |
1334 | ar_archive->accept = add_to_list(NULL, ar_name); | ||
1335 | |||
1336 | tar_gz_archive->src_fd = ar_archive->src_fd = xopen(filename, O_RDONLY); | ||
1337 | 1334 | ||
1335 | tar_archive->src_fd = ar_archive->src_fd = xopen(filename, O_RDONLY); | ||
1338 | unpack_ar_archive(ar_archive); | 1336 | unpack_ar_archive(ar_archive); |
1339 | close(ar_archive->src_fd); | 1337 | close(ar_archive->src_fd); |
1340 | 1338 | ||
@@ -1363,6 +1361,18 @@ static void unpack_package(deb_file_t *deb_file) | |||
1363 | char *info_prefix; | 1361 | char *info_prefix; |
1364 | archive_handle_t *archive_handle; | 1362 | archive_handle_t *archive_handle; |
1365 | FILE *out_stream; | 1363 | FILE *out_stream; |
1364 | const llist_t *control_list = NULL; | ||
1365 | const llist_t *data_list = NULL; | ||
1366 | |||
1367 | #ifdef CONFIG_FEATURE_DEB_TAR_GZ | ||
1368 | data_list = add_to_list(NULL, "data.tar.gz"); | ||
1369 | control_list = add_to_list(NULL, "control.tar.gz"); | ||
1370 | #endif | ||
1371 | |||
1372 | #ifdef CONFIG_FEATURE_DEB_TAR_BZ2 | ||
1373 | data_list = add_to_list(data_list, "data.tar.bz2"); | ||
1374 | control_list = add_to_list(control_list, "control.tar.bz2"); | ||
1375 | #endif | ||
1366 | 1376 | ||
1367 | /* If existing version, remove it first */ | 1377 | /* If existing version, remove it first */ |
1368 | if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) { | 1378 | if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) { |
@@ -1379,7 +1389,7 @@ static void unpack_package(deb_file_t *deb_file) | |||
1379 | info_prefix = (char *) xmalloc(strlen(package_name) + 20 + 4 + 2); | 1389 | info_prefix = (char *) xmalloc(strlen(package_name) + 20 + 4 + 2); |
1380 | sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name); | 1390 | sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name); |
1381 | 1391 | ||
1382 | deb_extract(deb_file->filename, "control.tar.gz", NULL, info_prefix, data_extract_all_prefix); | 1392 | deb_extract(deb_file->filename, control_list, NULL, info_prefix, data_extract_all_prefix); |
1383 | /* Run the preinst prior to extracting */ | 1393 | /* Run the preinst prior to extracting */ |
1384 | if (run_package_script(package_name, "preinst") != 0) { | 1394 | if (run_package_script(package_name, "preinst") != 0) { |
1385 | /* when preinst returns exit code != 0 then quit installation process */ | 1395 | /* when preinst returns exit code != 0 then quit installation process */ |
@@ -1387,7 +1397,7 @@ static void unpack_package(deb_file_t *deb_file) | |||
1387 | } | 1397 | } |
1388 | 1398 | ||
1389 | /* Extract data.tar.gz to the root directory */ | 1399 | /* Extract data.tar.gz to the root directory */ |
1390 | archive_handle = deb_extract(deb_file->filename, "data.tar.gz", NULL, NULL, data_extract_all); | 1400 | archive_handle = deb_extract(deb_file->filename, data_list, NULL, NULL, data_extract_all); |
1391 | 1401 | ||
1392 | /* Create the list file */ | 1402 | /* Create the list file */ |
1393 | strcat(info_prefix, "list"); | 1403 | strcat(info_prefix, "list"); |
@@ -1491,8 +1501,16 @@ int dpkg_main(int argc, char **argv) | |||
1491 | deb_file[deb_count] = (deb_file_t *) xmalloc(sizeof(deb_file_t)); | 1501 | deb_file[deb_count] = (deb_file_t *) xmalloc(sizeof(deb_file_t)); |
1492 | if (dpkg_opt & dpkg_opt_filename) { | 1502 | if (dpkg_opt & dpkg_opt_filename) { |
1493 | archive_handle_t *archive_handle; | 1503 | archive_handle_t *archive_handle; |
1504 | const llist_t *control_list = NULL; | ||
1505 | |||
1506 | #ifdef CONFIG_FEATURE_DEB_TAR_GZ | ||
1507 | control_list = add_to_list(NULL, "control.tar.gz"); | ||
1508 | #endif | ||
1509 | #ifdef CONFIG_FEATURE_DEB_TAR_BZ2 | ||
1510 | control_list = add_to_list(control_list, "control.tar.bz2"); | ||
1511 | #endif | ||
1494 | deb_file[deb_count]->filename = xstrdup(argv[optind]); | 1512 | deb_file[deb_count]->filename = xstrdup(argv[optind]); |
1495 | archive_handle = deb_extract(argv[optind], "control.tar.gz", "./control", NULL, data_extract_to_buffer); | 1513 | archive_handle = deb_extract(argv[optind], control_list, "./control", NULL, data_extract_to_buffer); |
1496 | deb_file[deb_count]->control_file = archive_handle->buffer; | 1514 | deb_file[deb_count]->control_file = archive_handle->buffer; |
1497 | if (deb_file[deb_count]->control_file == NULL) { | 1515 | if (deb_file[deb_count]->control_file == NULL) { |
1498 | error_msg_and_die("Couldnt extract control file"); | 1516 | error_msg_and_die("Couldnt extract control file"); |