summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorAlejandro del Castillo <alejandro.delcastillo@ni.com>2015-12-17 10:18:19 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-22 16:08:51 +0000
commitdad130b76493429b6dc1de436cb758cd1735f808 (patch)
tree2fed6ff3a4426ef21becfd566451682b6c23af9f /meta
parentd2b770caade430f584c83806924b962982ab7ddc (diff)
downloadpoky-dad130b76493429b6dc1de436cb758cd1735f808.tar.gz
opkg: upgrade to v0.3.1
* Drop merged patches * Add patch to fix crash when using the libsolv backend * Add patch to add pkgconfig support for libsolv * Add libsolv support via a PACKAGECONFIG option. (From OE-Core rev: 51265ca2b77c05c94f65d3bc8e1883853b0b540c) Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/opkg/opkg/0001-configure.ac-use-pkg-config-for-libsolv.patch36
-rw-r--r--meta/recipes-devtools/opkg/opkg/0001-libopkg-include-stdio.h-for-getting-FILE-defined.patch45
-rw-r--r--meta/recipes-devtools/opkg/opkg/0001-libsolv_solver_set_arch_policy-use-correct-logic-dur.patch35
-rw-r--r--meta/recipes-devtools/opkg/opkg/0001-opkg_archive-add-support-for-empty-compressed-files.patch64
-rw-r--r--meta/recipes-devtools/opkg/opkg/0001-string_util-New-file-with-bin_to_hex-function.patch122
-rw-r--r--meta/recipes-devtools/opkg/opkg/0002-md5-Add-md5_to_string-function.patch110
-rw-r--r--meta/recipes-devtools/opkg/opkg/0003-sha256-Add-sha256_to_string-function.patch110
-rw-r--r--meta/recipes-devtools/opkg/opkg/0004-opkg_download-Use-short-cache-file-name.patch85
-rw-r--r--meta/recipes-devtools/opkg/opkg_0.3.1.bb (renamed from meta/recipes-devtools/opkg/opkg_0.3.0.bb)13
9 files changed, 76 insertions, 544 deletions
diff --git a/meta/recipes-devtools/opkg/opkg/0001-configure.ac-use-pkg-config-for-libsolv.patch b/meta/recipes-devtools/opkg/opkg/0001-configure.ac-use-pkg-config-for-libsolv.patch
new file mode 100644
index 0000000000..e67ec7479e
--- /dev/null
+++ b/meta/recipes-devtools/opkg/opkg/0001-configure.ac-use-pkg-config-for-libsolv.patch
@@ -0,0 +1,36 @@
1From 2a43027f7ecf2bb3ce73f95bcf575c56bc495d07 Mon Sep 17 00:00:00 2001
2From: Alejandro del Castillo <alejandro.delcastillo@ni.com>
3Date: Wed, 9 Dec 2015 17:38:05 -0600
4Subject: [PATCH] configure.ac: use pkg-config for libsolv
5
6Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
7---
8 configure.ac | 12 +-----------
9 1 file changed, 1 insertion(+), 11 deletions(-)
10
11diff --git a/configure.ac b/configure.ac
12index 52e1025..d17dc5c 100644
13--- a/configure.ac
14+++ b/configure.ac
15@@ -159,17 +159,7 @@ if test "x$want_solver" != "xno"; then
16 AC_MSG_ERROR(Specify which solver with --enable-solver=<SOLVER>)],
17 [libsolv],
18 [AC_MSG_RESULT(libsolv)
19-
20- SOLVER_CFLAGS="-I/usr/local/include/"
21- SOLVER_LIBS="-lsolv -lsolvext"
22- AC_CHECK_LIB([solv],
23- [solver_solve],
24- [],
25- [AC_MSG_ERROR(libsolv not found)])
26- dnl TODO: remove previous 6 lines and uncomment line below to use
27- dnl pkg-config once there is a release of libsolv with pkg-config:
28- dnl PKG_CHECK_MODULES(SOLVER, libsolv)
29-
30+ PKG_CHECK_MODULES(SOLVER, libsolv)
31 AC_DEFINE(HAVE_SOLVER_LIBSOLV,1,[Define if you want to use libsolv])],
32 # default
33 [AC_MSG_RESULT(no)
34--
351.9.1
36
diff --git a/meta/recipes-devtools/opkg/opkg/0001-libopkg-include-stdio.h-for-getting-FILE-defined.patch b/meta/recipes-devtools/opkg/opkg/0001-libopkg-include-stdio.h-for-getting-FILE-defined.patch
deleted file mode 100644
index acc1338642..0000000000
--- a/meta/recipes-devtools/opkg/opkg/0001-libopkg-include-stdio.h-for-getting-FILE-defined.patch
+++ /dev/null
@@ -1,45 +0,0 @@
1From 58f4d3d63cd6097154205ea7ee042005036659b3 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 10 Sep 2015 21:43:32 -0700
4Subject: [PATCH] libopkg: include stdio.h for getting FILE defined
5To: opkg-devel@googlegroups.com
6Cc: paul@paulbarker.me.uk
7
8For some libc(musl) stdio.h may not get included indirectly which means
9we need to mention it in explicit include list
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13Upstream-Status: Submitted
14
15 libopkg/opkg_verify.c | 1 +
16 libopkg/pkg_src.c | 1 +
17 2 files changed, 2 insertions(+)
18
19diff --git a/libopkg/opkg_verify.c b/libopkg/opkg_verify.c
20index 41dc3f4..a71591d 100644
21--- a/libopkg/opkg_verify.c
22+++ b/libopkg/opkg_verify.c
23@@ -18,6 +18,7 @@
24
25 #include <malloc.h>
26 #include <string.h>
27+#include <stdio.h>
28
29 #include "file_util.h"
30 #include "opkg_conf.h"
31diff --git a/libopkg/pkg_src.c b/libopkg/pkg_src.c
32index e31ec21..6b49a00 100644
33--- a/libopkg/pkg_src.c
34+++ b/libopkg/pkg_src.c
35@@ -20,6 +20,7 @@
36
37 #include <malloc.h>
38 #include <unistd.h>
39+#include <stdio.h>
40
41 #include "file_util.h"
42 #include "opkg_conf.h"
43--
442.5.1
45
diff --git a/meta/recipes-devtools/opkg/opkg/0001-libsolv_solver_set_arch_policy-use-correct-logic-dur.patch b/meta/recipes-devtools/opkg/opkg/0001-libsolv_solver_set_arch_policy-use-correct-logic-dur.patch
new file mode 100644
index 0000000000..1ab1790d6a
--- /dev/null
+++ b/meta/recipes-devtools/opkg/opkg/0001-libsolv_solver_set_arch_policy-use-correct-logic-dur.patch
@@ -0,0 +1,35 @@
1From 3e562bed7dced25eb3e9174ca9395324b6c873c1 Mon Sep 17 00:00:00 2001
2From: Alejandro del Castillo <alejandro.delcastillo@ni.com>
3Date: Wed, 9 Dec 2015 13:36:14 -0600
4Subject: [PATCH] libsolv_solver_set_arch_policy: use correct logic during
5 archs resizing
6
7If there are more than INITIAL_ARCH_LIST_SIZE archs defined in the
8configuration, libsolv_solver_set_arch_policy crashes due to flawed
9logic when resizing the archs array.
10
11Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
12---
13 libopkg/opkg_solver_libsolv.c | 6 ++++--
14 1 file changed, 4 insertions(+), 2 deletions(-)
15
16diff --git a/libopkg/opkg_solver_libsolv.c b/libopkg/opkg_solver_libsolv.c
17index 1cdcf1f..b5af0fa 100644
18--- a/libopkg/opkg_solver_libsolv.c
19+++ b/libopkg/opkg_solver_libsolv.c
20@@ -66,8 +66,10 @@ static void libsolv_solver_set_arch_policy(libsolv_solver_t *libsolv_solver)
21 nv_pair_list_elt_t *arch_info;
22
23 list_for_each_entry(arch_info, &opkg_config->arch_list.head, node) {
24- if (arch_count > arch_list_size)
25- archs = xrealloc(archs, arch_list_size *= 2);
26+ if (arch_count >= arch_list_size) {
27+ arch_list_size *= 2;
28+ archs = xrealloc(archs, arch_list_size * sizeof(arch_data_t));
29+ }
30
31 archs[arch_count].arch = ((nv_pair_t *)(arch_info->data))->name;
32 archs[arch_count].priority = atoi(((nv_pair_t *)
33--
341.9.1
35
diff --git a/meta/recipes-devtools/opkg/opkg/0001-opkg_archive-add-support-for-empty-compressed-files.patch b/meta/recipes-devtools/opkg/opkg/0001-opkg_archive-add-support-for-empty-compressed-files.patch
deleted file mode 100644
index dabd196d2c..0000000000
--- a/meta/recipes-devtools/opkg/opkg/0001-opkg_archive-add-support-for-empty-compressed-files.patch
+++ /dev/null
@@ -1,64 +0,0 @@
1From bd32bb8646459508bb0b0ce54a14bd6fe0e19b75 Mon Sep 17 00:00:00 2001
2From: Alejandro del Castillo <alejandro.delcastillo@ni.com>
3Date: Thu, 27 Aug 2015 15:52:16 -0500
4Subject: [PATCH] opkg_archive: add support for empty compressed files
5
6Regression from 0.2.x: opkg used to support empty Package.gz files.
7
8Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
9
10Upstream-Status: Accepted
11---
12 libopkg/opkg_archive.c | 15 +++++++++++++--
13 1 file changed, 13 insertions(+), 2 deletions(-)
14
15diff --git a/libopkg/opkg_archive.c b/libopkg/opkg_archive.c
16index be903e4..7e91e48 100644
17--- a/libopkg/opkg_archive.c
18+++ b/libopkg/opkg_archive.c
19@@ -121,6 +121,9 @@ static int copy_to_stream(struct archive *a, FILE * stream)
20 int eof;
21 size_t len = EXTRACT_BUFFER_LEN;
22
23+ if (archive_format(a) == ARCHIVE_FORMAT_EMPTY)
24+ return 0;
25+
26 buffer = xmalloc(len);
27
28 while (1) {
29@@ -654,6 +657,13 @@ static struct archive *open_compressed_file(const char *filename)
30 goto err_cleanup;
31 }
32
33+ r = archive_read_support_format_empty(ar);
34+ if (r != ARCHIVE_OK) {
35+ opkg_msg(ERROR, "Empty format not supported: %s\n",
36+ archive_error_string(ar));
37+ goto err_cleanup;
38+ }
39+
40 /* Open input file and prepare for reading. */
41 r = archive_read_open_filename(ar, filename, EXTRACT_BUFFER_LEN);
42 if (r != ARCHIVE_OK) {
43@@ -723,6 +733,7 @@ struct opkg_ar *ar_open_compressed_file(const char *filename)
44 {
45 struct opkg_ar *ar;
46 struct archive_entry *entry;
47+ int eof;
48
49 ar = (struct opkg_ar *)xmalloc(sizeof(struct opkg_ar));
50
51@@ -737,8 +748,8 @@ struct opkg_ar *ar_open_compressed_file(const char *filename)
52 * header. We skip over this header here so that the caller doesn't need
53 * to know about it.
54 */
55- entry = read_header(ar->ar, NULL);
56- if (!entry)
57+ entry = read_header(ar->ar, &eof);
58+ if (!entry && !eof)
59 goto err_cleanup;
60
61 return ar;
62--
631.9.1
64
diff --git a/meta/recipes-devtools/opkg/opkg/0001-string_util-New-file-with-bin_to_hex-function.patch b/meta/recipes-devtools/opkg/opkg/0001-string_util-New-file-with-bin_to_hex-function.patch
deleted file mode 100644
index fb3ac462df..0000000000
--- a/meta/recipes-devtools/opkg/opkg/0001-string_util-New-file-with-bin_to_hex-function.patch
+++ /dev/null
@@ -1,122 +0,0 @@
1From 646b80024567a6245c598be3374653fa1fa09a12 Mon Sep 17 00:00:00 2001
2From: Paul Barker <paul@paulbarker.me.uk>
3Date: Sat, 7 Nov 2015 10:23:49 +0000
4Subject: [PATCH 1/4] string_util: New file with bin_to_hex function
5
6This function does very simple conversion from binary data to a hex string.
7
8Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
9Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
10
11Upstream-Status: Accepted
12---
13 libopkg/Makefile.am | 4 ++--
14 libopkg/string_util.c | 42 ++++++++++++++++++++++++++++++++++++++++++
15 libopkg/string_util.h | 24 ++++++++++++++++++++++++
16 3 files changed, 68 insertions(+), 2 deletions(-)
17 create mode 100644 libopkg/string_util.c
18 create mode 100644 libopkg/string_util.h
19
20diff --git a/libopkg/Makefile.am b/libopkg/Makefile.am
21index ee3fbee..3e62c24 100644
22--- a/libopkg/Makefile.am
23+++ b/libopkg/Makefile.am
24@@ -13,7 +13,7 @@ opkg_headers = active_list.h cksum_list.h conffile.h conffile_list.h \
25 pkg_depends.h pkg_dest.h pkg_dest_list.h pkg_extract.h pkg_hash.h \
26 pkg_parse.h pkg_src.h pkg_src_list.h pkg_vec.h release.h \
27 release_parse.h sha256.h sprintf_alloc.h str_list.h void_list.h \
28- xregex.h xsystem.h xfuncs.h opkg_verify.h
29+ xregex.h xsystem.h xfuncs.h opkg_verify.h string_util.h
30
31 opkg_sources = opkg_cmd.c opkg_configure.c opkg_download.c \
32 opkg_install.c opkg_remove.c opkg_conf.c release.c \
33@@ -23,7 +23,7 @@ opkg_sources = opkg_cmd.c opkg_configure.c opkg_download.c \
34 pkg_src.c pkg_src_list.c str_list.c void_list.c active_list.c \
35 file_util.c opkg_message.c md5.c parse_util.c cksum_list.c \
36 sprintf_alloc.c xregex.c xsystem.c xfuncs.c opkg_archive.c \
37- opkg_verify.c
38+ opkg_verify.c string_util.c
39
40 if HAVE_CURL
41 opkg_sources += opkg_download_curl.c
42diff --git a/libopkg/string_util.c b/libopkg/string_util.c
43new file mode 100644
44index 0000000..822cab6
45--- /dev/null
46+++ b/libopkg/string_util.c
47@@ -0,0 +1,42 @@
48+/* vi: set expandtab sw=4 sts=4: */
49+/* string_util.c - convenience routines for common string operations
50+
51+ Copyright (C) 2015 Paul Barker
52+
53+ This program is free software; you can redistribute it and/or
54+ modify it under the terms of the GNU General Public License as
55+ published by the Free Software Foundation; either version 2, or (at
56+ your option) any later version.
57+
58+ This program is distributed in the hope that it will be useful, but
59+ WITHOUT ANY WARRANTY; without even the implied warranty of
60+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
61+ General Public License for more details.
62+*/
63+
64+#include "config.h"
65+
66+#include "string_util.h"
67+#include "xfuncs.h"
68+
69+char *bin_to_hex(const void *bin_data, size_t len)
70+{
71+ const unsigned char *src = (const unsigned char *)bin_data;
72+ char *buf = xmalloc(2 * len + 1);
73+ int i;
74+
75+ static const unsigned char bin2hex[16] = {
76+ '0', '1', '2', '3',
77+ '4', '5', '6', '7',
78+ '8', '9', 'a', 'b',
79+ 'c', 'd', 'e', 'f'
80+ };
81+
82+ for (i = 0; i < len; i++) {
83+ buf[i * 2] = bin2hex[src[i] >> 4];
84+ buf[i * 2 + 1] = bin2hex[src[i] & 0xf];
85+ }
86+
87+ buf[len * 2] = '\0';
88+ return buf;
89+}
90diff --git a/libopkg/string_util.h b/libopkg/string_util.h
91new file mode 100644
92index 0000000..a920e2a
93--- /dev/null
94+++ b/libopkg/string_util.h
95@@ -0,0 +1,24 @@
96+/* vi: set expandtab sw=4 sts=4: */
97+/* string_util.h - convenience routines for common file operations
98+
99+ Copyright (C) 2015 Paul Barker
100+
101+ This program is free software; you can redistribute it and/or
102+ modify it under the terms of the GNU General Public License as
103+ published by the Free Software Foundation; either version 2, or (at
104+ your option) any later version.
105+
106+ This program is distributed in the hope that it will be useful, but
107+ WITHOUT ANY WARRANTY; without even the implied warranty of
108+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
109+ General Public License for more details.
110+*/
111+
112+#ifndef STRING_UTIL_H
113+#define STRING_UTIL_H
114+
115+#include <stddef.h>
116+
117+char *bin_to_hex(const void *bin_data, size_t len);
118+
119+#endif /* STRING_UTIL_H */
120--
1211.9.1
122
diff --git a/meta/recipes-devtools/opkg/opkg/0002-md5-Add-md5_to_string-function.patch b/meta/recipes-devtools/opkg/opkg/0002-md5-Add-md5_to_string-function.patch
deleted file mode 100644
index 3b823c693c..0000000000
--- a/meta/recipes-devtools/opkg/opkg/0002-md5-Add-md5_to_string-function.patch
+++ /dev/null
@@ -1,110 +0,0 @@
1From ecad8afab377d8be95eeaafc08afa228c8e030c3 Mon Sep 17 00:00:00 2001
2From: Paul Barker <paul@paulbarker.me.uk>
3Date: Sat, 7 Nov 2015 10:23:50 +0000
4Subject: [PATCH 2/4] md5: Add md5_to_string function
5
6Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
7Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
8
9Upstream-Status: Accepted
10---
11 libopkg/file_util.c | 28 +++-------------------------
12 libopkg/md5.c | 7 +++++++
13 libopkg/md5.h | 3 +++
14 3 files changed, 13 insertions(+), 25 deletions(-)
15
16diff --git a/libopkg/file_util.c b/libopkg/file_util.c
17index 5eff469..cb3dbf0 100644
18--- a/libopkg/file_util.c
19+++ b/libopkg/file_util.c
20@@ -349,27 +349,13 @@ int file_mkdir_hier(const char *path, long mode)
21
22 char *file_md5sum_alloc(const char *file_name)
23 {
24- static const int md5sum_bin_len = 16;
25- static const int md5sum_hex_len = 32;
26-
27- static const unsigned char bin2hex[16] = {
28- '0', '1', '2', '3',
29- '4', '5', '6', '7',
30- '8', '9', 'a', 'b',
31- 'c', 'd', 'e', 'f'
32- };
33-
34- int i, err;
35+ int err;
36 FILE *file;
37- char *md5sum_hex;
38- unsigned char md5sum_bin[md5sum_bin_len];
39-
40- md5sum_hex = xcalloc(1, md5sum_hex_len + 1);
41+ unsigned char md5sum_bin[16];
42
43 file = fopen(file_name, "r");
44 if (file == NULL) {
45 opkg_perror(ERROR, "Failed to open file %s", file_name);
46- free(md5sum_hex);
47 return NULL;
48 }
49
50@@ -377,20 +363,12 @@ char *file_md5sum_alloc(const char *file_name)
51 if (err) {
52 opkg_msg(ERROR, "Could't compute md5sum for %s.\n", file_name);
53 fclose(file);
54- free(md5sum_hex);
55 return NULL;
56 }
57
58 fclose(file);
59
60- for (i = 0; i < md5sum_bin_len; i++) {
61- md5sum_hex[i * 2] = bin2hex[md5sum_bin[i] >> 4];
62- md5sum_hex[i * 2 + 1] = bin2hex[md5sum_bin[i] & 0xf];
63- }
64-
65- md5sum_hex[md5sum_hex_len] = '\0';
66-
67- return md5sum_hex;
68+ return md5_to_string(md5sum_bin);
69 }
70
71 #ifdef HAVE_SHA256
72diff --git a/libopkg/md5.c b/libopkg/md5.c
73index d476b8b..bc2b229 100644
74--- a/libopkg/md5.c
75+++ b/libopkg/md5.c
76@@ -30,6 +30,8 @@
77 #include <string.h>
78 #include <sys/types.h>
79
80+#include "string_util.h"
81+
82 #if USE_UNLOCKED_IO
83 #include "unlocked-io.h"
84 #endif
85@@ -431,3 +433,8 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
86 ctx->C = C;
87 ctx->D = D;
88 }
89+
90+char *md5_to_string(const void *md5sum_bin)
91+{
92+ return bin_to_hex(md5sum_bin, 16);
93+}
94diff --git a/libopkg/md5.h b/libopkg/md5.h
95index 01320f5..2a7274d 100644
96--- a/libopkg/md5.h
97+++ b/libopkg/md5.h
98@@ -118,6 +118,9 @@ extern int __md5_stream(FILE * stream, void *resblock) __THROW;
99 extern void *__md5_buffer(const char *buffer, size_t len,
100 void *resblock) __THROW;
101
102+/* Convert a binary md5sum value to an ASCII string. */
103+char *md5_to_string(const void *md5sum_bin);
104+
105 #ifdef __cplusplus
106 }
107 #endif
108--
1091.9.1
110
diff --git a/meta/recipes-devtools/opkg/opkg/0003-sha256-Add-sha256_to_string-function.patch b/meta/recipes-devtools/opkg/opkg/0003-sha256-Add-sha256_to_string-function.patch
deleted file mode 100644
index 16e82d7417..0000000000
--- a/meta/recipes-devtools/opkg/opkg/0003-sha256-Add-sha256_to_string-function.patch
+++ /dev/null
@@ -1,110 +0,0 @@
1From 92e8378103bba3b91f2dec4e6fda3e1755a7c0fd Mon Sep 17 00:00:00 2001
2From: Paul Barker <paul@paulbarker.me.uk>
3Date: Sat, 7 Nov 2015 10:23:51 +0000
4Subject: [PATCH 3/4] sha256: Add sha256_to_string function
5
6Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
7Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
8
9Upstream-Status: Accepted
10---
11 libopkg/file_util.c | 28 +++-------------------------
12 libopkg/sha256.c | 7 +++++++
13 libopkg/sha256.h | 3 +++
14 3 files changed, 13 insertions(+), 25 deletions(-)
15
16diff --git a/libopkg/file_util.c b/libopkg/file_util.c
17index cb3dbf0..864aedb 100644
18--- a/libopkg/file_util.c
19+++ b/libopkg/file_util.c
20@@ -374,27 +374,13 @@ char *file_md5sum_alloc(const char *file_name)
21 #ifdef HAVE_SHA256
22 char *file_sha256sum_alloc(const char *file_name)
23 {
24- static const int sha256sum_bin_len = 32;
25- static const int sha256sum_hex_len = 64;
26-
27- static const unsigned char bin2hex[16] = {
28- '0', '1', '2', '3',
29- '4', '5', '6', '7',
30- '8', '9', 'a', 'b',
31- 'c', 'd', 'e', 'f'
32- };
33-
34- int i, err;
35+ int err;
36 FILE *file;
37- char *sha256sum_hex;
38- unsigned char sha256sum_bin[sha256sum_bin_len];
39-
40- sha256sum_hex = xcalloc(1, sha256sum_hex_len + 1);
41+ unsigned char sha256sum_bin[32];
42
43 file = fopen(file_name, "r");
44 if (file == NULL) {
45 opkg_perror(ERROR, "Failed to open file %s", file_name);
46- free(sha256sum_hex);
47 return NULL;
48 }
49
50@@ -402,20 +388,12 @@ char *file_sha256sum_alloc(const char *file_name)
51 if (err) {
52 opkg_msg(ERROR, "Could't compute sha256sum for %s.\n", file_name);
53 fclose(file);
54- free(sha256sum_hex);
55 return NULL;
56 }
57
58 fclose(file);
59
60- for (i = 0; i < sha256sum_bin_len; i++) {
61- sha256sum_hex[i * 2] = bin2hex[sha256sum_bin[i] >> 4];
62- sha256sum_hex[i * 2 + 1] = bin2hex[sha256sum_bin[i] & 0xf];
63- }
64-
65- sha256sum_hex[sha256sum_hex_len] = '\0';
66-
67- return sha256sum_hex;
68+ return sha256_to_string(sha256sum_bin);
69 }
70
71 #endif
72diff --git a/libopkg/sha256.c b/libopkg/sha256.c
73index 0816858..bceed72 100644
74--- a/libopkg/sha256.c
75+++ b/libopkg/sha256.c
76@@ -29,6 +29,8 @@
77 #include <stddef.h>
78 #include <string.h>
79
80+#include "string_util.h"
81+
82 #if USE_UNLOCKED_IO
83 #include "unlocked-io.h"
84 #endif
85@@ -517,3 +519,8 @@ void sha256_process_block(const void *buffer, size_t len,
86 h = ctx->state[7] += h;
87 }
88 }
89+
90+char *sha256_to_string(const void *sha256sum_bin)
91+{
92+ return bin_to_hex(sha256sum_bin, 32);
93+}
94diff --git a/libopkg/sha256.h b/libopkg/sha256.h
95index 734ab54..0d1e9e5 100644
96--- a/libopkg/sha256.h
97+++ b/libopkg/sha256.h
98@@ -85,6 +85,9 @@ extern int sha224_stream(FILE * stream, void *resblock);
99 extern void *sha256_buffer(const char *buffer, size_t len, void *resblock);
100 extern void *sha224_buffer(const char *buffer, size_t len, void *resblock);
101
102+/* Convert a binary sha256sum value to an ASCII string. */
103+char *sha256_to_string(const void *sha256sum_bin);
104+
105 #ifdef __cplusplus
106 }
107 #endif
108--
1091.9.1
110
diff --git a/meta/recipes-devtools/opkg/opkg/0004-opkg_download-Use-short-cache-file-name.patch b/meta/recipes-devtools/opkg/opkg/0004-opkg_download-Use-short-cache-file-name.patch
deleted file mode 100644
index 7ea661dcf6..0000000000
--- a/meta/recipes-devtools/opkg/opkg/0004-opkg_download-Use-short-cache-file-name.patch
+++ /dev/null
@@ -1,85 +0,0 @@
1From 61636f15718edc7ea17b91f22f1d97b905eaf951 Mon Sep 17 00:00:00 2001
2From: Paul Barker <paul@paulbarker.me.uk>
3Date: Sat, 7 Nov 2015 10:23:52 +0000
4Subject: [PATCH 4/4] opkg_download: Use short cache file name
5
6Source URIs can be very long. The cache directory itself may already have a very
7long path, especially if we're installing packages into an offline rootfs.
8Therefore it's not a good idea to simply tag the source URI onto the cache
9directory path to create a cache file name.
10
11To create shorter cache file names which are deterministic and very likely to be
12unique, we use the md5sum of the source URI along with the basename of the
13source URI. The basename is length limited to ensure that it the resulting
14filename length is always reasonable.
15
16Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
17Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
18
19Upstream-Status: Accepted
20---
21 libopkg/opkg_download.c | 35 ++++++++++++++++++++++++++++-------
22 1 file changed, 28 insertions(+), 7 deletions(-)
23
24diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c
25index e9b86a5..a37b10d 100644
26--- a/libopkg/opkg_download.c
27+++ b/libopkg/opkg_download.c
28@@ -29,10 +29,18 @@
29 #include "opkg_verify.h"
30 #include "opkg_utils.h"
31
32+#include "md5.h"
33 #include "sprintf_alloc.h"
34 #include "file_util.h"
35 #include "xfuncs.h"
36
37+/* Limit the short file name used to generate cache file names to 90 characters
38+ * so that when added to the md5sum (32 characters) and an underscore, the
39+ * resulting length is below 128 characters. The maximum file name length
40+ * differs between plaforms but 128 characters should be reasonable.
41+ */
42+#define MAX_SHORT_FILE_NAME_LENGTH 90
43+
44 static int opkg_download_set_env()
45 {
46 int r;
47@@ -135,15 +143,28 @@ int opkg_download_internal(const char *src, const char *dest,
48 */
49 char *get_cache_location(const char *src)
50 {
51- char *cache_name = xstrdup(src);
52- char *cache_location, *p;
53+ unsigned char md5sum_bin[16];
54+ char *md5sum_hex;
55+ char *cache_location;
56+ char *short_file_name;
57+ char *tmp = xstrdup(src);
58
59- for (p = cache_name; *p; p++)
60- if (*p == '/')
61- *p = '_';
62+ md5_buffer(src, strlen(src), md5sum_bin);
63+ md5sum_hex = md5_to_string(md5sum_bin);
64
65- sprintf_alloc(&cache_location, "%s/%s", opkg_config->cache_dir, cache_name);
66- free(cache_name);
67+ /* Generate a short file name which will be used along with an md5sum of the
68+ * full src URI in the cache file name. This short file name is limited to
69+ * MAX_SHORT_FILE_NAME_LENGTH to ensure that the total cache file name
70+ * length is reasonable.
71+ */
72+ short_file_name = basename(tmp);
73+ if (strlen(short_file_name) > MAX_SHORT_FILE_NAME_LENGTH)
74+ short_file_name[MAX_SHORT_FILE_NAME_LENGTH] = '\0';
75+
76+ sprintf_alloc(&cache_location, "%s/%s_%s", opkg_config->cache_dir,
77+ md5sum_hex, short_file_name);
78+ free(md5sum_hex);
79+ free(tmp);
80 return cache_location;
81 }
82
83--
841.9.1
85
diff --git a/meta/recipes-devtools/opkg/opkg_0.3.0.bb b/meta/recipes-devtools/opkg/opkg_0.3.1.bb
index 5ad3e92cff..577f495344 100644
--- a/meta/recipes-devtools/opkg/opkg_0.3.0.bb
+++ b/meta/recipes-devtools/opkg/opkg_0.3.1.bb
@@ -14,17 +14,13 @@ PE = "1"
14SRC_URI = "http://downloads.yoctoproject.org/releases/${BPN}/${BPN}-${PV}.tar.gz \ 14SRC_URI = "http://downloads.yoctoproject.org/releases/${BPN}/${BPN}-${PV}.tar.gz \
15 file://opkg-configure.service \ 15 file://opkg-configure.service \
16 file://opkg.conf \ 16 file://opkg.conf \
17 file://0001-opkg_archive-add-support-for-empty-compressed-files.patch \
18 file://0001-libopkg-include-stdio.h-for-getting-FILE-defined.patch \
19 file://0001-opkg_conf-create-opkg.lock-in-run-instead-of-var-run.patch \ 17 file://0001-opkg_conf-create-opkg.lock-in-run-instead-of-var-run.patch \
20 file://0001-string_util-New-file-with-bin_to_hex-function.patch \ 18 file://0001-libsolv_solver_set_arch_policy-use-correct-logic-dur.patch \
21 file://0002-md5-Add-md5_to_string-function.patch \ 19 file://0001-configure.ac-use-pkg-config-for-libsolv.patch \
22 file://0003-sha256-Add-sha256_to_string-function.patch \
23 file://0004-opkg_download-Use-short-cache-file-name.patch \
24" 20"
25 21
26SRC_URI[md5sum] = "3412cdc71d78b98facc84b19331ec64e" 22SRC_URI[md5sum] = "43735e5dc1ebf46bd6ce56a7cdfdc720"
27SRC_URI[sha256sum] = "7f735d1cdb8ef3718fb0f9fba44ca0d9a5c90d3a7f014f37a6d2f9474f54988f" 23SRC_URI[sha256sum] = "d2c6c02a8384ec21168a1f0a186cb5e9f577d1452f491d02ed3e56b2ea8b87df"
28 24
29inherit autotools pkgconfig systemd 25inherit autotools pkgconfig systemd
30 26
@@ -41,6 +37,7 @@ PACKAGECONFIG[ssl-curl] = "--enable-ssl-curl,--disable-ssl-curl,curl openssl"
41PACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl" 37PACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl"
42PACKAGECONFIG[sha256] = "--enable-sha256,--disable-sha256" 38PACKAGECONFIG[sha256] = "--enable-sha256,--disable-sha256"
43PACKAGECONFIG[pathfinder] = "--enable-pathfinder,--disable-pathfinder,pathfinder" 39PACKAGECONFIG[pathfinder] = "--enable-pathfinder,--disable-pathfinder,pathfinder"
40PACKAGECONFIG[libsolv] = "--enable-solver=libsolv,--disable-solver,libsolv"
44 41
45do_install_append () { 42do_install_append () {
46 install -d ${D}${sysconfdir}/opkg 43 install -d ${D}${sysconfdir}/opkg