termux-packages/packages/busybox/dpkg.patch
Fredrik Fornwall 59f0d218a6 Initial push
2015-06-13 01:03:31 +02:00

147 lines
6.1 KiB
Diff

diff -u -r ../busybox-1.22.1/archival/dpkg.c ./archival/dpkg.c
--- ../busybox-1.22.1/archival/dpkg.c 2014-01-09 19:15:44.000000000 +0100
+++ ./archival/dpkg.c 2014-01-20 08:52:03.000000000 +0100
@@ -813,8 +813,8 @@
/* This could do with a cleanup */
static void write_status_file(deb_file_t **deb_file)
{
- FILE *old_status_file = xfopen_for_read("/var/lib/dpkg/status");
- FILE *new_status_file = xfopen_for_write("/var/lib/dpkg/status.udeb");
+ FILE *old_status_file = xfopen_for_read("@TERMUX_PREFIX@/var/lib/dpkg/status");
+ FILE *new_status_file = xfopen_for_write("@TERMUX_PREFIX@/var/lib/dpkg/status.udeb");
char *package_name;
char *status_from_file;
char *control_buffer = NULL;
@@ -942,7 +942,7 @@
fclose(new_status_file);
/* Create a separate backfile to dpkg */
- if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
+ if (rename("@TERMUX_PREFIX@/var/lib/dpkg/status", "@TERMUX_PREFIX@/var/lib/dpkg/status.udeb.bak") == -1) {
if (errno != ENOENT)
bb_error_msg_and_die("can't create backup status file");
/* Its ok if renaming the status file fails because status
@@ -950,7 +950,7 @@
bb_error_msg("no status file found, creating new one");
}
- xrename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status");
+ xrename("@TERMUX_PREFIX@/var/lib/dpkg/status.udeb", "@TERMUX_PREFIX@/var/lib/dpkg/status");
}
/* This function returns TRUE if the given package can satisfy a
@@ -1242,7 +1242,7 @@
char *script_path;
int result;
- script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type);
+ script_path = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, script_type);
/* If the file doesnt exist is isnt fatal */
result = access(script_path, F_OK) ? EXIT_SUCCESS : system(script_path);
@@ -1295,7 +1295,7 @@
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = xzalloc(sizeof(all_control_files) + sizeof(char*));
while (i < ARRAY_SIZE(all_control_files)) {
- remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s",
+ remove_files[i] = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s",
package_name, all_control_files[i]);
i++;
}
@@ -1366,8 +1366,8 @@
const int package_name_length = strlen(package_name);
char **remove_files;
char **exclude_files;
- char list_name[package_name_length + 25];
- char conffile_name[package_name_length + 30];
+ char list_name[package_name_length + 100];
+ char conffile_name[package_name_length + 100];
if (noisy)
printf("Removing %s (%s)...\n", package_name, package_version);
@@ -1376,10 +1376,10 @@
run_package_script_or_die(package_name, "prerm");
/* Create a list of files to remove, and a separate list of those to keep */
- sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
+ sprintf(list_name, "@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "list");
remove_files = create_list(list_name);
- sprintf(conffile_name, "/var/lib/dpkg/info/%s.%s", package_name, "conffiles");
+ sprintf(conffile_name, "@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "conffiles");
exclude_files = create_list(conffile_name);
/* Some directories can't be removed straight away, so do multiple passes */
@@ -1391,7 +1391,7 @@
/* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
exclude_files = xzalloc(sizeof(exclude_files[0]) * 3);
exclude_files[0] = xstrdup(conffile_name);
- exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
+ exclude_files[1] = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "postrm");
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = all_control_list(package_name);
@@ -1416,7 +1416,7 @@
const unsigned status_num = search_status_hashtable(package_name);
char **remove_files;
char **exclude_files;
- char list_name[strlen(package_name) + 25];
+ char list_name[strlen(package_name) + 100];
printf("Purging %s (%s)...\n", package_name, package_version);
@@ -1424,7 +1424,7 @@
run_package_script_or_die(package_name, "prerm");
/* Create a list of files to remove */
- sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
+ sprintf(list_name, "@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "list");
remove_files = create_list(list_name);
/* Some directories cant be removed straight away, so do multiple passes */
@@ -1437,7 +1437,7 @@
/* Delete all of them except the postrm script */
exclude_files = xzalloc(sizeof(exclude_files[0]) * 2);
- exclude_files[0] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
+ exclude_files[0] = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "postrm");
remove_file_array(remove_files, exclude_files);
free_array(exclude_files);
@@ -1528,7 +1528,7 @@
FILE *fp;
char *filename, *line;
- filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, control_name);
+ filename = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, control_name);
fp = fopen_for_read(filename);
free(filename);
if (fp != NULL) {
@@ -1648,7 +1648,7 @@
}
/* Extract control.tar.gz to /var/lib/dpkg/info/<package>.filename */
- info_prefix = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "");
+ info_prefix = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "");
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_control(archive_handle);
@@ -1688,7 +1688,7 @@
unpack_ar_archive(archive_handle);
/* Create the list file */
- list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
+ list_filename = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "list");
out_stream = xfopen_for_write(list_filename);
archive_handle->dpkg__sub_archive->passed = llist_rev(archive_handle->dpkg__sub_archive->passed);
while (archive_handle->dpkg__sub_archive->passed) {
@@ -1782,7 +1782,7 @@
}
/* puts("(Reading database ... xxxxx files and directories installed.)"); */
- index_status_file("/var/lib/dpkg/status");
+ index_status_file("@TERMUX_PREFIX@/var/lib/dpkg/status");
/* if the list action was given print the installed packages and exit */
if (opt & OPT_list_installed) {