[OpenWrt-Devel] [PATCH] [package] opkg: Fix --force-checksum when using SHA256

Florian Fieber florian at florianfieber.de
Sun May 24 11:22:38 EDT 2015


Allow installing packages with mismatching SHA256 checksums via

$ opkg install --force-checksum $PACKAGE

Signed-off-by: Florian Fieber <florian at florianfieber.de>
---
 .../240-fix-force-checksum-for-sha256.patch        | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch

diff --git a/package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch b/package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch
new file mode 100644
index 0000000..8af4d40
--- /dev/null
+++ b/package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch
@@ -0,0 +1,31 @@
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -1364,12 +1364,22 @@ opkg_install_pkg(pkg_t *pkg, int from_up
+          file_sha256 = file_sha256sum_alloc(pkg->local_filename);
+          if (file_sha256 && strcmp(file_sha256, pkg->sha256sum))
+          {
+-              opkg_msg(ERROR, "Package %s sha256sum mismatch. "
+-			"Either the opkg or the package index are corrupt. "
+-			"Try 'opkg update'.\n",
+-			pkg->name);
+-              free(file_sha256);
+-              return -1;
++              if (!conf->force_checksum)
++              {
++                  opkg_msg(ERROR,
++                           "Package %s sha256sum mismatch. "
++                           "Either the opkg or the package index are corrupt. "
++                           "Try 'opkg update'.\n",
++                           pkg->name);
++                  free(file_sha256);
++                  return -1;
++              }
++              else
++              {
++                  opkg_msg(NOTICE,
++                           "Ignored %s sha256sum mismatch.\n",
++                           pkg->name);
++              }
+          }
+ 	 if (file_sha256)
+               free(file_sha256);
-- 
2.1.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list