aboutsummaryrefslogtreecommitdiffstats
path: root/package/system/opkg/patches
diff options
context:
space:
mode:
Diffstat (limited to 'package/system/opkg/patches')
-rw-r--r--package/system/opkg/patches/001-ship-pkg-m4.patch168
-rw-r--r--package/system/opkg/patches/002-no-shave.patch37
-rw-r--r--package/system/opkg/patches/004-host_cpu.patch20
-rw-r--r--package/system/opkg/patches/007-force_static.patch71
-rw-r--r--package/system/opkg/patches/009-remove-upgrade-all.patch41
-rw-r--r--package/system/opkg/patches/011-old-config-location.patch12
-rw-r--r--package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch23
-rw-r--r--package/system/opkg/patches/014-errors-to-stderr.patch15
-rw-r--r--package/system/opkg/patches/020-avoid_getline.patch317
-rw-r--r--package/system/opkg/patches/030-fix-double-free.patch10
-rw-r--r--package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch31
-rw-r--r--package/system/opkg/patches/050-add-case-insensitive-flag.patch169
-rw-r--r--package/system/opkg/patches/060-add-find-command.patch58
-rw-r--r--package/system/opkg/patches/070-use_gzipped_pkg_list.patch120
-rw-r--r--package/system/opkg/patches/080-suppress-blank-package-fields.patch16
-rw-r--r--package/system/opkg/patches/090-suppress-blank-provides-field.patch11
-rw-r--r--package/system/opkg/patches/100-add-force-checksum.patch85
-rw-r--r--package/system/opkg/patches/110-upgrade.patch49
-rw-r--r--package/system/opkg/patches/200-usign_support.patch91
-rw-r--r--package/system/opkg/patches/210-add-force-signature.patch70
-rw-r--r--package/system/opkg/patches/220-drop-release-support.patch812
-rw-r--r--package/system/opkg/patches/230-drop_md5_support.patch161
-rw-r--r--package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch31
-rw-r--r--package/system/opkg/patches/250-add-lists-dir-switch.patch39
-rw-r--r--package/system/opkg/patches/260-add-print-package-size.patch74
25 files changed, 2531 insertions, 0 deletions
diff --git a/package/system/opkg/patches/001-ship-pkg-m4.patch b/package/system/opkg/patches/001-ship-pkg-m4.patch
new file mode 100644
index 0000000..4ca0f88
--- /dev/null
+++ b/package/system/opkg/patches/001-ship-pkg-m4.patch
@@ -0,0 +1,168 @@
+--- /dev/null
++++ b/m4/pkg.m4
+@@ -0,0 +1,157 @@
++# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
++#
++# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful, but
++# WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++# General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++#
++# As a special exception to the GNU General Public License, if you
++# distribute this file as part of a program that contains a
++# configuration script generated by Autoconf, you may include it under
++# the same distribution terms that you use for the rest of that program.
++
++# PKG_PROG_PKG_CONFIG([MIN-VERSION])
++# ----------------------------------
++AC_DEFUN([PKG_PROG_PKG_CONFIG],
++[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
++m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
++AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
++ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
++fi
++if test -n "$PKG_CONFIG"; then
++ _pkg_min_version=m4_default([$1], [0.9.0])
++ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
++ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
++ AC_MSG_RESULT([yes])
++ else
++ AC_MSG_RESULT([no])
++ PKG_CONFIG=""
++ fi
++
++fi[]dnl
++])# PKG_PROG_PKG_CONFIG
++
++# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
++#
++# Check to see whether a particular set of modules exists. Similar
++# to PKG_CHECK_MODULES(), but does not set variables or print errors.
++#
++#
++# Similar to PKG_CHECK_MODULES, make sure that the first instance of
++# this or PKG_CHECK_MODULES is called, or make sure to call
++# PKG_CHECK_EXISTS manually
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_EXISTS],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++if test -n "$PKG_CONFIG" && \
++ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
++ m4_ifval([$2], [$2], [:])
++m4_ifvaln([$3], [else
++ $3])dnl
++fi])
++
++
++# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
++# ---------------------------------------------
++m4_define([_PKG_CONFIG],
++[if test -n "$PKG_CONFIG"; then
++ if test -n "$$1"; then
++ pkg_cv_[]$1="$$1"
++ else
++ PKG_CHECK_EXISTS([$3],
++ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
++ [pkg_failed=yes])
++ fi
++else
++ pkg_failed=untried
++fi[]dnl
++])# _PKG_CONFIG
++
++# _PKG_SHORT_ERRORS_SUPPORTED
++# -----------------------------
++AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
++ _pkg_short_errors_supported=yes
++else
++ _pkg_short_errors_supported=no
++fi[]dnl
++])# _PKG_SHORT_ERRORS_SUPPORTED
++
++
++# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
++# [ACTION-IF-NOT-FOUND])
++#
++#
++# Note that if there is a possibility the first call to
++# PKG_CHECK_MODULES might not happen, you should be sure to include an
++# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
++#
++#
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_MODULES],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
++AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
++
++pkg_failed=no
++AC_MSG_CHECKING([for $1])
++
++_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
++_PKG_CONFIG([$1][_LIBS], [libs], [$2])
++
++m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
++and $1[]_LIBS to avoid the need to call pkg-config.
++See the pkg-config man page for more details.])
++
++if test $pkg_failed = yes; then
++ _PKG_SHORT_ERRORS_SUPPORTED
++ if test $_pkg_short_errors_supported = yes; then
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
++ else
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
++ fi
++ # Put the nasty error message in config.log where it belongs
++ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
++
++ ifelse([$4], , [AC_MSG_ERROR(dnl
++[Package requirements ($2) were not met:
++
++$$1_PKG_ERRORS
++
++Consider adjusting the PKG_CONFIG_PATH environment variable if you
++installed software in a non-standard prefix.
++
++_PKG_TEXT
++])],
++ [AC_MSG_RESULT([no])
++ $4])
++elif test $pkg_failed = untried; then
++ ifelse([$4], , [AC_MSG_FAILURE(dnl
++[The pkg-config script could not be found or is too old. Make sure it
++is in your PATH or set the PKG_CONFIG environment variable to the full
++path to pkg-config.
++
++_PKG_TEXT
++
++To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
++ [$4])
++else
++ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
++ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
++ AC_MSG_RESULT([yes])
++ ifelse([$3], , :, [$3])
++fi[]dnl
++])# PKG_CHECK_MODULES
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-ACLOCAL_AMFLAGS = -I shave
++ACLOCAL_AMFLAGS = -I shave -I m4
+
+ SUBDIRS = libbb libopkg src tests utils man
+
diff --git a/package/system/opkg/patches/002-no-shave.patch b/package/system/opkg/patches/002-no-shave.patch
new file mode 100644
index 0000000..313aa71
--- /dev/null
+++ b/package/system/opkg/patches/002-no-shave.patch
@@ -0,0 +1,37 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -4,7 +4,6 @@ AC_CONFIG_SRCDIR([libopkg/pkg.c])
+
+ AC_CONFIG_AUX_DIR([conf])
+ AC_CONFIG_MACRO_DIR([m4])
+-AC_CONFIG_MACRO_DIR([shave])
+
+ AM_INIT_AUTOMAKE
+ AM_CONFIG_HEADER(libopkg/config.h)
+@@ -277,9 +276,6 @@ AC_SUBST(opkgetcdir)
+ AC_SUBST(opkglockfile)
+ AC_SUBST([CLEAN_DATE])
+
+-# Setup output beautifier.
+-SHAVE_INIT([shave], [enable])
+-
+ AC_OUTPUT(
+ Makefile
+ libopkg/Makefile
+@@ -289,8 +285,6 @@ AC_OUTPUT(
+ utils/Makefile
+ utils/update-alternatives
+ libopkg.pc
+- shave/shave
+- shave/shave-libtool
+ man/Makefile
+ man/opkg-cl.1
+ man/opkg-key.1
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-ACLOCAL_AMFLAGS = -I shave -I m4
++ACLOCAL_AMFLAGS = -I m4
+
+ SUBDIRS = libbb libopkg src tests utils man
+
diff --git a/package/system/opkg/patches/004-host_cpu.patch b/package/system/opkg/patches/004-host_cpu.patch
new file mode 100644
index 0000000..d500d60
--- /dev/null
+++ b/package/system/opkg/patches/004-host_cpu.patch
@@ -0,0 +1,20 @@
+--- a/libbb/Makefile.am
++++ b/libbb/Makefile.am
+@@ -1,6 +1,6 @@
+ HOST_CPU=@host_cpu@
+ BUILD_CPU=@build_cpu@
+-ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@
++ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@
+
+ noinst_LTLIBRARIES = libbb.la
+
+--- a/libopkg/Makefile.am
++++ b/libopkg/Makefile.am
+@@ -1,5 +1,5 @@
+-
+-AM_CFLAGS=-Wall -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DOPKGLOCKFILE=\"@opkglockfile@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) $(PATHFINDER_CFLAGS)
++HOST_CPU=@host_cpu@
++AM_CFLAGS=-Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DOPKGLOCKFILE=\"@opkglockfile@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) $(PATHFINDER_CFLAGS)
+
+ libopkg_includedir=$(includedir)/libopkg
+ libopkg_include_HEADERS= *.h
diff --git a/package/system/opkg/patches/007-force_static.patch b/package/system/opkg/patches/007-force_static.patch
new file mode 100644
index 0000000..38cdb7a
--- /dev/null
+++ b/package/system/opkg/patches/007-force_static.patch
@@ -0,0 +1,71 @@
+--- a/libopkg/Makefile.am
++++ b/libopkg/Makefile.am
+@@ -38,16 +38,10 @@
+ opkg_util_sources += sha256.c sha256.h
+ endif
+
+-lib_LTLIBRARIES = libopkg.la
+-libopkg_la_SOURCES = \
++noinst_LIBRARIES = libopkg.a
++libopkg_a_SOURCES = \
+ $(opkg_libcore_sources) \
+ $(opkg_cmd_sources) $(opkg_db_sources) \
+ $(opkg_util_sources) $(opkg_list_sources)
+
+-libopkg_la_LIBADD = $(top_builddir)/libbb/libbb.la $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
+-
+-# make sure we only export symbols that are for public use
+-#libopkg_la_LDFLAGS = -export-symbols-regex "^opkg_.*"
+-
+-
+-
++libopkg_a_LIBADD = $(top_builddir)/libbb/libbb.a
+--- a/libbb/Makefile.am
++++ b/libbb/Makefile.am
+@@ -2,9 +2,9 @@
+ BUILD_CPU=@build_cpu@
+ ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@
+
+-noinst_LTLIBRARIES = libbb.la
++noinst_LIBRARIES = libbb.a
+
+-libbb_la_SOURCES = gz_open.c \
++libbb_a_SOURCES = gz_open.c \
+ libbb.h \
+ unzip.c \
+ wfopen.c \
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -4,11 +4,11 @@
+ #noinst_PROGRAMS = libopkg_test opkg_active_list_test
+ noinst_PROGRAMS = libopkg_test
+
+-#opkg_hash_test_LDADD = $(top_builddir)/libbb/libbb.la $(top_builddir)/libopkg/libopkg.la
++#opkg_hash_test_LDADD = $(top_builddir)/libbb/libbb.a $(top_builddir)/libopkg/libopkg.a
+ #opkg_hash_test_SOURCES = opkg_hash_test.c
+ #opkg_hash_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+-#opkg_extract_test_LDADD = $(top_builddir)/libbb/libbb.la $(top_builddir)/libopkg/libopkg.la
++#opkg_extract_test_LDADD = $(top_builddir)/libbb/libbb.a $(top_builddir)/libopkg/libopkg.a
+ #opkg_extract_test_SOURCES = opkg_extract_test.c
+ #opkg_extract_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+@@ -16,7 +16,7 @@
+ #opkg_active_list_test_SOURCES = opkg_active_list_test.c
+ #opkg_active_list_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+-libopkg_test_LDADD = $(top_builddir)/libopkg/libopkg.la
++libopkg_test_LDADD = $(top_builddir)/libopkg/libopkg.a $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
+ libopkg_test_SOURCE = libopkg_test.c
+ libopkg_test_LDFLAGS = -static
+
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -2,5 +2,5 @@
+ bin_PROGRAMS = opkg-cl
+
+ opkg_cl_SOURCES = opkg-cl.c
+-opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.la \
+- $(top_builddir)/libbb/libbb.la
++opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.a \
++ $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
diff --git a/package/system/opkg/patches/009-remove-upgrade-all.patch b/package/system/opkg/patches/009-remove-upgrade-all.patch
new file mode 100644
index 0000000..395a2a6
--- /dev/null
+++ b/package/system/opkg/patches/009-remove-upgrade-all.patch
@@ -0,0 +1,41 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -551,18 +551,6 @@ opkg_upgrade_cmd(int argc, char **argv)
+ err = -1;
+ }
+ }
+- } else {
+- pkg_vec_t *installed = pkg_vec_alloc();
+-
+- pkg_info_preinstall_check();
+-
+- pkg_hash_fetch_all_installed(installed);
+- for (i = 0; i < installed->len; i++) {
+- pkg = installed->pkgs[i];
+- if (opkg_upgrade_pkg(pkg))
+- err = -1;
+- }
+- pkg_vec_free(installed);
+ }
+
+ if (opkg_configure_packages(NULL))
+@@ -1258,7 +1246,7 @@ opkg_print_architecture_cmd(int argc, ch
+ array for easier maintenance */
+ static opkg_cmd_t cmds[] = {
+ {"update", 0, (opkg_cmd_fun_t)opkg_update_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+- {"upgrade", 0, (opkg_cmd_fun_t)opkg_upgrade_cmd, PFM_DESCRIPTION|PFM_SOURCE},
++ {"upgrade", 1, (opkg_cmd_fun_t)opkg_upgrade_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"list", 0, (opkg_cmd_fun_t)opkg_list_cmd, PFM_SOURCE},
+ {"list_installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd, PFM_SOURCE},
+ {"list-installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd, PFM_SOURCE},
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -221,7 +221,7 @@ usage()
+
+ printf("\nPackage Manipulation:\n");
+ printf("\tupdate Update list of available packages\n");
+- printf("\tupgrade Upgrade installed packages\n");
++ printf("\tupgrade <pkgs> Upgrade packages\n");
+ printf("\tinstall <pkgs> Install package(s)\n");
+ printf("\tconfigure <pkgs> Configure unpacked package(s)\n");
+ printf("\tremove <pkgs|regexp> Remove package(s)\n");
diff --git a/package/system/opkg/patches/011-old-config-location.patch b/package/system/opkg/patches/011-old-config-location.patch
new file mode 100644
index 0000000..0555926
--- /dev/null
+++ b/package/system/opkg/patches/011-old-config-location.patch
@@ -0,0 +1,12 @@
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -207,6 +207,9 @@ args_parse(int argc, char *argv[])
+ }
+ }
+
++ if(!conf->conf_file && !conf->offline_root)
++ conf->conf_file = xstrdup("/etc/opkg.conf");
++
+ if (parse_err)
+ return parse_err;
+ else
diff --git a/package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch b/package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch
new file mode 100644
index 0000000..a47ae77
--- /dev/null
+++ b/package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch
@@ -0,0 +1,23 @@
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -274,6 +274,7 @@ unpack_pkg_control_files(pkg_t *pkg)
+ while (1) {
+ char *cf_name;
+ char *cf_name_in_dest;
++ int i;
+
+ cf_name = file_read_line_alloc(conffiles_file);
+ if (cf_name == NULL) {
+@@ -282,6 +283,12 @@ unpack_pkg_control_files(pkg_t *pkg)
+ if (cf_name[0] == '\0') {
+ continue;
+ }
++ for (i = strlen(cf_name) - 1;
++ (i >= 0) && (cf_name[i] == ' ' || cf_name[i] == '\t');
++ i--
++ ) {
++ cf_name[i] = '\0';
++ }
+
+ /* Prepend dest->root_dir to conffile name.
+ Take pains to avoid multiple slashes. */
diff --git a/package/system/opkg/patches/014-errors-to-stderr.patch b/package/system/opkg/patches/014-errors-to-stderr.patch
new file mode 100644
index 0000000..f0a93a8
--- /dev/null
+++ b/package/system/opkg/patches/014-errors-to-stderr.patch
@@ -0,0 +1,15 @@
+--- a/libopkg/opkg_message.c
++++ b/libopkg/opkg_message.c
+@@ -64,10 +64,10 @@ print_error_list(void)
+ struct errlist *err = error_list_head;
+
+ if (err) {
+- printf("Collected errors:\n");
++ fprintf(stderr, "Collected errors:\n");
+ /* Here we print the errors collected and free the list */
+ while (err != NULL) {
+- printf(" * %s", err->errmsg);
++ fprintf(stderr, " * %s", err->errmsg);
+ err = err->next;
+ }
+ }
diff --git a/package/system/opkg/patches/020-avoid_getline.patch b/package/system/opkg/patches/020-avoid_getline.patch
new file mode 100644
index 0000000..8a1a8f6
--- /dev/null
+++ b/package/system/opkg/patches/020-avoid_getline.patch
@@ -0,0 +1,317 @@
+--- a/libopkg/parse_util.c
++++ b/libopkg/parse_util.c
+@@ -22,6 +22,7 @@
+ #include "libbb/libbb.h"
+
+ #include "parse_util.h"
++#include "pkg_parse.h"
+
+ int
+ is_field(const char *type, const char *line)
+@@ -86,3 +87,84 @@ parse_list(const char *raw, unsigned int
+ *count = line_count;
+ return depends;
+ }
++
++int
++parse_from_stream_nomalloc(parse_line_t parse_line, void *item, FILE *fp, uint mask,
++ char **buf0, size_t buf0len)
++{
++ int ret, lineno;
++ char *buf, *nl;
++ size_t buflen;
++
++ lineno = 1;
++ ret = 0;
++
++ buflen = buf0len;
++ buf = *buf0;
++ buf[0] = '\0';
++
++ while (1) {
++ if (fgets(buf, (int)buflen, fp) == NULL) {
++ if (ferror(fp)) {
++ opkg_perror(ERROR, "fgets");
++ ret = -1;
++ } else if (strlen(*buf0) == buf0len-1) {
++ opkg_msg(ERROR, "Missing new line character"
++ " at end of file!\n");
++ parse_line(item, *buf0, mask);
++ }
++ break;
++ }
++
++ nl = strchr(buf, '\n');
++ if (nl == NULL) {
++ if (strlen(buf) < buflen-1) {
++ /*
++ * Line could be exactly buflen-1 long and
++ * missing a newline, but we won't know until
++ * fgets fails to read more data.
++ */
++ opkg_msg(ERROR, "Missing new line character"
++ " at end of file!\n");
++ parse_line(item, *buf0, mask);
++ break;
++ }
++ if (buf0len >= EXCESSIVE_LINE_LEN) {
++ opkg_msg(ERROR, "Excessively long line at "
++ "%d. Corrupt file?\n",
++ lineno);
++ ret = -1;
++ break;
++ }
++
++ /*
++ * Realloc and point buf past the data already read,
++ * at the NULL terminator inserted by fgets.
++ * |<--------------- buf0len ----------------->|
++ * | |<------- buflen ---->|
++ * |---------------------|---------------------|
++ * buf0 buf
++ */
++ buflen = buf0len +1;
++ buf0len *= 2;
++ *buf0 = xrealloc(*buf0, buf0len);
++ buf = *buf0 + buflen -2;
++
++ continue;
++ }
++
++ *nl = '\0';
++
++ lineno++;
++
++ if (parse_line(item, *buf0, mask))
++ break;
++
++ buf = *buf0;
++ buflen = buf0len;
++ buf[0] = '\0';
++ }
++
++ return ret;
++}
++
+--- a/libopkg/parse_util.h
++++ b/libopkg/parse_util.h
+@@ -22,4 +22,8 @@ int is_field(const char *type, const cha
+ char *parse_simple(const char *type, const char *line);
+ char **parse_list(const char *raw, unsigned int *count, const char sep, int skip_field);
+
++typedef int (*parse_line_t)(void *, const char *, uint);
++int parse_from_stream_nomalloc(parse_line_t parse_line, void *item, FILE *fp, uint mask,
++ char **buf0, size_t buf0len);
++
+ #endif
+--- a/libopkg/pkg_hash.c
++++ b/libopkg/pkg_hash.c
+@@ -23,6 +23,7 @@
+ #include "opkg_message.h"
+ #include "pkg_vec.h"
+ #include "pkg_hash.h"
++#include "parse_util.h"
+ #include "pkg_parse.h"
+ #include "opkg_utils.h"
+ #include "sprintf_alloc.h"
+@@ -119,8 +120,14 @@ pkg_hash_add_from_file(const char *file_
+ pkg->src = src;
+ pkg->dest = dest;
+
+- ret = pkg_parse_from_stream_nomalloc(pkg, fp, 0,
++ ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, 0,
+ &buf, len);
++
++ if (pkg->name == NULL) {
++ /* probably just a blank line */
++ ret = 1;
++ }
++
+ if (ret) {
+ pkg_deinit (pkg);
+ free(pkg);
+--- a/libopkg/pkg_parse.c
++++ b/libopkg/pkg_parse.c
+@@ -104,9 +104,11 @@ get_arch_priority(const char *arch)
+ return 0;
+ }
+
+-static int
+-pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
++int
++pkg_parse_line(void *ptr, const char *line, uint mask)
+ {
++ pkg_t *pkg = (pkg_t *) ptr;
++
+ /* these flags are a bit hackish... */
+ static int reading_conffiles = 0, reading_description = 0;
+ int ret = 0;
+@@ -266,91 +268,6 @@ dont_reset_flags:
+ }
+
+ int
+-pkg_parse_from_stream_nomalloc(pkg_t *pkg, FILE *fp, uint mask,
+- char **buf0, size_t buf0len)
+-{
+- int ret, lineno;
+- char *buf, *nl;
+- size_t buflen;
+-
+- lineno = 1;
+- ret = 0;
+-
+- buflen = buf0len;
+- buf = *buf0;
+- buf[0] = '\0';
+-
+- while (1) {
+- if (fgets(buf, (int)buflen, fp) == NULL) {
+- if (ferror(fp)) {
+- opkg_perror(ERROR, "fgets");
+- ret = -1;
+- } else if (strlen(*buf0) == buf0len-1) {
+- opkg_msg(ERROR, "Missing new line character"
+- " at end of file!\n");
+- pkg_parse_line(pkg, *buf0, mask);
+- }
+- break;
+- }
+-
+- nl = strchr(buf, '\n');
+- if (nl == NULL) {
+- if (strlen(buf) < buflen-1) {
+- /*
+- * Line could be exactly buflen-1 long and
+- * missing a newline, but we won't know until
+- * fgets fails to read more data.
+- */
+- opkg_msg(ERROR, "Missing new line character"
+- " at end of file!\n");
+- pkg_parse_line(pkg, *buf0, mask);
+- break;
+- }
+- if (buf0len >= EXCESSIVE_LINE_LEN) {
+- opkg_msg(ERROR, "Excessively long line at "
+- "%d. Corrupt file?\n",
+- lineno);
+- ret = -1;
+- break;
+- }
+-
+- /*
+- * Realloc and point buf past the data already read,
+- * at the NULL terminator inserted by fgets.
+- * |<--------------- buf0len ----------------->|
+- * | |<------- buflen ---->|
+- * |---------------------|---------------------|
+- * buf0 buf
+- */
+- buflen = buf0len +1;
+- buf0len *= 2;
+- *buf0 = xrealloc(*buf0, buf0len);
+- buf = *buf0 + buflen -2;
+-
+- continue;
+- }
+-
+- *nl = '\0';
+-
+- lineno++;
+-
+- if (pkg_parse_line(pkg, *buf0, mask))
+- break;
+-
+- buf = *buf0;
+- buflen = buf0len;
+- buf[0] = '\0';
+- }
+-
+- if (pkg->name == NULL) {
+- /* probably just a blank line */
+- ret = 1;
+- }
+-
+- return ret;
+-}
+-
+-int
+ pkg_parse_from_stream(pkg_t *pkg, FILE *fp, uint mask)
+ {
+ int ret;
+@@ -358,8 +275,13 @@ pkg_parse_from_stream(pkg_t *pkg, FILE *
+ const size_t len = 4096;
+
+ buf = xmalloc(len);
+- ret = pkg_parse_from_stream_nomalloc(pkg, fp, mask, &buf, len);
++ ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, mask, &buf, len);
+ free(buf);
+
++ if (pkg->name == NULL) {
++ /* probably just a blank line */
++ ret = 1;
++ }
++
+ return ret;
+ }
+--- a/libopkg/pkg_parse.h
++++ b/libopkg/pkg_parse.h
+@@ -18,10 +18,11 @@
+ #ifndef PKG_PARSE_H
+ #define PKG_PARSE_H
+
++#include "pkg.h"
++
+ int parse_version(pkg_t *pkg, const char *raw);
+ int pkg_parse_from_stream(pkg_t *pkg, FILE *fp, uint mask);
+-int pkg_parse_from_stream_nomalloc(pkg_t *pkg, FILE *fp, uint mask,
+- char **buf0, size_t buf0len);
++int pkg_parse_line(void *ptr, const char *line, uint mask);
+
+ #define EXCESSIVE_LINE_LEN (4096 << 8)
+
+--- a/libopkg/release_parse.c
++++ b/libopkg/release_parse.c
+@@ -23,8 +23,10 @@
+ #include "parse_util.h"
+
+ static int
+-release_parse_line(release_t *release, const char *line)
++release_parse_line(void *ptr, const char *line, uint mask)
+ {
++ release_t *release = (release_t *) ptr;
++
+ int ret = 0;
+ unsigned int count = 0;
+ char **list = 0;
+@@ -111,25 +113,14 @@ dont_reset_flags:
+ int
+ release_parse_from_stream(release_t *release, FILE *fp)
+ {
+- int ret = 0;
+- char *buf = NULL;
+- size_t buflen, nread;
+-
+- nread = getline(&buf, &buflen, fp);
+- while ( nread != -1 ) {
+- if (buf[nread-1] == '\n') buf[nread-1] = '\0';
+- if (release_parse_line(release, buf))
+- opkg_msg(DEBUG, "Failed to parse release line for %s:\n\t%s\n",
+- release->name, buf);
+- nread = getline(&buf, &buflen, fp);
+- }
+-
+- if (!feof(fp)) {
+- opkg_perror(ERROR, "Problems reading Release file for %sd\n", release->name);
+- ret = -1;
+- }
++ int ret;
++ char *buf;
++ const size_t len = 4096;
+
++ buf = xmalloc(len);
++ ret = parse_from_stream_nomalloc(release_parse_line, release, fp, 0, &buf, len);
+ free(buf);
++
+ return ret;
+ }
+
diff --git a/package/system/opkg/patches/030-fix-double-free.patch b/package/system/opkg/patches/030-fix-double-free.patch
new file mode 100644
index 0000000..312e06c
--- /dev/null
+++ b/package/system/opkg/patches/030-fix-double-free.patch
@@ -0,0 +1,10 @@
+--- a/libopkg/opkg_remove.c
++++ b/libopkg/opkg_remove.c
+@@ -138,7 +138,6 @@ opkg_remove_dependent_pkgs(pkg_t *pkg, a
+ for (i = 0; i < dependent_pkgs->len; i++) {
+ err = opkg_remove_pkg(dependent_pkgs->pkgs[i],0);
+ if (err) {
+- pkg_vec_free(dependent_pkgs);
+ break;
+ }
+ }
diff --git a/package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch b/package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch
new file mode 100644
index 0000000..9540668
--- /dev/null
+++ b/package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch
@@ -0,0 +1,31 @@
+--- a/libopkg/pkg_parse.c
++++ b/libopkg/pkg_parse.c
+@@ -20,6 +20,7 @@
+
+ #include <stdio.h>
+ #include <ctype.h>
++#include <unistd.h>
+
+ #include "pkg.h"
+ #include "opkg_utils.h"
+@@ -239,10 +240,16 @@ pkg_parse_line(void *ptr, const char *li
+
+ case ' ':
+ if ((mask & PFM_DESCRIPTION) && reading_description) {
+- pkg->description = xrealloc(pkg->description,
+- strlen(pkg->description)
+- + 1 + strlen(line) + 1);
+- strcat(pkg->description, "\n");
++ if (isatty(1)) {
++ pkg->description = xrealloc(pkg->description,
++ strlen(pkg->description)
++ + 1 + strlen(line) + 1);
++ strcat(pkg->description, "\n");
++ } else {
++ pkg->description = xrealloc(pkg->description,
++ strlen(pkg->description)
++ + 1 + strlen(line));
++ }
+ strcat(pkg->description, (line));
+ goto dont_reset_flags;
+ } else if ((mask & PFM_CONFFILES) && reading_conffiles) {
diff --git a/package/system/opkg/patches/050-add-case-insensitive-flag.patch b/package/system/opkg/patches/050-add-case-insensitive-flag.patch
new file mode 100644
index 0000000..4b9215b
--- /dev/null
+++ b/package/system/opkg/patches/050-add-case-insensitive-flag.patch
@@ -0,0 +1,169 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -436,7 +436,7 @@ opkg_configure_packages(char *pkg_name)
+ for(i = 0; i < ordered->len; i++) {
+ pkg = ordered->pkgs[i];
+
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+
+ if (pkg->state_status == SS_UNPACKED) {
+@@ -610,7 +610,7 @@ opkg_list_cmd(int argc, char **argv)
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -637,7 +637,7 @@ opkg_list_installed_cmd(int argc, char *
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -666,7 +666,7 @@ opkg_list_changed_conffiles_cmd(int argc
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ if (nv_pair_list_empty(&pkg->conffiles))
+ continue;
+@@ -722,7 +722,7 @@ opkg_info_status_cmd(int argc, char **ar
+
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase)) {
+ continue;
+ }
+
+@@ -792,7 +792,7 @@ opkg_remove_cmd(int argc, char **argv)
+ for (i=0; i<argc; i++) {
+ for (a=0; a<available->len; a++) {
+ pkg = available->pkgs[a];
+- if (fnmatch(argv[i], pkg->name, 0)) {
++ if (fnmatch(argv[i], pkg->name, conf->nocase)) {
+ continue;
+ }
+ if (conf->restrict_to_default_dest) {
+@@ -926,7 +926,7 @@ opkg_depends_cmd(int argc, char **argv)
+ for (j=0; j<available_pkgs->len; j++) {
+ pkg = available_pkgs->pkgs[j];
+
+- if (fnmatch(argv[i], pkg->name, 0) != 0)
++ if (fnmatch(argv[i], pkg->name, conf->nocase) != 0)
+ continue;
+
+ depends_count = pkg->depends_count +
+@@ -1147,9 +1147,9 @@ opkg_what_provides_replaces_cmd(enum wha
+ ((what_field_type == WHATPROVIDES)
+ ? pkg->provides[k]
+ : pkg->replaces[k]);
+- if (fnmatch(target, apkg->name, 0) == 0) {
++ if (fnmatch(target, apkg->name, conf->nocase) == 0) {
+ opkg_msg(NOTICE, " %s", pkg->name);
+- if (strcmp(target, apkg->name) != 0)
++ if ((conf->nocase ? strcasecmp(target, apkg->name) : strcmp(target, apkg->name)) != 0)
+ opkg_msg(NOTICE, "\t%s %s\n",
+ rel_str, apkg->name);
+ opkg_message(NOTICE, "\n");
+@@ -1200,7 +1200,7 @@ opkg_search_cmd(int argc, char **argv)
+
+ for (iter = str_list_first(installed_files); iter; iter = str_list_next(installed_files, iter)) {
+ installed_file = (char *)iter->data;
+- if (fnmatch(argv[0], installed_file, 0)==0)
++ if (fnmatch(argv[0], installed_file, conf->nocase)==0)
+ print_pkg(pkg);
+ }
+
+--- a/libopkg/opkg_conf.c
++++ b/libopkg/opkg_conf.c
+@@ -62,6 +62,7 @@ opkg_option_t options[] = {
+ { "noaction", OPKG_OPT_TYPE_BOOL, &_conf.noaction },
+ { "download_only", OPKG_OPT_TYPE_BOOL, &_conf.download_only },
+ { "nodeps", OPKG_OPT_TYPE_BOOL, &_conf.nodeps },
++ { "nocase", OPKG_OPT_TYPE_BOOL, &_conf.nocase },
+ { "offline_root", OPKG_OPT_TYPE_STRING, &_conf.offline_root },
+ { "overlay_root", OPKG_OPT_TYPE_STRING, &_conf.overlay_root },
+ { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd },
+--- a/libopkg/opkg_conf.h
++++ b/libopkg/opkg_conf.h
+@@ -24,6 +24,7 @@ extern opkg_conf_t *conf;
+ #include "config.h"
+
+ #include <stdarg.h>
++#include <fnmatch.h> /* FNM_CASEFOLD */
+
+ #include "hash_table.h"
+ #include "pkg_src_list.h"
+@@ -79,6 +80,7 @@ struct opkg_conf
+ int force_remove;
+ int check_signature;
+ int nodeps; /* do not follow dependencies */
++ int nocase; /* perform case insensitive matching */
+ char *offline_root;
+ char *overlay_root;
+ int query_all;
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -47,6 +47,7 @@ enum {
+ ARGS_OPT_NOACTION,
+ ARGS_OPT_DOWNLOAD_ONLY,
+ ARGS_OPT_NODEPS,
++ ARGS_OPT_NOCASE,
+ ARGS_OPT_AUTOREMOVE,
+ ARGS_OPT_CACHE,
+ };
+@@ -86,6 +87,7 @@ static struct option long_options[] = {
+ {"noaction", 0, 0, ARGS_OPT_NOACTION},
+ {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY},
+ {"nodeps", 0, 0, ARGS_OPT_NODEPS},
++ {"nocase", 0, 0, ARGS_OPT_NOCASE},
+ {"offline", 1, 0, 'o'},
+ {"offline-root", 1, 0, 'o'},
+ {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH},
+@@ -107,7 +109,7 @@ args_parse(int argc, char *argv[])
+ char *tuple, *targ;
+
+ while (1) {
+- c = getopt_long_only(argc, argv, "Ad:f:no:p:t:vV::",
++ c = getopt_long_only(argc, argv, "Ad:f:ino:p:t:vV::",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+@@ -122,6 +124,9 @@ args_parse(int argc, char *argv[])
+ case 'f':
+ conf->conf_file = xstrdup(optarg);
+ break;
++ case 'i':
++ conf->nocase = FNM_CASEFOLD;
++ break;
+ case 'o':
+ conf->offline_root = xstrdup(optarg);
+ break;
+@@ -176,6 +181,9 @@ args_parse(int argc, char *argv[])
+ case ARGS_OPT_NODEPS:
+ conf->nodeps = 1;
+ break;
++ case ARGS_OPT_NOCASE:
++ conf->nocase = FNM_CASEFOLD;
++ break;
+ case ARGS_OPT_ADD_ARCH:
+ case ARGS_OPT_ADD_DEST:
+ tuple = xstrdup(optarg);
+@@ -287,6 +295,7 @@ usage()
+ printf("\t--noaction No action -- test only\n");
+ printf("\t--download-only No action -- download only\n");
+ printf("\t--nodeps Do not follow dependencies\n");
++ printf("\t--nocase Perform case insensitive pattern matching\n");
+ printf("\t--force-removal-of-dependent-packages\n");
+ printf("\t Remove package and all dependencies\n");
+ printf("\t--autoremove Remove packages that were installed\n");
diff --git a/package/system/opkg/patches/060-add-find-command.patch b/package/system/opkg/patches/060-add-find-command.patch
new file mode 100644
index 0000000..1762534
--- /dev/null
+++ b/package/system/opkg/patches/060-add-find-command.patch
@@ -0,0 +1,58 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -594,7 +594,7 @@ opkg_download_cmd(int argc, char **argv)
+
+
+ static int
+-opkg_list_cmd(int argc, char **argv)
++opkg_list_find_cmd(int argc, char **argv, int use_desc)
+ {
+ int i;
+ pkg_vec_t *available;
+@@ -610,7 +610,8 @@ opkg_list_cmd(int argc, char **argv)
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase) &&
++ (!use_desc || !pkg->description || fnmatch(pkg_name, pkg->description, conf->nocase)))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -619,6 +620,18 @@ opkg_list_cmd(int argc, char **argv)
+ return 0;
+ }
+
++static int
++opkg_list_cmd(int argc, char **argv)
++{
++ return opkg_list_find_cmd(argc, argv, 0);
++}
++
++static int
++opkg_find_cmd(int argc, char **argv)
++{
++ return opkg_list_find_cmd(argc, argv, 1);
++}
++
+
+ static int
+ opkg_list_installed_cmd(int argc, char **argv)
+@@ -1262,6 +1275,7 @@ static opkg_cmd_t cmds[] = {
+ {"configure", 0, (opkg_cmd_fun_t)opkg_configure_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"files", 1, (opkg_cmd_fun_t)opkg_files_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"search", 1, (opkg_cmd_fun_t)opkg_search_cmd, PFM_DESCRIPTION|PFM_SOURCE},
++ {"find", 1, (opkg_cmd_fun_t)opkg_find_cmd, PFM_SOURCE},
+ {"download", 1, (opkg_cmd_fun_t)opkg_download_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"compare_versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"compare-versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -246,6 +246,7 @@ usage()
+ printf("\tlist-changed-conffiles List user modified configuration files\n");
+ printf("\tfiles <pkg> List files belonging to <pkg>\n");
+ printf("\tsearch <file|regexp> List package providing <file>\n");
++ printf("\tfind <regexp> List packages whose name or description matches <regexp>\n");
+ printf("\tinfo [pkg|regexp] Display all info for <pkg>\n");
+ printf("\tstatus [pkg|regexp] Display all status for <pkg>\n");
+ printf("\tdownload <pkg> Download <pkg> to current directory\n");
diff --git a/package/system/opkg/patches/070-use_gzipped_pkg_list.patch b/package/system/opkg/patches/070-use_gzipped_pkg_list.patch
new file mode 100644
index 0000000..d32b519
--- /dev/null
+++ b/package/system/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;
+ }
diff --git a/package/system/opkg/patches/080-suppress-blank-package-fields.patch b/package/system/opkg/patches/080-suppress-blank-package-fields.patch
new file mode 100644
index 0000000..976b97d
--- /dev/null
+++ b/package/system/opkg/patches/080-suppress-blank-package-fields.patch
@@ -0,0 +1,16 @@
+--- a/libopkg/parse_util.c
++++ b/libopkg/parse_util.c
+@@ -35,7 +35,12 @@ is_field(const char *type, const char *l
+ char *
+ parse_simple(const char *type, const char *line)
+ {
+- return trim_xstrdup(line + strlen(type) + 1);
++ char *field = trim_xstrdup(line + strlen(type) + 1);
++ if (strlen(field) == 0) {
++ free(field);
++ return NULL;
++ }
++ return field;
+ }
+
+ /*
diff --git a/package/system/opkg/patches/090-suppress-blank-provides-field.patch b/package/system/opkg/patches/090-suppress-blank-provides-field.patch
new file mode 100644
index 0000000..7adf922
--- /dev/null
+++ b/package/system/opkg/patches/090-suppress-blank-provides-field.patch
@@ -0,0 +1,11 @@
+--- a/libopkg/pkg.c
++++ b/libopkg/pkg.c
+@@ -731,7 +731,7 @@ pkg_formatted_field(FILE *fp, pkg_t *pkg
+ } else if (strcasecmp(field, "Priority") == 0) {
+ fprintf(fp, "Priority: %s\n", pkg->priority);
+ } else if (strcasecmp(field, "Provides") == 0) {
+- if (pkg->provides_count) {
++ if (pkg->provides_count > 1) {
+ fprintf(fp, "Provides:");
+ for(i = 1; i < pkg->provides_count; i++) {
+ fprintf(fp, "%s %s", i == 1 ? "" : ",",
diff --git a/package/system/opkg/patches/100-add-force-checksum.patch b/package/system/opkg/patches/100-add-force-checksum.patch
new file mode 100644
index 0000000..5f65a75
--- /dev/null
+++ b/package/system/opkg/patches/100-add-force-checksum.patch
@@ -0,0 +1,85 @@
+--- a/libopkg/opkg_conf.c
++++ b/libopkg/opkg_conf.c
+@@ -54,6 +54,7 @@ opkg_option_t options[] = {
+ { "force_reinstall", OPKG_OPT_TYPE_BOOL, &_conf.force_reinstall },
+ { "force_space", OPKG_OPT_TYPE_BOOL, &_conf.force_space },
+ { "force_postinstall", OPKG_OPT_TYPE_BOOL, &_conf.force_postinstall },
++ { "force_checksum", OPKG_OPT_TYPE_BOOL, &_conf.force_checksum },
+ { "check_signature", OPKG_OPT_TYPE_BOOL, &_conf.check_signature },
+ { "ftp_proxy", OPKG_OPT_TYPE_STRING, &_conf.ftp_proxy },
+ { "http_proxy", OPKG_OPT_TYPE_STRING, &_conf.http_proxy },
+--- a/libopkg/opkg_conf.h
++++ b/libopkg/opkg_conf.h
+@@ -78,6 +78,7 @@ struct opkg_conf
+ int force_removal_of_essential_packages;
+ int force_postinstall;
+ int force_remove;
++ int force_checksum;
+ int check_signature;
+ int nodeps; /* do not follow dependencies */
+ int nocase; /* perform case insensitive matching */
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -1327,12 +1327,19 @@ opkg_install_pkg(pkg_t *pkg, int from_up
+ file_md5 = file_md5sum_alloc(pkg->local_filename);
+ if (file_md5 && strcmp(file_md5, pkg->md5sum))
+ {
+- opkg_msg(ERROR, "Package %s md5sum mismatch. "
+- "Either the opkg or the package index are corrupt. "
+- "Try 'opkg update'.\n",
+- pkg->name);
+- free(file_md5);
+- return -1;
++ if (!conf->force_checksum)
++ {
++ opkg_msg(ERROR, "Package %s md5sum mismatch. "
++ "Either the opkg or the package index are corrupt. "
++ "Try 'opkg update'.\n",
++ pkg->name);
++ free(file_md5);
++ return -1;
++ }
++ else
++ {
++ opkg_msg(NOTICE, "Ignored %s md5sum mismatch.\n", pkg->name);
++ }
+ }
+ if (file_md5)
+ free(file_md5);
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -42,6 +42,7 @@ enum {
+ ARGS_OPT_FORCE_SPACE,
+ ARGS_OPT_FORCE_POSTINSTALL,
+ ARGS_OPT_FORCE_REMOVE,
++ ARGS_OPT_FORCE_CHECKSUM,
+ ARGS_OPT_ADD_ARCH,
+ ARGS_OPT_ADD_DEST,
+ ARGS_OPT_NOACTION,
+@@ -84,6 +85,8 @@ static struct option long_options[] = {
+ {"force_postinstall", 0, 0, ARGS_OPT_FORCE_POSTINSTALL},
+ {"force-remove", 0, 0, ARGS_OPT_FORCE_REMOVE},
+ {"force_remove", 0, 0, ARGS_OPT_FORCE_REMOVE},
++ {"force-checksum", 0, 0, ARGS_OPT_FORCE_CHECKSUM},
++ {"force_checksum", 0, 0, ARGS_OPT_FORCE_CHECKSUM},
+ {"noaction", 0, 0, ARGS_OPT_NOACTION},
+ {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY},
+ {"nodeps", 0, 0, ARGS_OPT_NODEPS},
+@@ -178,6 +181,9 @@ args_parse(int argc, char *argv[])
+ case ARGS_OPT_FORCE_REMOVE:
+ conf->force_remove = 1;
+ break;
++ case ARGS_OPT_FORCE_CHECKSUM:
++ conf->force_checksum = 1;
++ break;
+ case ARGS_OPT_NODEPS:
+ conf->nodeps = 1;
+ break;
+@@ -293,6 +299,7 @@ usage()
+ printf("\t--force-space Disable free space checks\n");
+ printf("\t--force-postinstall Run postinstall scripts even in offline mode\n");
+ printf("\t--force-remove Remove package even if prerm script fails\n");
++ printf("\t--force-checksum Don't fail on checksum mismatches\n");
+ printf("\t--noaction No action -- test only\n");
+ printf("\t--download-only No action -- download only\n");
+ printf("\t--nodeps Do not follow dependencies\n");
diff --git a/package/system/opkg/patches/110-upgrade.patch b/package/system/opkg/patches/110-upgrade.patch
new file mode 100644
index 0000000..071df0e
--- /dev/null
+++ b/package/system/opkg/patches/110-upgrade.patch
@@ -0,0 +1,49 @@
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -1405,9 +1405,10 @@
+ opkg_state_changed++;
+ pkg->state_flag |= SF_FILELIST_CHANGED;
+
+- if (old_pkg)
++ if (old_pkg) {
+ pkg_remove_orphan_dependent(pkg, old_pkg);
+-
++ pkg->is_upgrade = 1;
++ }
+ /* XXX: BUG: we really should treat replacement more like an upgrade
+ * Instead, we're going to remove the replacees
+ */
+@@ -1466,7 +1467,7 @@
+ }
+
+
+- opkg_msg(INFO, "Installing maintainer scripts.\n");
++ opkg_msg(INFO, "%s maintainer scripts.\n", (pkg->is_upgrade) ? ("Upgrading") : ("Installing"));
+ if (install_maintainer_scripts(pkg, old_pkg)) {
+ opkg_msg(ERROR, "Failed to extract maintainer scripts for %s."
+ " Package debris may remain!\n",
+--- a/libopkg/pkg.c
++++ b/libopkg/pkg.c
+@@ -1285,6 +1285,12 @@
+ setenv("PKG_ROOT",
+ pkg->dest ? pkg->dest->root_dir : conf->default_dest->root_dir, 1);
+
++ if (pkg->is_upgrade)
++ setenv("PKG_UPGRADE", "1", 1);
++ else
++ setenv("PKG_UPGRADE", "0", 1);
++
++
+ if (! file_exists(path)) {
+ free(path);
+ return 0;
+--- a/libopkg/pkg.h
++++ b/libopkg/pkg.h
+@@ -184,6 +184,7 @@
+ /* this flag specifies whether the package was installed to satisfy another
+ * package's dependancies */
+ int auto_installed;
++ int is_upgrade;
+ };
+
+ pkg_t *pkg_new(void);
diff --git a/package/system/opkg/patches/200-usign_support.patch b/package/system/opkg/patches/200-usign_support.patch
new file mode 100644
index 0000000..991708a
--- /dev/null
+++ b/package/system/opkg/patches/200-usign_support.patch
@@ -0,0 +1,91 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -169,6 +169,15 @@ if test "x$want_gpgme" = "xyes"; then
+ fi
+ fi
+
++AC_ARG_ENABLE(usign,
++ AC_HELP_STRING([--enable-usign], [Enable signature checking with usign
++ [[default=yes]] ]),
++ [want_usign="$enableval"], [want_usign="yes"])
++
++if test "x$want_usign" = "xyes"; then
++ AC_DEFINE(HAVE_USIGN, 1, [Define if you want usign support])
++fi
++
+ AC_SUBST(GPGME_CFLAGS)
+ AC_SUBST(GPGME_LIBS)
+
+--- a/libopkg/opkg.c
++++ b/libopkg/opkg.c
+@@ -599,7 +599,7 @@ opkg_update_package_lists(opkg_progress_
+ }
+ free(url);
+
+-#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL)
++#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN)
+ if (conf->check_signature) {
+ char *sig_file_name;
+ /* download detached signitures to verify the package lists */
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -169,7 +169,7 @@ opkg_update_cmd(int argc, char **argv)
+ list_file_name);
+ }
+ free(url);
+-#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL)
++#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN)
+ if (conf->check_signature) {
+ /* download detached signitures to verify the package lists */
+ /* get the url for the sig file */
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -1288,7 +1288,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up
+ }
+
+ /* check that the repository is valid */
+- #if defined(HAVE_GPGME) || defined(HAVE_OPENSSL)
++ #if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN)
+ char *list_file_name, *sig_file_name, *lists_dir;
+
+ /* check to ensure the package has come from a repository */
+--- a/libopkg/opkg_download.c
++++ b/libopkg/opkg_download.c
+@@ -19,6 +19,7 @@
+
+ #include "config.h"
+
++#include <sys/wait.h>
+ #include <stdio.h>
+ #include <unistd.h>
+ #include <libgen.h>
+@@ -342,7 +343,28 @@ opkg_prepare_url_for_install(const char
+ int
+ opkg_verify_file (char *text_file, char *sig_file)
+ {
+-#if defined HAVE_GPGME
++#if defined HAVE_USIGN
++ int status = -1;
++ int pid;
++
++ if (conf->check_signature == 0 )
++ return 0;
++
++ pid = fork();
++ if (pid < 0)
++ return -1;
++
++ if (!pid) {
++ execl("/usr/sbin/opkg-key", "opkg-key", "verify", sig_file, text_file, NULL);
++ exit(255);
++ }
++
++ waitpid(pid, &status, 0);
++ if (!WIFEXITED(status) || WEXITSTATUS(status))
++ return -1;
++
++ return 0;
++#elif defined HAVE_GPGME
+ if (conf->check_signature == 0 )
+ return 0;
+ int status = -1;
diff --git a/package/system/opkg/patches/210-add-force-signature.patch b/package/system/opkg/patches/210-add-force-signature.patch
new file mode 100644
index 0000000..c41eab0
--- /dev/null
+++ b/package/system/opkg/patches/210-add-force-signature.patch
@@ -0,0 +1,70 @@
+--- a/libopkg/opkg_conf.h
++++ b/libopkg/opkg_conf.h
+@@ -80,6 +80,7 @@ struct opkg_conf
+ int force_remove;
+ int force_checksum;
+ int check_signature;
++ int force_signature;
+ int nodeps; /* do not follow dependencies */
+ int nocase; /* perform case insensitive matching */
+ char *offline_root;
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -51,6 +51,7 @@ enum {
+ ARGS_OPT_NOCASE,
+ ARGS_OPT_AUTOREMOVE,
+ ARGS_OPT_CACHE,
++ ARGS_OPT_FORCE_SIGNATURE,
+ };
+
+ static struct option long_options[] = {
+@@ -87,6 +88,8 @@ static struct option long_options[] = {
+ {"force_remove", 0, 0, ARGS_OPT_FORCE_REMOVE},
+ {"force-checksum", 0, 0, ARGS_OPT_FORCE_CHECKSUM},
+ {"force_checksum", 0, 0, ARGS_OPT_FORCE_CHECKSUM},
++ {"force-signature", 0, 0, ARGS_OPT_FORCE_SIGNATURE},
++ {"force_signature", 0, 0, ARGS_OPT_FORCE_SIGNATURE},
+ {"noaction", 0, 0, ARGS_OPT_NOACTION},
+ {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY},
+ {"nodeps", 0, 0, ARGS_OPT_NODEPS},
+@@ -210,6 +213,9 @@ args_parse(int argc, char *argv[])
+ case ARGS_OPT_DOWNLOAD_ONLY:
+ conf->download_only = 1;
+ break;
++ case ARGS_OPT_FORCE_SIGNATURE:
++ conf->force_signature = 1;
++ break;
+ case ':':
+ parse_err = -1;
+ break;
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -1306,13 +1306,15 @@ opkg_install_pkg(pkg_t *pkg, int from_up
+ if (opkg_verify_file (list_file_name, sig_file_name)){
+ opkg_msg(ERROR, "Failed to verify the signature of %s.\n",
+ list_file_name);
+- return -1;
++ if (!conf->force_signature)
++ return -1;
+ }
+ }else{
+ opkg_msg(ERROR, "Signature file is missing for %s. "
+ "Perhaps you need to run 'opkg update'?\n",
+ pkg->name);
+- return -1;
++ if (!conf->force_signature)
++ return -1;
+ }
+
+ free (lists_dir);
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -196,7 +196,7 @@ opkg_update_cmd(int argc, char **argv)
+ else
+ opkg_msg(NOTICE, "Signature check failed.\n");
+ }
+- if (err) {
++ if (err && !conf->force_signature) {
+ /* The signature was wrong so delete it */
+ opkg_msg(NOTICE, "Remove wrong Signature file.\n");
+ unlink (tmp_file_name);
diff --git a/package/system/opkg/patches/220-drop-release-support.patch b/package/system/opkg/patches/220-drop-release-support.patch
new file mode 100644
index 0000000..41f271f
--- /dev/null
+++ b/package/system/opkg/patches/220-drop-release-support.patch
@@ -0,0 +1,812 @@
+--- a/libopkg/Makefile.am
++++ b/libopkg/Makefile.am
+@@ -15,7 +15,6 @@
+ opkg_upgrade.c opkg_upgrade.h \
+ opkg_remove.c opkg_remove.h
+ opkg_db_sources = opkg_conf.c opkg_conf.h \
+- release.c release.h release_parse.c release_parse.h \
+ opkg_utils.c opkg_utils.h pkg.c pkg.h hash_table.h \
+ pkg_depends.c pkg_depends.h pkg_extract.c pkg_extract.h \
+ hash_table.c pkg_hash.c pkg_hash.h pkg_parse.c pkg_parse.h \
+@@ -28,7 +27,6 @@
+ active_list.c active_list.h list.h
+ opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c md5.c md5.h \
+ parse_util.c parse_util.h \
+- cksum_list.c cksum_list.h \
+ sprintf_alloc.c sprintf_alloc.h \
+ xregex.c xregex.h xsystem.c xsystem.h
+ if HAVE_PATHFINDER
+--- a/libopkg/cksum_list.c
++++ /dev/null
+@@ -1,87 +0,0 @@
+-/* cksum_lis.c - the opkg package management system
+-
+- Copyright (C) 2010,2011 Javier Palacios
+-
+- This program is free software; you can redistribute it and/or
+- modify it under the terms of the GNU General Public License as
+- published by the Free Software Foundation; either version 2, or (at
+- your option) any later version.
+-
+- This program is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-*/
+-
+-#include "config.h"
+-
+-#include <stdio.h>
+-
+-#include "cksum_list.h"
+-#include "libbb/libbb.h"
+-
+-
+-int cksum_init(cksum_t *cksum, char **itemlist)
+-{
+- cksum->value = xstrdup(*itemlist++);
+- cksum->size = atoi(*itemlist++);
+- cksum->name = xstrdup(*itemlist++);
+-
+- return 0;
+-}
+-
+-void cksum_deinit(cksum_t *cksum)
+-{
+- free (cksum->name);
+- cksum->name = NULL;
+-
+- free (cksum->value);
+- cksum->value = NULL;
+-}
+-
+-void cksum_list_init(cksum_list_t *list)
+-{
+- void_list_init((void_list_t *) list);
+-}
+-
+-void cksum_list_deinit(cksum_list_t *list)
+-{
+- cksum_list_elt_t *iter, *n;
+- cksum_t *cksum;
+-
+- list_for_each_entry_safe(iter, n, &list->head, node) {
+- cksum = (cksum_t *)iter->data;
+- cksum_deinit(cksum);
+-
+- /* malloced in cksum_list_append */
+- free(cksum);
+- iter->data = NULL;
+- }
+- void_list_deinit((void_list_t *) list);
+-}
+-
+-cksum_t *cksum_list_append(cksum_list_t *list, char **itemlist)
+-{
+- /* freed in cksum_list_deinit */
+- cksum_t *cksum = xcalloc(1, sizeof(cksum_t));
+- cksum_init(cksum, itemlist);
+-
+- void_list_append((void_list_t *) list, cksum);
+-
+- return cksum;
+-}
+-
+-const cksum_t *cksum_list_find(cksum_list_t *list, const char *name)
+-{
+- cksum_list_elt_t *iter;
+- cksum_t *cksum;
+-
+- list_for_each_entry(iter, &list->head, node) {
+- cksum = (cksum_t *)iter->data;
+- if (strcmp(cksum->name, name) == 0) {
+- return cksum;
+- }
+- }
+- return NULL;
+-}
+-
+--- a/libopkg/cksum_list.h
++++ /dev/null
+@@ -1,46 +0,0 @@
+-/* cksum_list.h - the opkg package management system
+-
+- Copyright (C) 2010,2011 Javier Palacios
+-
+- This program is free software; you can redistribute it and/or
+- modify it under the terms of the GNU General Public License as
+- published by the Free Software Foundation; either version 2, or (at
+- your option) any later version.
+-
+- This program is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-*/
+-
+-#ifndef CKSUM_LIST_H
+-#define CKSUM_LIST_H
+-
+-typedef struct
+-{
+- char *name;
+- char *value;
+- int size;
+-} cksum_t;
+-
+-int cksum_init(cksum_t *cksum, char **itemlist);
+-void cksum_deinit(cksum_t *cksum);
+-
+-#include "void_list.h"
+-
+-typedef struct void_list_elt cksum_list_elt_t;
+-
+-typedef struct void_list cksum_list_t;
+-
+-static inline int cksum_list_empty(cksum_list_t *list)
+-{
+- return void_list_empty ((void_list_t *)list);
+-}
+-
+-void cksum_list_init(cksum_list_t *list);
+-void cksum_list_deinit(cksum_list_t *list);
+-
+-cksum_t *cksum_list_append(cksum_list_t *list, char **itemlist);
+-const cksum_t *cksum_list_find(cksum_list_t *list, const char *name);
+-
+-#endif
+--- a/libopkg/release.c
++++ /dev/null
+@@ -1,342 +0,0 @@
+-/* release.c - the opkg package management system
+-
+- Copyright (C) 2010,2011 Javier Palacios
+-
+- This program is free software; you can redistribute it and/or
+- modify it under the terms of the GNU General Public License as
+- published by the Free Software Foundation; either version 2, or (at
+- your option) any later version.
+-
+- This program is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-*/
+-
+-#include <unistd.h>
+-#include <ctype.h>
+-
+-#include "release.h"
+-#include "opkg_utils.h"
+-#include "libbb/libbb.h"
+-
+-#include "opkg_download.h"
+-#include "sprintf_alloc.h"
+-
+-#include "release_parse.h"
+-
+-#include "parse_util.h"
+-#include "file_util.h"
+-
+-static void
+-release_init(release_t *release)
+-{
+- release->name = NULL;
+- release->datestring = NULL;
+- release->architectures = NULL;
+- release->architectures_count = 0;
+- release->components = NULL;
+- release->components_count = 0;
+- release->complist = NULL;
+- release->complist_count = 0;
+-}
+-
+-release_t *
+-release_new(void)
+-{
+- release_t *release;
+-
+- release = xcalloc(1, sizeof(release_t));
+- release_init(release);
+-
+- return release;
+-}
+-
+-void
+-release_deinit(release_t *release)
+-{
+- int i;
+-
+- free(release->name);
+- free(release->datestring);
+-
+- for(i = 0; i < release->architectures_count; i++){
+- free(release->architectures[i]);
+- }
+- free(release->architectures);
+-
+- for(i = 0; i < release->components_count; i++){
+- free(release->components[i]);
+- }
+- free(release->components);
+-
+- for(i = 0; i < release->complist_count; i++){
+- free(release->complist[i]);
+- }
+- free(release->complist);
+-
+-}
+-
+-int
+-release_init_from_file(release_t *release, const char *filename)
+-{
+- int err = 0;
+- FILE *release_file;
+-
+- release_file = fopen(filename, "r");
+- if (release_file == NULL) {
+- opkg_perror(ERROR, "Failed to open %s", filename);
+- return -1;
+- }
+-
+- err=release_parse_from_stream(release, release_file);
+- if (!err) {
+- if (!release_arch_supported(release)) {
+- opkg_msg(ERROR, "No valid architecture found on Release file.\n");
+- err = -1;
+- }
+- }
+-
+- return err;
+-}
+-
+-const char *
+-item_in_list(const char *comp, char **complist, const unsigned int count)
+-{
+- int i;
+-
+- if (!complist)
+- return comp;
+-
+- for(i = 0; i < count; i++){
+- if (strcmp(comp, complist[i]) == 0)
+- return complist[i];
+- }
+-
+- return NULL;
+-}
+-
+-int
+-release_arch_supported(release_t *release)
+-{
+- nv_pair_list_elt_t *l;
+-
+- list_for_each_entry(l , &conf->arch_list.head, node) {
+- nv_pair_t *nv = (nv_pair_t *)l->data;
+- if (item_in_list(nv->name, release->architectures, release->architectures_count)) {
+- opkg_msg(DEBUG, "Arch %s (priority %s) supported for dist %s.\n",
+- nv->name, nv->value, release->name);
+- return 1;
+- }
+- }
+-
+- return 0;
+-}
+-
+-int
+-release_comps_supported(release_t *release, const char *complist)
+-{
+- int ret = 1;
+- int i;
+-
+- if (complist) {
+- release->complist = parse_list(complist, &release->complist_count, ' ', 1);
+- for(i = 0; i < release->complist_count; i++){
+- if (!item_in_list(release->complist[i], release->components, release->components_count)) {
+- opkg_msg(ERROR, "Component %s not supported for dist %s.\n",
+- release->complist[i], release->name);
+- ret = 0;
+- }
+- }
+- }
+-
+- return ret;
+-}
+-
+-const char **
+-release_comps(release_t *release, unsigned int *count)
+-{
+- char **comps = release->complist;
+-
+- if (!comps) {
+- comps = release->components;
+- *count = release->components_count;
+- } else {
+- *count = release->complist_count;
+- }
+-
+- return (const char **)comps;
+-}
+-
+-int
+-release_download(release_t *release, pkg_src_t *dist, char *lists_dir, char *tmpdir)
+-{
+- int ret = 0;
+- unsigned int ncomp;
+- const char **comps = release_comps(release, &ncomp);
+- nv_pair_list_elt_t *l;
+- int i;
+-
+- for(i = 0; i < ncomp; i++){
+- int err = 0;
+- char *prefix;
+-
+- sprintf_alloc(&prefix, "%s/dists/%s/%s/binary", dist->value, dist->name,
+- comps[i]);
+-
+- list_for_each_entry(l , &conf->arch_list.head, node) {
+- char *url;
+- char *tmp_file_name, *list_file_name;
+- char *subpath = NULL;
+-
+- nv_pair_t *nv = (nv_pair_t *)l->data;
+-
+- sprintf_alloc(&list_file_name, "%s/%s-%s-%s", lists_dir, dist->name, comps[i], nv->name);
+-
+- sprintf_alloc(&tmp_file_name, "%s/%s-%s-%s%s", tmpdir, dist->name, comps[i], nv->name, ".gz");
+-
+- sprintf_alloc(&subpath, "%s/binary-%s/%s", comps[i], nv->name, dist->gzip ? "Packages.gz" : "Packages");
+-
+- if (dist->gzip) {
+- sprintf_alloc(&url, "%s-%s/Packages.gz", prefix, nv->name);
+- err = opkg_download(url, tmp_file_name, NULL, NULL, 1);
+- if (!err) {
+- err = release_verify_file(release, tmp_file_name, subpath);
+- if (err) {
+- unlink (tmp_file_name);
+- unlink (list_file_name);
+- }
+- }
+- if (!err) {
+- FILE *in, *out;
+- opkg_msg(NOTICE, "Inflating %s.\n", url);
+- in = fopen (tmp_file_name, "r");
+- out = fopen (list_file_name, "w");
+- if (in && out) {
+- err = unzip (in, out);
+- if (err)
+- opkg_msg(INFO, "Corrumpt file at %s.\n", url);
+- } else
+- err = 1;
+- if (in)
+- fclose (in);
+- if (out)
+- fclose (out);
+- unlink (tmp_file_name);
+- }
+- free(url);
+- }
+-
+- if (err) {
+- sprintf_alloc(&url, "%s-%s/Packages", prefix, nv->name);
+- err = opkg_download(url, list_file_name, NULL, NULL, 1);
+- if (!err) {
+- err = release_verify_file(release, tmp_file_name, subpath);
+- if (err)
+- unlink (list_file_name);
+- }
+- free(url);
+- }
+-
+- free(tmp_file_name);
+- free(list_file_name);
+- }
+-
+- if(err)
+- ret = 1;
+-
+- free(prefix);
+- }
+-
+- return ret;
+-}
+-
+-int
+-release_get_size(release_t *release, const char *pathname)
+-{
+- const cksum_t *cksum;
+-
+- if (release->md5sums) {
+- cksum = cksum_list_find(release->md5sums, pathname);
+- return cksum->size;
+- }
+-
+-#ifdef HAVE_SHA256
+- if (release->sha256sums) {
+- cksum = cksum_list_find(release->sha256sums, pathname);
+- return cksum->size;
+- }
+-#endif
+-
+- return -1;
+-}
+-
+-const char *
+-release_get_md5(release_t *release, const char *pathname)
+-{
+- const cksum_t *cksum;
+-
+- if (release->md5sums) {
+- cksum = cksum_list_find(release->md5sums, pathname);
+- return cksum->value;
+- }
+-
+- return '\0';
+-}
+-
+-#ifdef HAVE_SHA256
+-const char *
+-release_get_sha256(release_t *release, const char *pathname)
+-{
+- const cksum_t *cksum;
+-
+- if (release->sha256sums) {
+- cksum = cksum_list_find(release->sha256sums, pathname);
+- return cksum->value;
+- }
+-
+- return '\0';
+-}
+-#endif
+-
+-int
+-release_verify_file(release_t *release, const char* file_name, const char *pathname)
+-{
+- struct stat f_info;
+- char *f_md5 = NULL;
+- const char *md5 = release_get_md5(release, pathname);
+-#ifdef HAVE_SHA256
+- char *f_sha256 = NULL;
+- const char *sha256 = release_get_sha256(release, pathname);
+-#endif
+- int ret = 0;
+-
+- if (stat(file_name, &f_info) || (f_info.st_size!=release_get_size(release, pathname))) {
+- opkg_msg(ERROR, "Size verification failed for %s - %s.\n", release->name, pathname);
+- ret = 1;
+- } else {
+-
+- f_md5 = file_md5sum_alloc(file_name);
+-#ifdef HAVE_SHA256
+- f_sha256 = file_sha256sum_alloc(file_name);
+-#endif
+-
+- if (md5 && strcmp(md5, f_md5)) {
+- opkg_msg(ERROR, "MD5 verification failed for %s - %s.\n", release->name, pathname);
+- ret = 1;
+-#ifdef HAVE_SHA256
+- } else if (sha256 && strcmp(sha256, f_sha256)) {
+- opkg_msg(ERROR, "SHA256 verification failed for %s - %s.\n", release->name, pathname);
+- ret = 1;
+-#endif
+- }
+-
+- }
+-
+- free(f_md5);
+-#ifdef HAVE_SHA256
+- free(f_sha256);
+-#endif
+-
+- return ret;
+-}
+--- a/libopkg/release.h
++++ /dev/null
+@@ -1,53 +0,0 @@
+-/* release.h - the opkg package management system
+-
+- Copyright (C) 2010,2011 Javier Palacios
+-
+- This program is free software; you can redistribute it and/or
+- modify it under the terms of the GNU General Public License as
+- published by the Free Software Foundation; either version 2, or (at
+- your option) any later version.
+-
+- This program is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-*/
+-
+-#ifndef RELEASE_H
+-#define RELEASE_H
+-
+-#include <stdio.h>
+-#include "pkg.h"
+-#include "cksum_list.h"
+-
+-struct release
+-{
+- char *name;
+- char *datestring;
+- char **architectures;
+- unsigned int architectures_count;
+- char **components;
+- unsigned int components_count;
+- cksum_list_t *md5sums;
+-#ifdef HAVE_SHA256
+- cksum_list_t *sha256sums;
+-#endif
+- char **complist;
+- unsigned int complist_count;
+-};
+-
+-typedef struct release release_t;
+-
+-release_t *release_new(void);
+-void release_deinit(release_t *release);
+-int release_init_from_file(release_t *release, const char *filename);
+-
+-int release_arch_supported(release_t *release);
+-int release_comps_supported(release_t *release, const char *complist);
+-int release_download(release_t *release, pkg_src_t *dist, char *lists_dir, char *tmpdir);
+-
+-const char **release_comps(release_t *release, unsigned int *count);
+-
+-int release_verify_file(release_t *release, const char *filename, const char *pathname);
+-
+-#endif
+--- a/libopkg/release_parse.c
++++ /dev/null
+@@ -1,126 +0,0 @@
+-/* release_parse.c - the opkg package management system
+-
+- Copyright (C) 2010,2011 Javier Palacios
+-
+- This program is free software; you can redistribute it and/or
+- modify it under the terms of the GNU General Public License as
+- published by the Free Software Foundation; either version 2, or (at
+- your option) any later version.
+-
+- This program is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-*/
+-
+-#include "config.h"
+-
+-#include <stdio.h>
+-
+-#include "release.h"
+-#include "release_parse.h"
+-#include "libbb/libbb.h"
+-#include "parse_util.h"
+-
+-static int
+-release_parse_line(void *ptr, const char *line, uint mask)
+-{
+- release_t *release = (release_t *) ptr;
+-
+- int ret = 0;
+- unsigned int count = 0;
+- char **list = 0;
+- static int reading_md5sums = 0;
+-#ifdef HAVE_SHA256
+- static int reading_sha256sums = 0;
+-#endif
+-
+- switch (*line) {
+- case 'A':
+- if (is_field("Architectures", line)) {
+- release->architectures = parse_list(line, &release->architectures_count, ' ', 0);
+- }
+- break;
+-
+- case 'C':
+- if (is_field("Codename", line)) {
+- release->name = parse_simple("Codename", line);
+- }
+- else if (is_field("Components", line)) {
+- release->components = parse_list(line, &release->components_count, ' ', 0);
+- }
+- break;
+-
+- case 'D':
+- if (is_field("Date", line)) {
+- release->datestring = parse_simple("Date", line);
+- }
+- break;
+-
+- case 'M':
+- if (is_field("MD5sum", line)) {
+- reading_md5sums = 1;
+- if (release->md5sums == NULL) {
+- release->md5sums = xcalloc(1, sizeof(cksum_list_t));
+- cksum_list_init(release->md5sums);
+- }
+- goto dont_reset_flags;
+- }
+- break;
+-
+-#ifdef HAVE_SHA256
+- case 'S':
+- if (is_field("SHA256", line)) {
+- reading_sha256sums = 1;
+- if (release->sha256sums == NULL) {
+- release->sha256sums = xcalloc(1, sizeof(cksum_list_t));
+- cksum_list_init(release->sha256sums);
+- }
+- goto dont_reset_flags;
+- }
+- break;
+-#endif
+-
+- case ' ':
+- if (reading_md5sums) {
+- list = parse_list(line, &count, ' ', 1);
+- cksum_list_append(release->md5sums, list);
+- goto dont_reset_flags;
+- }
+-#ifdef HAVE_SHA256
+- else if (reading_sha256sums) {
+- list = parse_list(line, &count, ' ', 1);
+- cksum_list_append(release->sha256sums, list);
+- goto dont_reset_flags;
+- }
+-#endif
+- break;
+-
+- default:
+- ret = 1;
+- }
+-
+- reading_md5sums = 0;
+-#ifdef HAVE_SHA256
+- reading_sha256sums = 0;
+-#endif
+-
+-dont_reset_flags:
+-
+- return ret;
+-}
+-
+-int
+-release_parse_from_stream(release_t *release, FILE *fp)
+-{
+- int ret;
+- char *buf;
+- const size_t len = 4096;
+-
+- buf = xmalloc(len);
+- ret = parse_from_stream_nomalloc(release_parse_line, release, fp, 0, &buf, len);
+- free(buf);
+-
+- return ret;
+-}
+-
+--- a/libopkg/release_parse.h
++++ /dev/null
+@@ -1,21 +0,0 @@
+-/* release_parse.h - the opkg package management system
+-
+- Copyright (C) 2010,2011 Javier Palacios
+-
+- This program is free software; you can redistribute it and/or
+- modify it under the terms of the GNU General Public License as
+- published by the Free Software Foundation; either version 2, or (at
+- your option) any later version.
+-
+- This program is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-*/
+-
+-#ifndef RELEASE_PARSE_H
+-#define RELEASE_PARSE_H
+-
+-int release_parse_from_stream(release_t *release, FILE *fp);
+-
+-#endif
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -27,7 +27,6 @@
+ #include "opkg_conf.h"
+ #include "opkg_cmd.h"
+ #include "opkg_message.h"
+-#include "release.h"
+ #include "pkg.h"
+ #include "pkg_dest.h"
+ #include "pkg_parse.h"
+@@ -114,39 +113,6 @@
+ }
+
+
+- for (iter = void_list_first(&conf->dist_src_list); iter; iter = void_list_next(&conf->dist_src_list, iter)) {
+- char *url, *list_file_name;
+-
+- src = (pkg_src_t *)iter->data;
+-
+- sprintf_alloc(&url, "%s/dists/%s/Release", src->value, src->name);
+-
+- sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
+- err = opkg_download(url, list_file_name, NULL, NULL, 0);
+- if (!err) {
+- opkg_msg(NOTICE, "Downloaded release files for dist %s.\n",
+- src->name);
+- release_t *release = release_new();
+- err = release_init_from_file(release, list_file_name);
+- if (!err) {
+- if (!release_comps_supported(release, src->extra_data))
+- err = -1;
+- }
+- if (!err) {
+- err = release_download(release, src, lists_dir, tmp);
+- }
+- release_deinit(release);
+- if (err)
+- unlink(list_file_name);
+- }
+-
+- if (err)
+- failures++;
+-
+- free(list_file_name);
+- free(url);
+- }
+-
+ for (iter = void_list_first(&conf->pkg_src_list); iter; iter = void_list_next(&conf->pkg_src_list, iter)) {
+ char *url, *list_file_name;
+
+--- a/libopkg/pkg_hash.c
++++ b/libopkg/pkg_hash.c
+@@ -18,7 +18,6 @@
+ #include <stdio.h>
+
+ #include "hash_table.h"
+-#include "release.h"
+ #include "pkg.h"
+ #include "opkg_message.h"
+ #include "pkg_vec.h"
+@@ -183,40 +182,6 @@
+ lists_dir = conf->restrict_to_default_dest ?
+ conf->default_dest->lists_dir : conf->lists_dir;
+
+- for (iter = void_list_first(&conf->dist_src_list); iter;
+- iter = void_list_next(&conf->dist_src_list, iter)) {
+-
+- src = (pkg_src_t *)iter->data;
+-
+- sprintf_alloc(&list_file, "%s/%s", lists_dir, src->name);
+-
+- if (file_exists(list_file)) {
+- int i;
+- release_t *release = release_new();
+- if(release_init_from_file(release, list_file)) {
+- free(list_file);
+- return -1;
+- }
+-
+- unsigned int ncomp;
+- const char **comps = release_comps(release, &ncomp);
+- subdist = (pkg_src_t *) xmalloc(sizeof(pkg_src_t));
+- memcpy(subdist, src, sizeof(pkg_src_t));
+-
+- for(i = 0; i < ncomp; i++){
+- subdist->name = NULL;
+- sprintf_alloc(&subdist->name, "%s-%s", src->name, comps[i]);
+- if (dist_hash_add_from_file(lists_dir, subdist)) {
+- free(subdist->name); free(subdist);
+- free(list_file);
+- return -1;
+- }
+- }
+- free(subdist->name); free(subdist);
+- }
+- free(list_file);
+- }
+-
+ for (iter = void_list_first(&conf->pkg_src_list); iter;
+ iter = void_list_next(&conf->pkg_src_list, iter)) {
+
diff --git a/package/system/opkg/patches/230-drop_md5_support.patch b/package/system/opkg/patches/230-drop_md5_support.patch
new file mode 100644
index 0000000..63671e5
--- /dev/null
+++ b/package/system/opkg/patches/230-drop_md5_support.patch
@@ -0,0 +1,161 @@
+--- a/libopkg/conffile.c
++++ b/libopkg/conffile.c
+@@ -36,7 +36,7 @@
+
+ int conffile_has_been_modified(conffile_t *conffile)
+ {
+- char *md5sum;
++ char *chksum;
+ char *filename = conffile->name;
+ char *root_filename;
+ int ret = 1;
+@@ -48,16 +48,19 @@
+
+ root_filename = root_filename_alloc(filename);
+
+- md5sum = file_md5sum_alloc(root_filename);
+-
+- if (md5sum && (ret = strcmp(md5sum, conffile->value))) {
+- opkg_msg(INFO, "Conffile %s:\n\told md5=%s\n\tnew md5=%s\n",
+- conffile->name, md5sum, conffile->value);
++#ifdef HAVE_MD5
++ chksum = file_md5sum_alloc(root_filename);
++#else
++ chksum = file_sha256sum_alloc(root_filename);
++#endif
++ if (chksum && (ret = strcmp(chksum, conffile->value))) {
++ opkg_msg(INFO, "Conffile %s:\n\told chk=%s\n\tnew chk=%s\n",
++ conffile->name, chksum, conffile->value);
+ }
+
+ free(root_filename);
+- if (md5sum)
+- free(md5sum);
++ if (chksum)
++ free(chksum);
+
+ return ret;
+ }
+--- a/libopkg/file_util.c
++++ b/libopkg/file_util.c
+@@ -26,7 +26,9 @@
+
+ #include "sprintf_alloc.h"
+ #include "file_util.h"
++#ifdef HAVE_MD5
+ #include "md5.h"
++#endif
+ #include "libbb/libbb.h"
+
+ #if defined HAVE_SHA256
+@@ -135,6 +137,7 @@
+ return make_directory(path, mode, FILEUTILS_RECUR);
+ }
+
++#ifdef HAVE_MD5
+ char *file_md5sum_alloc(const char *file_name)
+ {
+ static const int md5sum_bin_len = 16;
+@@ -180,6 +183,7 @@
+
+ return md5sum_hex;
+ }
++#endif
+
+ #ifdef HAVE_SHA256
+ char *file_sha256sum_alloc(const char *file_name)
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -1082,7 +1082,7 @@
+ conffile_list_elt_t *iter;
+ conffile_t *cf;
+ char *cf_backup;
+- char *md5sum;
++ char *chksum;
+
+ if (conf->noaction) return 0;
+
+@@ -1093,7 +1093,11 @@
+
+ /* Might need to initialize the md5sum for each conffile */
+ if (cf->value == NULL) {
++#ifdef HAVE_MD5
+ cf->value = file_md5sum_alloc(root_filename);
++#else
++ cf->value = file_sha256sum_alloc(root_filename);
++#endif
+ }
+
+ if (!file_exists(root_filename)) {
+@@ -1105,8 +1109,12 @@
+
+ if (file_exists(cf_backup)) {
+ /* Let's compute md5 to test if files are changed */
+- md5sum = file_md5sum_alloc(cf_backup);
+- if (md5sum && cf->value && strcmp(cf->value,md5sum) != 0 ) {
++#ifdef HAVE_MD5
++ chksum = file_md5sum_alloc(cf_backup);
++#else
++ chksum = file_sha256sum_alloc(cf_backup);
++#endif
++ if (chksum && cf->value && strcmp(cf->value,chksum) != 0 ) {
+ if (conf->force_maintainer) {
+ opkg_msg(NOTICE, "Conffile %s using maintainer's setting.\n",
+ cf_backup);
+@@ -1123,8 +1131,8 @@
+ }
+ }
+ unlink(cf_backup);
+- if (md5sum)
+- free(md5sum);
++ if (chksum)
++ free(chksum);
+ }
+
+ free(cf_backup);
+@@ -1323,6 +1331,7 @@
+ }
+ #endif
+
++#ifdef HAVE_MD5
+ /* Check for md5 values */
+ if (pkg->md5sum)
+ {
+@@ -1346,6 +1355,7 @@
+ if (file_md5)
+ free(file_md5);
+ }
++#endif
+
+ #ifdef HAVE_SHA256
+ /* Check for sha256 value */
+--- a/libopkg/Makefile.am
++++ b/libopkg/Makefile.am
+@@ -25,13 +25,16 @@
+ pkg_src.c pkg_src.h pkg_src_list.c pkg_src_list.h \
+ str_list.c str_list.h void_list.c void_list.h \
+ active_list.c active_list.h list.h
+-opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c md5.c md5.h \
++opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c \
+ parse_util.c parse_util.h \
+ sprintf_alloc.c sprintf_alloc.h \
+ xregex.c xregex.h xsystem.c xsystem.h
+ if HAVE_PATHFINDER
+ opkg_util_sources += opkg_pathfinder.c opkg_pathfinder.h
+ endif
++if HAVE_MD5
++opkg_util_sources += md5.c md5.h
++endif
+ if HAVE_SHA256
+ opkg_util_sources += sha256.c sha256.h
+ endif
+--- a/configure.ac
++++ b/configure.ac
+@@ -72,6 +72,7 @@
+ AC_DEFINE(HAVE_SHA256, 1, [Define if you want sha256 support])
+ fi
+ AM_CONDITIONAL(HAVE_SHA256, test "x$want_sha256" = "xyes")
++AM_CONDITIONAL(HAVE_MD5, test "x$want_sha256" = "xno")
+
+ # check for openssl
+ AC_ARG_ENABLE(openssl,
diff --git a/package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch b/package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch
new file mode 100644
index 0000000..8af4d40
--- /dev/null
+++ b/package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch
@@ -0,0 +1,31 @@
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -1364,12 +1364,22 @@ opkg_install_pkg(pkg_t *pkg, int from_up
+ file_sha256 = file_sha256sum_alloc(pkg->local_filename);
+ if (file_sha256 && strcmp(file_sha256, pkg->sha256sum))
+ {
+- opkg_msg(ERROR, "Package %s sha256sum mismatch. "
+- "Either the opkg or the package index are corrupt. "
+- "Try 'opkg update'.\n",
+- pkg->name);
+- free(file_sha256);
+- return -1;
++ if (!conf->force_checksum)
++ {
++ opkg_msg(ERROR,
++ "Package %s sha256sum mismatch. "
++ "Either the opkg or the package index are corrupt. "
++ "Try 'opkg update'.\n",
++ pkg->name);
++ free(file_sha256);
++ return -1;
++ }
++ else
++ {
++ opkg_msg(NOTICE,
++ "Ignored %s sha256sum mismatch.\n",
++ pkg->name);
++ }
+ }
+ if (file_sha256)
+ free(file_sha256);
diff --git a/package/system/opkg/patches/250-add-lists-dir-switch.patch b/package/system/opkg/patches/250-add-lists-dir-switch.patch
new file mode 100644
index 0000000..d0d0707
--- /dev/null
+++ b/package/system/opkg/patches/250-add-lists-dir-switch.patch
@@ -0,0 +1,39 @@
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -101,6 +101,8 @@ static struct option long_options[] = {
+ {"test", 0, 0, ARGS_OPT_NOACTION},
+ {"tmp-dir", 1, 0, 't'},
+ {"tmp_dir", 1, 0, 't'},
++ {"lists-dir", 1, 0, 'l'},
++ {"lists_dir", 1, 0, 'l'},
+ {"verbosity", 2, 0, 'V'},
+ {"version", 0, 0, 'v'},
+ {0, 0, 0, 0}
+@@ -115,7 +117,7 @@ args_parse(int argc, char *argv[])
+ char *tuple, *targ;
+
+ while (1) {
+- c = getopt_long_only(argc, argv, "Ad:f:ino:p:t:vV::",
++ c = getopt_long_only(argc, argv, "Ad:f:ino:p:l:t:vV::",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+@@ -139,6 +141,9 @@ args_parse(int argc, char *argv[])
+ case 't':
+ conf->tmp_dir = xstrdup(optarg);
+ break;
++ case 'l':
++ conf->lists_dir = xstrdup(optarg);
++ break;
+ case 'v':
+ printf("opkg version %s\n", VERSION);
+ exit(0);
+@@ -316,6 +321,8 @@ usage()
+ printf("\t automatically to satisfy dependencies\n");
+ printf("\t-t Specify tmp-dir.\n");
+ printf("\t--tmp-dir Specify tmp-dir.\n");
++ printf("\t-l Specify lists-dir.\n");
++ printf("\t--lists-dir Specify lists-dir.\n");
+
+ printf("\n");
+
diff --git a/package/system/opkg/patches/260-add-print-package-size.patch b/package/system/opkg/patches/260-add-print-package-size.patch
new file mode 100644
index 0000000..4dce356
--- /dev/null
+++ b/package/system/opkg/patches/260-add-print-package-size.patch
@@ -0,0 +1,74 @@
+--- a/libopkg/opkg_conf.c
++++ b/libopkg/opkg_conf.c
+@@ -69,6 +69,7 @@ opkg_option_t options[] = {
+ { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd },
+ { "proxy_user", OPKG_OPT_TYPE_STRING, &_conf.proxy_user },
+ { "query-all", OPKG_OPT_TYPE_BOOL, &_conf.query_all },
++ { "size", OPKG_OPT_TYPE_BOOL, &_conf.size },
+ { "tmp_dir", OPKG_OPT_TYPE_STRING, &_conf.tmp_dir },
+ { "verbosity", OPKG_OPT_TYPE_INT, &_conf.verbosity },
+ #if defined(HAVE_OPENSSL)
+--- a/libopkg/opkg_conf.h
++++ b/libopkg/opkg_conf.h
+@@ -88,6 +88,7 @@ struct opkg_conf
+ int query_all;
+ int verbosity;
+ int noaction;
++ int size;
+ int download_only;
+ char *cache;
+
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -52,6 +52,7 @@ enum {
+ ARGS_OPT_AUTOREMOVE,
+ ARGS_OPT_CACHE,
+ ARGS_OPT_FORCE_SIGNATURE,
++ ARGS_OPT_SIZE,
+ };
+
+ static struct option long_options[] = {
+@@ -98,6 +99,7 @@ static struct option long_options[] = {
+ {"offline-root", 1, 0, 'o'},
+ {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH},
+ {"add-dest", 1, 0, ARGS_OPT_ADD_DEST},
++ {"size", 0, 0, ARGS_OPT_SIZE},
+ {"test", 0, 0, ARGS_OPT_NOACTION},
+ {"tmp-dir", 1, 0, 't'},
+ {"tmp_dir", 1, 0, 't'},
+@@ -212,6 +214,9 @@ args_parse(int argc, char *argv[])
+ }
+ free(tuple);
+ break;
++ case ARGS_OPT_SIZE:
++ conf->size = 1;
++ break;
+ case ARGS_OPT_NOACTION:
+ conf->noaction = 1;
+ break;
+@@ -315,6 +320,7 @@ usage()
+ printf("\t--download-only No action -- download only\n");
+ printf("\t--nodeps Do not follow dependencies\n");
+ printf("\t--nocase Perform case insensitive pattern matching\n");
++ printf("\t--size Print package size when listing available packages\n");
+ printf("\t--force-removal-of-dependent-packages\n");
+ printf("\t Remove package and all dependencies\n");
+ printf("\t--autoremove Remove packages that were installed\n");
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -47,10 +47,12 @@ static void
+ print_pkg(pkg_t *pkg)
+ {
+ char *version = pkg_version_str_alloc(pkg);
++ printf("%s - %s", pkg->name, version);
++ if (conf->size)
++ printf(" - %lu", pkg->size);
+ if (pkg->description)
+- printf("%s - %s - %s\n", pkg->name, version, pkg->description);
+- else
+- printf("%s - %s\n", pkg->name, version);
++ printf(" - %s", pkg->description);
++ printf("\n");
+ free(version);
+ }
+