aboutsummaryrefslogtreecommitdiffstats
path: root/package/opkg
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-12-22 19:31:37 +0000
committerFelix Fietkau <nbd@openwrt.org>2012-12-22 19:31:37 +0000
commit9801f4687ff01f37d8f4faa100b35e672ea40739 (patch)
tree84bcf0cafd1284a52537248787fc9d7e836ef482 /package/opkg
parentdc0faf077cc5ff4049cc408d1c77457402dd3371 (diff)
downloadupstream-9801f4687ff01f37d8f4faa100b35e672ea40739.tar.gz
upstream-9801f4687ff01f37d8f4faa100b35e672ea40739.tar.bz2
upstream-9801f4687ff01f37d8f4faa100b35e672ea40739.zip
opkg: keep package list files compressed when src/gz is used, reduces tmpfs usage
SVN-Revision: 34869
Diffstat (limited to 'package/opkg')
-rw-r--r--package/opkg/patches/070-use_gzipped_pkg_list.patch120
1 files changed, 120 insertions, 0 deletions
diff --git a/package/opkg/patches/070-use_gzipped_pkg_list.patch b/package/opkg/patches/070-use_gzipped_pkg_list.patch
new file mode 100644
index 0000000000..d32b519182
--- /dev/null
+++ b/package/opkg/patches/070-use_gzipped_pkg_list.patch
@@ -0,0 +1,120 @@
+--- a/libopkg/opkg.c
++++ b/libopkg/opkg.c
+@@ -592,49 +592,8 @@ opkg_update_package_lists(opkg_progress_
+ src->gzip ? "Packages.gz" : "Packages");
+
+ sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
+- if (src->gzip) {
+- FILE *in, *out;
+- struct _curl_cb_data cb_data;
+- char *tmp_file_name = NULL;
+
+- sprintf_alloc(&tmp_file_name, "%s/%s.gz", tmp,
+- src->name);
+-
+- opkg_msg(INFO, "Downloading %s to %s...\n", url,
+- tmp_file_name);
+-
+- cb_data.cb = progress_callback;
+- cb_data.progress_data = &pdata;
+- cb_data.user_data = user_data;
+- cb_data.start_range =
+- 100 * sources_done / sources_list_count;
+- cb_data.finish_range =
+- 100 * (sources_done + 1) / sources_list_count;
+-
+- err = opkg_download(url, tmp_file_name,
+- (curl_progress_func) curl_progress_cb,
+- &cb_data, 0);
+-
+- if (err == 0) {
+- opkg_msg(INFO, "Inflating %s...\n",
+- tmp_file_name);
+- in = fopen(tmp_file_name, "r");
+- out = fopen(list_file_name, "w");
+- if (in && out)
+- unzip(in, out);
+- else
+- err = 1;
+- if (in)
+- fclose(in);
+- if (out)
+- fclose(out);
+- unlink(tmp_file_name);
+- }
+- free(tmp_file_name);
+- } else
+- err = opkg_download(url, list_file_name, NULL, NULL, 0);
+-
+- if (err) {
++ if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
+ opkg_msg(ERROR, "Couldn't retrieve %s\n", url);
+ result = -1;
+ }
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -162,30 +162,7 @@ opkg_update_cmd(int argc, char **argv)
+ sprintf_alloc(&url, "%s/%s", src->value, src->gzip ? "Packages.gz" : "Packages");
+
+ sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
+- if (src->gzip) {
+- char *tmp_file_name;
+- FILE *in, *out;
+-
+- sprintf_alloc (&tmp_file_name, "%s/%s.gz", tmp, src->name);
+- err = opkg_download(url, tmp_file_name, NULL, NULL, 0);
+- if (err == 0) {
+- opkg_msg(NOTICE, "Inflating %s.\n", url);
+- in = fopen (tmp_file_name, "r");
+- out = fopen (list_file_name, "w");
+- if (in && out)
+- unzip (in, out);
+- else
+- err = 1;
+- if (in)
+- fclose (in);
+- if (out)
+- fclose (out);
+- unlink (tmp_file_name);
+- }
+- free(tmp_file_name);
+- } else
+- err = opkg_download(url, list_file_name, NULL, NULL, 0);
+- if (err) {
++ if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
+ failures++;
+ } else {
+ opkg_msg(NOTICE, "Updated list of available packages in %s.\n",
+--- a/libopkg/pkg_hash.c
++++ b/libopkg/pkg_hash.c
+@@ -102,12 +102,18 @@ pkg_hash_add_from_file(const char *file_
+ pkg_src_t *src, pkg_dest_t *dest, int is_status_file)
+ {
+ pkg_t *pkg;
+- FILE *fp;
++ FILE *fp, *fp_c = NULL;
+ char *buf;
+ const size_t len = 4096;
+ int ret = 0;
++ int pid;
+
+ fp = fopen(file_name, "r");
++ if (fp && src && src->gzip) {
++ fp_c = fp;
++ fp = gz_open(fp_c, &pid);
++ }
++
+ if (fp == NULL) {
+ opkg_perror(ERROR, "Failed to open %s", file_name);
+ return -1;
+@@ -154,6 +160,10 @@ pkg_hash_add_from_file(const char *file_
+
+ free(buf);
+ fclose(fp);
++ if (fp_c) {
++ fclose(fp_c);
++ gz_close(pid);
++ }
+
+ return ret;
+ }