From 5aa97e35dec1783c98d0f28502b2d16879ffc8ee Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 16 Feb 2017 17:36:47 +0100 Subject: [PATCH] opkg: switch to LEDE fork (#120, #551, #571) Cherry-pick the following commits from master to bump opkg in LEDE 17.01: b65dc04712 opkg: switch to own fork to improve memory usage 55ffc38004 opkg: re-enable usign support 19720a6f03 opkg: fix handling conffiles in status lists 9e4555f58d opkg: fix stray printf() (#551) ebf846b005 opkg: mark as essential (FS#571) aedd5d5cb0 opkg: fix several package installation bugs 48ae44d033 opkg: gracefully handle missing $PATH, fix build warnings 1449b52f02 opkg: backport upstream fixes, code cleanups Signed-off-by: Jo-Philipp Wich --- package/system/opkg/Makefile | 92 +- .../system/opkg/patches/001-ship-pkg-m4.patch | 168 ---- .../system/opkg/patches/002-no-shave.patch | 37 - .../system/opkg/patches/004-host_cpu.patch | 20 - .../opkg/patches/007-force_static.patch | 71 -- .../opkg/patches/009-remove-upgrade-all.patch | 41 - .../patches/011-old-config-location.patch | 12 - ...-strip-trailing-conffiles-whitespace.patch | 23 - .../opkg/patches/014-errors-to-stderr.patch | 15 - .../opkg/patches/020-avoid_getline.patch | 317 ------- .../opkg/patches/030-fix-double-free.patch | 10 - .../040-wrap-descriptions-only-on-ttys.patch | 31 - .../050-add-case-insensitive-flag.patch | 169 ---- .../opkg/patches/060-add-find-command.patch | 58 -- .../opkg/patches/070-use_external_gzip.patch | 719 ---------------- .../patches/071-use_gzipped_pkg_list.patch | 124 --- .../080-suppress-blank-package-fields.patch | 16 - .../090-suppress-blank-provides-field.patch | 11 - .../opkg/patches/100-add-force-checksum.patch | 85 -- package/system/opkg/patches/110-upgrade.patch | 50 -- .../opkg/patches/200-usign_support.patch | 91 -- .../patches/210-add-force-signature.patch | 70 -- .../patches/220-drop-release-support.patch | 812 ------------------ .../opkg/patches/230-drop_md5_support.patch | 192 ----- .../240-fix-force-checksum-for-sha256.patch | 31 - .../patches/250-add-lists-dir-switch.patch | 39 - .../patches/260-add-print-package-size.patch | 74 -- .../opkg/patches/270-fix-use-after-free.patch | 11 - ...-prerm-and-postrm-scripts-on-upgrade.patch | 73 -- .../patches/290-clarify-download-errors.patch | 61 -- 30 files changed, 27 insertions(+), 3496 deletions(-) delete mode 100644 package/system/opkg/patches/001-ship-pkg-m4.patch delete mode 100644 package/system/opkg/patches/002-no-shave.patch delete mode 100644 package/system/opkg/patches/004-host_cpu.patch delete mode 100644 package/system/opkg/patches/007-force_static.patch delete mode 100644 package/system/opkg/patches/009-remove-upgrade-all.patch delete mode 100644 package/system/opkg/patches/011-old-config-location.patch delete mode 100644 package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch delete mode 100644 package/system/opkg/patches/014-errors-to-stderr.patch delete mode 100644 package/system/opkg/patches/020-avoid_getline.patch delete mode 100644 package/system/opkg/patches/030-fix-double-free.patch delete mode 100644 package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch delete mode 100644 package/system/opkg/patches/050-add-case-insensitive-flag.patch delete mode 100644 package/system/opkg/patches/060-add-find-command.patch delete mode 100644 package/system/opkg/patches/070-use_external_gzip.patch delete mode 100644 package/system/opkg/patches/071-use_gzipped_pkg_list.patch delete mode 100644 package/system/opkg/patches/080-suppress-blank-package-fields.patch delete mode 100644 package/system/opkg/patches/090-suppress-blank-provides-field.patch delete mode 100644 package/system/opkg/patches/100-add-force-checksum.patch delete mode 100644 package/system/opkg/patches/110-upgrade.patch delete mode 100644 package/system/opkg/patches/200-usign_support.patch delete mode 100644 package/system/opkg/patches/210-add-force-signature.patch delete mode 100644 package/system/opkg/patches/220-drop-release-support.patch delete mode 100644 package/system/opkg/patches/230-drop_md5_support.patch delete mode 100644 package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch delete mode 100644 package/system/opkg/patches/250-add-lists-dir-switch.patch delete mode 100644 package/system/opkg/patches/260-add-print-package-size.patch delete mode 100644 package/system/opkg/patches/270-fix-use-after-free.patch delete mode 100644 package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch delete mode 100644 package/system/opkg/patches/290-clarify-download-errors.patch diff --git a/package/system/opkg/Makefile b/package/system/opkg/Makefile index 39e6b4d058..110116971e 100644 --- a/package/system/opkg/Makefile +++ b/package/system/opkg/Makefile @@ -11,15 +11,14 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=opkg -PKG_RELEASE:=17 +PKG_RELEASE:=1 +PKG_FLAGS:=essential PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=http://git.yoctoproject.org/git/opkg -PKG_SOURCE_DATE:=2011-04-08 -PKG_SOURCE_VERSION:=9c97d5ecd795709c8584e972bfdf3aee3a5b846d -PKG_MIRROR_HASH:=55e05270f3eb2f3aff5d3791463ce3d13b8197ca7b301cd58e731a249552c48f -PKG_FIXUP:=autoreconf -PKG_REMOVE_FILES = autogen.sh aclocal.m4 +PKG_SOURCE_URL:=https://git.lede-project.org/project/opkg-lede.git +PKG_SOURCE_DATE:=2017-03-23 +PKG_SOURCE_VERSION:=1d0263bb40e3c099501fc1f2431907636230e7f2 +PKG_MIRROR_HASH:=1f527179e60b9404affa5f3c9c506d4249e085bf521f770819b8648273a1010c PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=COPYING @@ -27,21 +26,24 @@ PKG_LICENSE_FILES:=COPYING PKG_MAINTAINER:=Jo-Philipp Wich PKG_FLAGS := nonshared -PKG_CONFIG_DEPENDS := CONFIG_SIGNED_PACKAGES +PKG_CONFIG_DEPENDS := CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH PKG_BUILD_PARALLEL:=1 HOST_BUILD_PARALLEL:=1 PKG_INSTALL:=1 +HOST_BUILD_DEPENDS:=libubox/host + include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/cmake.mk define Package/opkg SECTION:=base CATEGORY:=Base system TITLE:=opkg package manager - DEPENDS:=+uclient-fetch +libpthread - URL:=http://wiki.openmoko.org/wiki/Opkg + DEPENDS:=+uclient-fetch +libpthread +libubox + URL:=https://git.lede-project.org/?p=project/opkg-lede.git MENU:=1 endef @@ -55,16 +57,6 @@ define Package/opkg/description opkg knows how to install both .ipk and .deb packages. endef -define Package/opkg/config -config OPKG_SUPPORT_MD5 - bool - default n - depends on PACKAGE_opkg - prompt "Support reading old md5 hashes." - help - Old opkg used md5s, new uses sha. This options enables understanding both while prefering sha. -endef - define Package/opkg/conffiles /etc/opkg.conf /etc/opkg/keys/ @@ -74,29 +66,20 @@ endef TARGET_CFLAGS += -ffunction-sections -fdata-sections EXTRA_CFLAGS += $(TARGET_CPPFLAGS) -CONFIGURE_ARGS += \ - --disable-curl \ - --disable-gpg \ - --enable-sha256 \ - --with-opkgetcdir=/etc \ - --with-opkglockfile=/var/lock/opkg.lock - -ifndef CONFIG_SIGNED_PACKAGES - CONFIGURE_ARGS += --disable-usign -endif -ifeq ($(CONFIG_OPKG_SUPPORT_MD5),y) - CONFIGURE_ARGS += --enable-md5 -else - CONFIGURE_ARGS += --disable-md5 -endif - -MAKE_FLAGS = \ - CC="$(TARGET_CC)" \ - DESTDIR="$(PKG_INSTALL_DIR)" \ - HOST_CPU="$(PKGARCH)" \ - LDFLAGS="-Wl,--gc-sections" \ - -define Package/opkg/Default/install +CMAKE_OPTIONS += \ + -DBUILD_TESTS=OFF \ + -DHOST_CPU=$(PKGARCH) \ + -DPATH_SPEC="$(TARGET_INIT_PATH)" \ + -DVERSION="$(PKG_SOURCE_VERSION) ($(PKG_SOURCE_DATE))" + +CMAKE_HOST_OPTIONS += \ + -DSTATIC_UBOX=ON \ + -DBUILD_TESTS=OFF \ + -DHOST_CPU=$(PKGARCH) \ + -DLOCK_FILE=/tmp/opkg.lock \ + -DVERSION="$(PKG_SOURCE_VERSION) ($(PKG_SOURCE_DATE))" + +define Package/opkg/install $(INSTALL_DIR) $(1)/usr/lib/opkg $(INSTALL_DIR) $(1)/bin $(INSTALL_DIR) $(1)/etc/opkg @@ -107,34 +90,13 @@ define Package/opkg/Default/install $(VERSION_SED) $(1)/etc/opkg/distfeeds.conf $(INSTALL_BIN) ./files/20_migrate-feeds $(1)/etc/uci-defaults/ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/opkg-cl $(1)/bin/opkg -endef - -define Package/opkg/install - $(call Package/opkg/Default/install,$(1),) ifneq ($(CONFIG_SIGNED_PACKAGES),) echo "option check_signature 1" >> $(1)/etc/opkg.conf endif - mkdir $(1)/usr/sbin + $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) ./files/opkg-key $(1)/usr/sbin/ endef -define Build/InstallDev - mkdir -p $(1)/usr/include - $(CP) $(PKG_INSTALL_DIR)/usr/include/libopkg $(1)/usr/include/ -endef - - -HOST_CONFIGURE_ARGS+= \ - --disable-curl \ - --disable-gpg \ - --enable-sha256 \ - --with-opkgetcdir=/etc \ - --with-opkglockfile=/tmp/opkg.lock - -define Host/Compile - +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) CC="$(HOSTCC)" all -endef - define Host/Install $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/opkg-cl $(STAGING_DIR_HOST)/bin/opkg endef diff --git a/package/system/opkg/patches/001-ship-pkg-m4.patch b/package/system/opkg/patches/001-ship-pkg-m4.patch deleted file mode 100644 index 4ca0f88970..0000000000 --- a/package/system/opkg/patches/001-ship-pkg-m4.patch +++ /dev/null @@ -1,168 +0,0 @@ ---- /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 . -+# -+# 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 .])], -+ [$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 deleted file mode 100644 index 313aa71b00..0000000000 --- a/package/system/opkg/patches/002-no-shave.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- 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 deleted file mode 100644 index d500d603da..0000000000 --- a/package/system/opkg/patches/004-host_cpu.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- 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 deleted file mode 100644 index 74977070c3..0000000000 --- a/package/system/opkg/patches/007-force_static.patch +++ /dev/null @@ -1,71 +0,0 @@ ---- a/libopkg/Makefile.am -+++ b/libopkg/Makefile.am -@@ -38,16 +38,10 @@ if HAVE_SHA256 - 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 @@ HOST_CPU=@host_cpu@ - 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 @@ AM_CFLAGS = $(ALL_CFLAGS) -Wall -g -O3 - - #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 @@ noinst_PROGRAMS = libopkg_test - #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 @@ AM_CFLAGS = -I${top_srcdir}/libopkg ${AL - 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 deleted file mode 100644 index 395a2a6f91..0000000000 --- a/package/system/opkg/patches/009-remove-upgrade-all.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- 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 Upgrade packages\n"); - printf("\tinstall Install package(s)\n"); - printf("\tconfigure Configure unpacked package(s)\n"); - printf("\tremove 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 deleted file mode 100644 index 0555926864..0000000000 --- a/package/system/opkg/patches/011-old-config-location.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- 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 deleted file mode 100644 index a47ae77cee..0000000000 --- a/package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- 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 deleted file mode 100644 index f0a93a8717..0000000000 --- a/package/system/opkg/patches/014-errors-to-stderr.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- 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 deleted file mode 100644 index 8a1a8f6272..0000000000 --- a/package/system/opkg/patches/020-avoid_getline.patch +++ /dev/null @@ -1,317 +0,0 @@ ---- 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 deleted file mode 100644 index 312e06c548..0000000000 --- a/package/system/opkg/patches/030-fix-double-free.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- 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 deleted file mode 100644 index 95406687b6..0000000000 --- a/package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- a/libopkg/pkg_parse.c -+++ b/libopkg/pkg_parse.c -@@ -20,6 +20,7 @@ - - #include - #include -+#include - - #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 deleted file mode 100644 index 4b9215b87a..0000000000 --- a/package/system/opkg/patches/050-add-case-insensitive-flag.patch +++ /dev/null @@ -1,169 +0,0 @@ ---- 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; ilen; 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; jlen; 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 -+#include /* 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 deleted file mode 100644 index 17625349f8..0000000000 --- a/package/system/opkg/patches/060-add-find-command.patch +++ /dev/null @@ -1,58 +0,0 @@ ---- 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 List files belonging to \n"); - printf("\tsearch List package providing \n"); -+ printf("\tfind List packages whose name or description matches \n"); - printf("\tinfo [pkg|regexp] Display all info for \n"); - printf("\tstatus [pkg|regexp] Display all status for \n"); - printf("\tdownload Download to current directory\n"); diff --git a/package/system/opkg/patches/070-use_external_gzip.patch b/package/system/opkg/patches/070-use_external_gzip.patch deleted file mode 100644 index 95873591de..0000000000 --- a/package/system/opkg/patches/070-use_external_gzip.patch +++ /dev/null @@ -1,719 +0,0 @@ ---- a/libbb/unarchive.c -+++ b/libbb/unarchive.c -@@ -28,6 +28,7 @@ - #include - - #include "libbb.h" -+#include "gzip.h" - - #define CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY 1 - #define CONFIG_FEATURE_TAR_GNU_EXTENSIONS -@@ -39,38 +40,15 @@ static char *linkname = NULL; - - off_t archive_offset; - --#define SEEK_BUF 4096 - static ssize_t --seek_by_read(FILE* fd, size_t len) --{ -- ssize_t cc, total = 0; -- char buf[SEEK_BUF]; -- -- while (len) { -- cc = fread(buf, sizeof(buf[0]), -- len > SEEK_BUF ? SEEK_BUF : len, -- fd); -- -- total += cc; -- len -= cc; -- -- if(feof(fd) || ferror(fd)) -- break; -- } -- return total; --} -- --static void --seek_sub_file(FILE *fd, const int count) -+seek_forward(struct gzip_handle *zh, ssize_t len) - { -- archive_offset += count; -+ ssize_t slen = gzip_seek(zh, len); - -- /* Do not use fseek() on a pipe. It may fail with ESPIPE, leaving the -- * stream at an undefined location. -- */ -- seek_by_read(fd, count); -+ if (slen == len) -+ archive_offset += len; - -- return; -+ return slen; - } - - -@@ -87,7 +65,7 @@ seek_sub_file(FILE *fd, const int count) - * trailing '/' or else the last dir will be assumed to be the file prefix - */ - static char * --extract_archive(FILE *src_stream, FILE *out_stream, -+extract_archive(struct gzip_handle *src_stream, FILE *out_stream, - const file_header_t *file_entry, const int function, - const char *prefix, - int *err) -@@ -129,14 +107,14 @@ extract_archive(FILE *src_stream, FILE * - - if (function & extract_to_stream) { - if (S_ISREG(file_entry->mode)) { -- *err = copy_file_chunk(src_stream, out_stream, file_entry->size); -+ *err = gzip_copy(src_stream, out_stream, file_entry->size); - archive_offset += file_entry->size; - } - } - else if (function & extract_one_to_buffer) { - if (S_ISREG(file_entry->mode)) { - buffer = (char *) xmalloc(file_entry->size + 1); -- fread(buffer, 1, file_entry->size, src_stream); -+ gzip_read(src_stream, buffer, file_entry->size); - buffer[file_entry->size] = '\0'; - archive_offset += file_entry->size; - goto cleanup; -@@ -156,7 +134,7 @@ extract_archive(FILE *src_stream, FILE * - *err = -1; - error_msg("%s not created: newer or same age file exists", file_entry->name); - } -- seek_sub_file(src_stream, file_entry->size); -+ seek_forward(src_stream, file_entry->size); - goto cleanup; - } - } -@@ -185,11 +163,11 @@ extract_archive(FILE *src_stream, FILE * - } else { - if ((dst_stream = wfopen(full_name, "w")) == NULL) { - *err = -1; -- seek_sub_file(src_stream, file_entry->size); -+ seek_forward(src_stream, file_entry->size); - goto cleanup; - } - archive_offset += file_entry->size; -- *err = copy_file_chunk(src_stream, dst_stream, file_entry->size); -+ *err = gzip_copy(src_stream, dst_stream, file_entry->size); - fclose(dst_stream); - } - break; -@@ -250,7 +228,7 @@ extract_archive(FILE *src_stream, FILE * - /* If we arent extracting data we have to skip it, - * if data size is 0 then then just do it anyway - * (saves testing for it) */ -- seek_sub_file(src_stream, file_entry->size); -+ seek_forward(src_stream, file_entry->size); - } - - /* extract_list and extract_verbose_list can be used in conjunction -@@ -274,8 +252,8 @@ cleanup: - } - - static char * --unarchive(FILE *src_stream, FILE *out_stream, -- file_header_t *(*get_headers)(FILE *), -+unarchive(struct gzip_handle *src_stream, FILE *out_stream, -+ file_header_t *(*get_headers)(struct gzip_handle *), - void (*free_headers)(file_header_t *), - const int extract_function, - const char *prefix, -@@ -329,7 +307,7 @@ unarchive(FILE *src_stream, FILE *out_st - } - } else { - /* seek past the data entry */ -- seek_sub_file(src_stream, file_entry->size); -+ seek_forward(src_stream, file_entry->size); - } - free_headers(file_entry); - } -@@ -337,108 +315,9 @@ unarchive(FILE *src_stream, FILE *out_st - return buffer; - } - --static file_header_t * --get_header_ar(FILE *src_stream) --{ -- file_header_t *typed; -- union { -- char raw[60]; -- struct { -- char name[16]; -- char date[12]; -- char uid[6]; -- char gid[6]; -- char mode[8]; -- char size[10]; -- char magic[2]; -- } formated; -- } ar; -- static char *ar_long_names; -- -- if (fread(ar.raw, 1, 60, src_stream) != 60) { -- return(NULL); -- } -- archive_offset += 60; -- /* align the headers based on the header magic */ -- if ((ar.formated.magic[0] != '`') || (ar.formated.magic[1] != '\n')) { -- /* some version of ar, have an extra '\n' after each data entry, -- * this puts the next header out by 1 */ -- if (ar.formated.magic[1] != '`') { -- error_msg("Invalid magic"); -- return(NULL); -- } -- /* read the next char out of what would be the data section, -- * if its a '\n' then it is a valid header offset by 1*/ -- archive_offset++; -- if (fgetc(src_stream) != '\n') { -- error_msg("Invalid magic"); -- return(NULL); -- } -- /* fix up the header, we started reading 1 byte too early */ -- /* raw_header[60] wont be '\n' as it should, but it doesnt matter */ -- memmove(ar.raw, &ar.raw[1], 59); -- } -- -- typed = (file_header_t *) xcalloc(1, sizeof(file_header_t)); -- -- typed->size = (size_t) atoi(ar.formated.size); -- /* long filenames have '/' as the first character */ -- if (ar.formated.name[0] == '/') { -- if (ar.formated.name[1] == '/') { -- /* If the second char is a '/' then this entries data section -- * stores long filename for multiple entries, they are stored -- * in static variable long_names for use in future entries */ -- ar_long_names = (char *) xrealloc(ar_long_names, typed->size); -- fread(ar_long_names, 1, typed->size, src_stream); -- archive_offset += typed->size; -- /* This ar entries data section only contained filenames for other records -- * they are stored in the static ar_long_names for future reference */ -- return (get_header_ar(src_stream)); /* Return next header */ -- } else if (ar.formated.name[1] == ' ') { -- /* This is the index of symbols in the file for compilers */ -- seek_sub_file(src_stream, typed->size); -- return (get_header_ar(src_stream)); /* Return next header */ -- } else { -- /* The number after the '/' indicates the offset in the ar data section -- (saved in variable long_name) that conatains the real filename */ -- if (!ar_long_names) { -- error_msg("Cannot resolve long file name"); -- return (NULL); -- } -- typed->name = xstrdup(ar_long_names + atoi(&ar.formated.name[1])); -- } -- } else { -- /* short filenames */ -- typed->name = xcalloc(1, 16); -- strncpy(typed->name, ar.formated.name, 16); -- } -- typed->name[strcspn(typed->name, " /")]='\0'; -- -- /* convert the rest of the now valid char header to its typed struct */ -- parse_mode(ar.formated.mode, &typed->mode); -- typed->mtime = atoi(ar.formated.date); -- typed->uid = atoi(ar.formated.uid); -- typed->gid = atoi(ar.formated.gid); -- -- return(typed); --} -- --static void --free_header_ar(file_header_t *ar_entry) --{ -- if (ar_entry == NULL) -- return; -- -- free(ar_entry->name); -- if (ar_entry->link_name) -- free(ar_entry->link_name); -- -- free(ar_entry); --} -- - - static file_header_t * --get_header_tar(FILE *tar_stream) -+get_header_tar(struct gzip_handle *tar_stream) - { - union { - unsigned char raw[512]; -@@ -467,10 +346,10 @@ get_header_tar(FILE *tar_stream) - long sum = 0; - - if (archive_offset % 512 != 0) { -- seek_sub_file(tar_stream, 512 - (archive_offset % 512)); -+ seek_forward(tar_stream, 512 - (archive_offset % 512)); - } - -- if (fread(tar.raw, 1, 512, tar_stream) != 512) { -+ if (gzip_read(tar_stream, tar.raw, 512) != 512) { - /* Unfortunately its common for tar files to have all sorts of - * trailing garbage, fail silently */ - // error_msg("Couldnt read header"); -@@ -557,7 +436,7 @@ get_header_tar(FILE *tar_stream) - # ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS - case 'L': { - longname = xmalloc(tar_entry->size + 1); -- if(fread(longname, tar_entry->size, 1, tar_stream) != 1) -+ if(gzip_read(tar_stream, longname, tar_entry->size) != tar_entry->size) - return NULL; - longname[tar_entry->size] = '\0'; - archive_offset += tar_entry->size; -@@ -566,7 +445,7 @@ get_header_tar(FILE *tar_stream) - } - case 'K': { - linkname = xmalloc(tar_entry->size + 1); -- if(fread(linkname, tar_entry->size, 1, tar_stream) != 1) -+ if(gzip_read(tar_stream, linkname, tar_entry->size) != tar_entry->size) - return NULL; - linkname[tar_entry->size] = '\0'; - archive_offset += tar_entry->size; -@@ -642,6 +521,9 @@ deb_extract(const char *package_filename - char *ared_file = NULL; - char ar_magic[8]; - int gz_err; -+ struct gzip_handle tar_outer, tar_inner; -+ file_header_t *tar_header; -+ ssize_t len; - - *err = 0; - -@@ -672,111 +554,44 @@ deb_extract(const char *package_filename - /* set the buffer size */ - setvbuf(deb_stream, NULL, _IOFBF, 0x8000); - -- /* check ar magic */ -- fread(ar_magic, 1, 8, deb_stream); -- -- if (strncmp(ar_magic,"!",7) == 0) { -- archive_offset = 8; -+ memset(&tar_outer, 0, sizeof(tar_outer)); -+ tar_outer.file = deb_stream; -+ gzip_exec(&tar_outer, NULL); - -- while ((ar_header = get_header_ar(deb_stream)) != NULL) { -- if (strcmp(ared_file, ar_header->name) == 0) { -- int gunzip_pid = 0; -- FILE *uncompressed_stream; -- /* open a stream of decompressed data */ -- uncompressed_stream = gz_open(deb_stream, &gunzip_pid); -- if (uncompressed_stream == NULL) { -- *err = -1; -- goto cleanup; -- } -+ /* walk through outer tar file to find ared_file */ -+ while ((tar_header = get_header_tar(&tar_outer)) != NULL) { -+ int name_offset = 0; -+ if (strncmp(tar_header->name, "./", 2) == 0) -+ name_offset = 2; - -- archive_offset = 0; -- output_buffer = unarchive(uncompressed_stream, -- out_stream, get_header_tar, -- free_header_tar, -- extract_function, prefix, -- file_list, err); -- fclose(uncompressed_stream); -- gz_err = gz_close(gunzip_pid); -- if (gz_err) -- *err = -1; -- free_header_ar(ar_header); -- break; -- } -- if (fseek(deb_stream, ar_header->size, SEEK_CUR) == -1) { -- opkg_perror(ERROR, "Couldn't fseek into %s", package_filename); -- *err = -1; -- free_header_ar(ar_header); -- goto cleanup; -- } -- free_header_ar(ar_header); -- } -- goto cleanup; -- } else if (strncmp(ar_magic, "\037\213", 2) == 0) { -- /* it's a gz file, let's assume it's an opkg */ -- int unzipped_opkg_pid; -- FILE *unzipped_opkg_stream; -- file_header_t *tar_header; -- archive_offset = 0; -- if (fseek(deb_stream, 0, SEEK_SET) == -1) { -- opkg_perror(ERROR, "Couldn't fseek into %s", package_filename); -- *err = -1; -- goto cleanup; -- } -- unzipped_opkg_stream = gz_open(deb_stream, &unzipped_opkg_pid); -- if (unzipped_opkg_stream == NULL) { -- *err = -1; -- goto cleanup; -- } -+ if (strcmp(ared_file, tar_header->name+name_offset) == 0) { -+ memset(&tar_inner, 0, sizeof(tar_inner)); -+ tar_inner.gzip = &tar_outer; -+ gzip_exec(&tar_inner, NULL); - -- /* walk through outer tar file to find ared_file */ -- while ((tar_header = get_header_tar(unzipped_opkg_stream)) != NULL) { -- int name_offset = 0; -- if (strncmp(tar_header->name, "./", 2) == 0) -- name_offset = 2; -- if (strcmp(ared_file, tar_header->name+name_offset) == 0) { -- int gunzip_pid = 0; -- FILE *uncompressed_stream; -- /* open a stream of decompressed data */ -- uncompressed_stream = gz_open(unzipped_opkg_stream, &gunzip_pid); -- if (uncompressed_stream == NULL) { -- *err = -1; -- goto cleanup; -- } -- archive_offset = 0; -+ archive_offset = 0; - -- output_buffer = unarchive(uncompressed_stream, -- out_stream, -- get_header_tar, -- free_header_tar, -- extract_function, -- prefix, -- file_list, -- err); -+ output_buffer = unarchive(&tar_inner, -+ out_stream, -+ get_header_tar, -+ free_header_tar, -+ extract_function, -+ prefix, -+ file_list, -+ err); - -- free_header_tar(tar_header); -- fclose(uncompressed_stream); -- gz_err = gz_close(gunzip_pid); -- if (gz_err) -- *err = -1; -- break; -- } -- seek_sub_file(unzipped_opkg_stream, tar_header->size); - free_header_tar(tar_header); -+ gzip_close(&tar_inner); -+ break; - } -- fclose(unzipped_opkg_stream); -- gz_err = gz_close(unzipped_opkg_pid); -- if (gz_err) -- *err = -1; - -- goto cleanup; -- } else { -- *err = -1; -- error_msg("%s: invalid magic", package_filename); -+ seek_forward(&tar_outer, tar_header->size); -+ free_header_tar(tar_header); - } - - cleanup: -- if (deb_stream) -- fclose(deb_stream); -+ gzip_close(&tar_outer); -+ - if (file_list) - free(file_list); - ---- /dev/null -+++ b/libbb/gzip.h -@@ -0,0 +1,41 @@ -+/* -+ * Copyright (C) 2016 Jo-Philipp Wich -+ * -+ * Zlib decrompression utility routines. -+ * -+ * 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 Library 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. -+ */ -+ -+#include -+#include -+#include -+ -+struct gzip_handle { -+ FILE *file; -+ struct gzip_handle *gzip; -+ -+ pid_t pid; -+ int rfd, wfd; -+ struct sigaction pipe_sa; -+ pthread_t thread; -+}; -+ -+int gzip_exec(struct gzip_handle *zh, const char *filename); -+ssize_t gzip_read(struct gzip_handle *zh, char *buf, ssize_t len); -+ssize_t gzip_copy(struct gzip_handle *zh, FILE *out, ssize_t len); -+int gzip_close(struct gzip_handle *zh); -+FILE *gzip_fdopen(struct gzip_handle *zh, const char *filename); -+ -+#define gzip_seek(zh, len) gzip_copy(zh, NULL, len) ---- a/libbb/Makefile.am -+++ b/libbb/Makefile.am -@@ -4,9 +4,8 @@ ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\" - - noinst_LIBRARIES = libbb.a - --libbb_a_SOURCES = gz_open.c \ -+libbb_a_SOURCES = \ - libbb.h \ -- unzip.c \ - wfopen.c \ - unarchive.c \ - copy_file.c \ -@@ -20,7 +19,8 @@ libbb_a_SOURCES = gz_open.c \ - parse_mode.c \ - time_string.c \ - all_read.c \ -- mode_string.c -+ mode_string.c \ -+ gzip.c - - libbb_la_CFLAGS = $(ALL_CFLAGS) - #libbb_la_LDFLAGS = -static ---- /dev/null -+++ b/libbb/gzip.c -@@ -0,0 +1,208 @@ -+/* -+ * Copyright (C) 2016 Jo-Philipp Wich -+ * Copyright (C) 2016 Felix Fietkau -+ * -+ * Zlib decrompression utility routines. -+ * -+ * 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 Library 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. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "gzip.h" -+ -+static void -+to_devnull(int fd) -+{ -+ int devnull = open("/dev/null", fd ? O_WRONLY : O_RDONLY); -+ -+ if (devnull >= 0) -+ dup2(devnull, fd); -+ -+ if (devnull > STDERR_FILENO) -+ close(devnull); -+} -+ -+void * -+gzip_thread(void *ptr) -+{ -+ struct gzip_handle *zh = ptr; -+ char buf[4096]; -+ int len, ret; -+ -+ while (1) { -+ if (zh->file) -+ len = fread(buf, 1, sizeof(buf), zh->file); -+ else if (zh->gzip) -+ len = gzip_read(zh->gzip, buf, sizeof(buf)); -+ -+ if (len <= 0) -+ break; -+ -+ do { -+ ret = write(zh->wfd, buf, len); -+ } while (ret == -1 && errno == EINTR); -+ } -+ -+ close(zh->wfd); -+ zh->wfd = -1; -+} -+ -+int -+gzip_exec(struct gzip_handle *zh, const char *filename) -+{ -+ int rpipe[2] = { -1, -1 }, wpipe[2] = { -1, -1 }; -+ struct sigaction pipe_sa = { .sa_handler = SIG_IGN }; -+ -+ zh->rfd = -1; -+ zh->wfd = -1; -+ -+ if (sigaction(SIGPIPE, &pipe_sa, &zh->pipe_sa) < 0) -+ return -1; -+ -+ if (pipe(rpipe) < 0) -+ return -1; -+ -+ if (!filename && pipe(wpipe) < 0) { -+ close(rpipe[0]); -+ close(rpipe[1]); -+ return -1; -+ } -+ -+ zh->pid = vfork(); -+ -+ switch (zh->pid) { -+ case -1: -+ return -1; -+ -+ case 0: -+ to_devnull(STDERR_FILENO); -+ -+ if (filename) { -+ to_devnull(STDIN_FILENO); -+ } -+ else { -+ dup2(wpipe[0], STDIN_FILENO); -+ close(wpipe[0]); -+ close(wpipe[1]); -+ } -+ -+ dup2(rpipe[1], STDOUT_FILENO); -+ close(rpipe[0]); -+ close(rpipe[1]); -+ -+ execlp("gzip", "gzip", "-d", "-c", filename, NULL); -+ exit(-1); -+ -+ default: -+ zh->rfd = rpipe[0]; -+ zh->wfd = wpipe[1]; -+ -+ fcntl(zh->rfd, F_SETFD, fcntl(zh->rfd, F_GETFD) | FD_CLOEXEC); -+ close(rpipe[1]); -+ -+ if (zh->wfd >= 0) { -+ fcntl(zh->wfd, F_SETFD, fcntl(zh->wfd, F_GETFD) | FD_CLOEXEC); -+ close(wpipe[0]); -+ pthread_create(&zh->thread, NULL, gzip_thread, zh); -+ } -+ } -+ -+ return 0; -+} -+ -+ssize_t -+gzip_read(struct gzip_handle *zh, char *buf, ssize_t len) -+{ -+ ssize_t ret; -+ -+ do { -+ ret = read(zh->rfd, buf, len); -+ } while (ret == -1 && errno != EINTR); -+ -+ return ret; -+} -+ -+ssize_t -+gzip_copy(struct gzip_handle *zh, FILE *out, ssize_t len) -+{ -+ char buf[4096]; -+ ssize_t rlen, total = 0; -+ -+ while (len > 0) { -+ rlen = gzip_read(zh, buf, -+ (len > sizeof(buf)) ? sizeof(buf) : len); -+ -+ if (rlen <= 0) -+ break; -+ -+ if (out != NULL) { -+ if (fwrite(buf, 1, rlen, out) != rlen) -+ break; -+ } -+ -+ len -= rlen; -+ total += rlen; -+ } -+ -+ return total; -+} -+ -+FILE * -+gzip_fdopen(struct gzip_handle *zh, const char *filename) -+{ -+ memset(zh, 0, sizeof(*zh)); -+ -+ if (!filename || gzip_exec(zh, filename) < 0) -+ return NULL; -+ -+ fcntl(zh->rfd, F_SETFL, fcntl(zh->rfd, F_GETFL) & ~O_NONBLOCK); -+ -+ return fdopen(zh->rfd, "r"); -+} -+ -+int -+gzip_close(struct gzip_handle *zh) -+{ -+ int code = -1; -+ -+ if (zh->rfd >= 0) -+ close(zh->rfd); -+ -+ if (zh->wfd >= 0) -+ close(zh->wfd); -+ -+ if (zh->pid > 0) { -+ kill(zh->pid, SIGKILL); -+ waitpid(zh->pid, &code, 0); -+ } -+ -+ if (zh->file) -+ fclose(zh->file); -+ -+ if (zh->thread) -+ pthread_join(zh->thread, NULL); -+ -+ sigaction(SIGPIPE, &zh->pipe_sa, NULL); -+ -+ return WIFEXITED(code) ? WEXITSTATUS(code) : -1; -+} ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -3,4 +3,4 @@ bin_PROGRAMS = opkg-cl - - opkg_cl_SOURCES = opkg-cl.c - opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.a \ -- $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS) -+ $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS) -lpthread ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -16,7 +16,7 @@ noinst_PROGRAMS = libopkg_test - #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.a $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS) -+libopkg_test_LDADD = $(top_builddir)/libopkg/libopkg.a $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS) -lpthread - libopkg_test_SOURCE = libopkg_test.c - libopkg_test_LDFLAGS = -static - diff --git a/package/system/opkg/patches/071-use_gzipped_pkg_list.patch b/package/system/opkg/patches/071-use_gzipped_pkg_list.patch deleted file mode 100644 index e102868d36..0000000000 --- a/package/system/opkg/patches/071-use_gzipped_pkg_list.patch +++ /dev/null @@ -1,124 +0,0 @@ ---- 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 -@@ -29,6 +29,7 @@ - #include "sprintf_alloc.h" - #include "file_util.h" - #include "libbb/libbb.h" -+#include "libbb/gzip.h" - - void - pkg_hash_init(void) -@@ -106,8 +107,15 @@ pkg_hash_add_from_file(const char *file_ - char *buf; - const size_t len = 4096; - int ret = 0; -+ struct gzip_handle zh; -+ -+ if (src && src->gzip) { -+ fp = gzip_fdopen(&zh, file_name); -+ } -+ else { -+ fp = fopen(file_name, "r"); -+ } - -- fp = fopen(file_name, "r"); - if (fp == NULL) { - opkg_perror(ERROR, "Failed to open %s", file_name); - return -1; -@@ -155,6 +163,9 @@ pkg_hash_add_from_file(const char *file_ - free(buf); - fclose(fp); - -+ if (src && src->gzip) -+ gzip_close(&zh); -+ - 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 deleted file mode 100644 index 976b97d7d2..0000000000 --- a/package/system/opkg/patches/080-suppress-blank-package-fields.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- 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 deleted file mode 100644 index 7adf92235c..0000000000 --- a/package/system/opkg/patches/090-suppress-blank-provides-field.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- 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 deleted file mode 100644 index 5f65a7540c..0000000000 --- a/package/system/opkg/patches/100-add-force-checksum.patch +++ /dev/null @@ -1,85 +0,0 @@ ---- 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 deleted file mode 100644 index 61f454ae1c..0000000000 --- a/package/system/opkg/patches/110-upgrade.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/libopkg/opkg_install.c -+++ b/libopkg/opkg_install.c -@@ -1405,9 +1405,11 @@ opkg_install_pkg(pkg_t *pkg, int from_up - opkg_state_changed++; - pkg->state_flag |= SF_FILELIST_CHANGED; - -- if (old_pkg) -+ if (old_pkg) { - pkg_remove_orphan_dependent(pkg, old_pkg); -- -+ old_pkg->is_upgrade = 1; -+ 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 +1468,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up - } - - -- 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 @@ pkg_run_script(pkg_t *pkg, const char *s - 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 @@ struct pkg - /* 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 deleted file mode 100644 index 6479d57330..0000000000 --- a/package/system/opkg/patches/200-usign_support.patch +++ /dev/null @@ -1,91 +0,0 @@ ---- 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 - #include - #include - #include -@@ -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 deleted file mode 100644 index c41eab02d3..0000000000 --- a/package/system/opkg/patches/210-add-force-signature.patch +++ /dev/null @@ -1,70 +0,0 @@ ---- 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 deleted file mode 100644 index b674e33a91..0000000000 --- a/package/system/opkg/patches/220-drop-release-support.patch +++ /dev/null @@ -1,812 +0,0 @@ ---- a/libopkg/Makefile.am -+++ b/libopkg/Makefile.am -@@ -15,7 +15,6 @@ opkg_cmd_sources = opkg_cmd.c opkg_cmd.h - 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 @@ opkg_list_sources = conffile.c conffile. - 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 -- --#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 --#include -- --#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 --#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 -- --#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 @@ opkg_update_cmd(int argc, char **argv) - } - - -- 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 - - #include "hash_table.h" --#include "release.h" - #include "pkg.h" - #include "opkg_message.h" - #include "pkg_vec.h" -@@ -184,40 +183,6 @@ pkg_hash_load_feeds(void) - 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 deleted file mode 100644 index 57546bedf1..0000000000 --- a/package/system/opkg/patches/230-drop_md5_support.patch +++ /dev/null @@ -1,192 +0,0 @@ ---- a/libopkg/conffile.c -+++ b/libopkg/conffile.c -@@ -36,7 +36,7 @@ void conffile_deinit(conffile_t *conffil - - 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,23 @@ int conffile_has_been_modified(conffile_ - - 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 -+ if(conffile->value && strlen(conffile->value) > 33) { -+ chksum = file_sha256sum_alloc(root_filename); -+ } else { -+ 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 @@ file_mkdir_hier(const char *path, long m - 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 @@ char *file_md5sum_alloc(const char *file - - 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 @@ resolve_conffiles(pkg_t *pkg) - conffile_list_elt_t *iter; - conffile_t *cf; - char *cf_backup; -- char *md5sum; -+ char *chksum; - - if (conf->noaction) return 0; - -@@ -1093,7 +1093,7 @@ resolve_conffiles(pkg_t *pkg) - - /* Might need to initialize the md5sum for each conffile */ - if (cf->value == NULL) { -- cf->value = file_md5sum_alloc(root_filename); -+ cf->value = file_sha256sum_alloc(root_filename); - } - - if (!file_exists(root_filename)) { -@@ -1105,8 +1105,16 @@ resolve_conffiles(pkg_t *pkg) - - 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 -+ if(cf->value && strlen(cf->value) > 33) { -+ chksum = file_sha256sum_alloc(cf_backup); -+ } else { -+ 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 @@ resolve_conffiles(pkg_t *pkg) - } - } - unlink(cf_backup); -- if (md5sum) -- free(md5sum); -+ if (chksum) -+ free(chksum); - } - - free(cf_backup); -@@ -1323,6 +1331,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up - } - #endif - -+#ifdef HAVE_MD5 - /* Check for md5 values */ - if (pkg->md5sum) - { -@@ -1346,6 +1355,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up - 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 @@ opkg_list_sources = conffile.c conffile. - 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 -@@ -68,10 +68,19 @@ AC_ARG_ENABLE(sha256, - (sha256.{c,h} are GPLv3 licensed) [[default=no]] ]), - [want_sha256="$enableval"], [want_sha256="no"]) - -+AC_ARG_ENABLE(md5, -+ AC_HELP_STRING([--enable-md5], [Enable md5sum check -+ (md5.{c,h} are GPLv3 licensed) [[default=no]] ]), -+ [want_md5="$enableval"], [want_md5="yes"]) -+ - if test "x$want_sha256" = "xyes"; then - AC_DEFINE(HAVE_SHA256, 1, [Define if you want sha256 support]) - fi -+if test "x$want_md5" = "xyes"; then -+ AC_DEFINE(HAVE_MD5, 1, [Define if you want md5 support]) -+fi - AM_CONDITIONAL(HAVE_SHA256, test "x$want_sha256" = "xyes") -+AM_CONDITIONAL(HAVE_MD5, test "x$want_md5" = "xyes") - - # check for openssl - AC_ARG_ENABLE(openssl, ---- a/libopkg/pkg_parse.c -+++ b/libopkg/pkg_parse.c -@@ -49,9 +49,9 @@ parse_status(pkg_t *pkg, const char *sst - static void - parse_conffiles(pkg_t *pkg, const char *cstr) - { -- char file_name[1024], md5sum[35]; -+ char file_name[1024], md5sum[85]; - -- if (sscanf(cstr, "%1023s %34s", file_name, md5sum) != 2) { -+ if (sscanf(cstr, "%1023s %84s", file_name, md5sum) != 2) { - opkg_msg(ERROR, "Failed to parse Conffiles line for %s\n", - pkg->name); - return; 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 deleted file mode 100644 index 8af4d4071d..0000000000 --- a/package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- 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 deleted file mode 100644 index d0d0707836..0000000000 --- a/package/system/opkg/patches/250-add-lists-dir-switch.patch +++ /dev/null @@ -1,39 +0,0 @@ ---- 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 deleted file mode 100644 index 4dce356e67..0000000000 --- a/package/system/opkg/patches/260-add-print-package-size.patch +++ /dev/null @@ -1,74 +0,0 @@ ---- 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); - } - diff --git a/package/system/opkg/patches/270-fix-use-after-free.patch b/package/system/opkg/patches/270-fix-use-after-free.patch deleted file mode 100644 index 96e24b9456..0000000000 --- a/package/system/opkg/patches/270-fix-use-after-free.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libopkg/opkg_download.c -+++ b/libopkg/opkg_download.c -@@ -335,7 +335,7 @@ opkg_prepare_url_for_install(const char - hash_insert_pkg(pkg, 1); - - if (namep) { -- *namep = pkg->name; -+ *namep = xstrdup(pkg->name); - } - return 0; - } diff --git a/package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch b/package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch deleted file mode 100644 index 6abbd5df8e..0000000000 --- a/package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch +++ /dev/null @@ -1,73 +0,0 @@ -From a8555d352d2851ee1482b74b57ba9eacfb354c18 Mon Sep 17 00:00:00 2001 -From: Peter Urbanec -Date: Thu, 23 Oct 2014 01:05:35 +1100 -Subject: [PATCH] opkg_install: Call prerm and postrm scripts on package - upgrade - -When upgrading a package from v1 to v2, run "v1-prerm upgrade v2" and -"v1-postrm upgrade v2", similarly to what dpkg does. - -This patch fixes issue 104. - -Signed-off-by: Peter Urbanec -Signed-off-by: Paul Barker ---- - libopkg/opkg_install.c | 40 ++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 38 insertions(+), 2 deletions(-) - ---- a/libopkg/opkg_install.c -+++ b/libopkg/opkg_install.c -@@ -528,7 +528,25 @@ prerm_upgrade_old_pkg(pkg_t *pkg, pkg_t - Error unwind, for both the above cases: - old-postinst abort-upgrade new-version - */ -- return 0; -+ int err; -+ char *script_args; -+ char *new_version; -+ -+ if (!old_pkg || !pkg) -+ return 0; -+ -+ new_version = pkg_version_str_alloc(pkg); -+ -+ sprintf_alloc(&script_args, "upgrade %s", new_version); -+ free(new_version); -+ err = pkg_run_script(old_pkg, "prerm", script_args); -+ free(script_args); -+ if (err != 0) { -+ opkg_msg(ERROR, "prerm script for package \"%s\" failed\n", -+ old_pkg->name); -+ return -1; -+ } -+ return 0; - } - - static int -@@ -925,7 +943,25 @@ postrm_upgrade_old_pkg(pkg_t *pkg, pkg_t - new-postrm failed-upgrade old-version - Error unwind, for both cases: - old-preinst abort-upgrade new-version */ -- return 0; -+ int err; -+ char *script_args; -+ char *new_version; -+ -+ if (!old_pkg || !pkg) -+ return 0; -+ -+ new_version = pkg_version_str_alloc(pkg); -+ -+ sprintf_alloc(&script_args, "upgrade %s", new_version); -+ free(new_version); -+ err = pkg_run_script(old_pkg, "postrm", script_args); -+ free(script_args); -+ if (err != 0) { -+ opkg_msg(ERROR, "postrm script for package \"%s\" failed\n", -+ old_pkg->name); -+ return -1; -+ } -+ return 0; - } - - static int diff --git a/package/system/opkg/patches/290-clarify-download-errors.patch b/package/system/opkg/patches/290-clarify-download-errors.patch deleted file mode 100644 index 5512f675d8..0000000000 --- a/package/system/opkg/patches/290-clarify-download-errors.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- a/libopkg/opkg_cmd.c -+++ b/libopkg/opkg_cmd.c -@@ -85,6 +85,7 @@ opkg_update_cmd(int argc, char **argv) - char *tmp; - int err; - int failures; -+ int pkglist_dl_error; - char *lists_dir; - pkg_src_list_elt_t *iter; - pkg_src_t *src; -@@ -130,15 +131,19 @@ 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); -+ pkglist_dl_error = 0; - if (opkg_download(url, list_file_name, NULL, NULL, 0)) { - failures++; -+ pkglist_dl_error = 1; -+ opkg_msg(NOTICE, "*** Failed to download the package list from %s\n\n", -+ url); - } else { -- opkg_msg(NOTICE, "Updated list of available packages in %s.\n", -+ opkg_msg(NOTICE, "Updated list of available packages in %s\n", - list_file_name); - } - free(url); - #if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN) -- if (conf->check_signature) { -+ if (pkglist_dl_error == 0 && conf->check_signature) { - /* download detached signitures to verify the package lists */ - /* get the url for the sig file */ - if (src->extra_data) /* debian style? */ -@@ -156,7 +161,7 @@ opkg_update_cmd(int argc, char **argv) - err = opkg_download(url, tmp_file_name, NULL, NULL, 0); - if (err) { - failures++; -- opkg_msg(NOTICE, "Signature check failed.\n"); -+ opkg_msg(NOTICE, "Signature file download failed.\n"); - } else { - err = opkg_verify_file (list_file_name, tmp_file_name); - if (err == 0) ---- a/libopkg/opkg_download.c -+++ b/libopkg/opkg_download.c -@@ -91,7 +91,7 @@ opkg_download(const char *src, const cha - char *src_base = basename(src_basec); - char *tmp_file_location; - -- opkg_msg(NOTICE,"Downloading %s.\n", src); -+ opkg_msg(NOTICE,"Downloading %s\n", src); - - if (str_starts_with(src, "file:")) { - const char *file_src = src + 5; -@@ -175,6 +175,8 @@ opkg_download(const char *src, const cha - - if (res) { - opkg_msg(ERROR, "Failed to download %s, wget returned %d.\n", src, res); -+ if (res == 4) -+ opkg_msg(ERROR, "Check your network settings and connectivity.\n\n"); - free(tmp_file_location); - return -1; - } -- 2.30.2