opkg: Fix --force-checksum when using SHA256
[openwrt.git] / package / system / opkg / patches / 240-fix-force-checksum-for-sha256.patch
1 --- a/libopkg/opkg_install.c
2 +++ b/libopkg/opkg_install.c
3 @@ -1364,12 +1364,22 @@ opkg_install_pkg(pkg_t *pkg, int from_up
4           file_sha256 = file_sha256sum_alloc(pkg->local_filename);
5           if (file_sha256 && strcmp(file_sha256, pkg->sha256sum))
6           {
7 -              opkg_msg(ERROR, "Package %s sha256sum mismatch. "
8 -                       "Either the opkg or the package index are corrupt. "
9 -                       "Try 'opkg update'.\n",
10 -                       pkg->name);
11 -              free(file_sha256);
12 -              return -1;
13 +              if (!conf->force_checksum)
14 +              {
15 +                  opkg_msg(ERROR,
16 +                           "Package %s sha256sum mismatch. "
17 +                           "Either the opkg or the package index are corrupt. "
18 +                           "Try 'opkg update'.\n",
19 +                           pkg->name);
20 +                  free(file_sha256);
21 +                  return -1;
22 +              }
23 +              else
24 +              {
25 +                  opkg_msg(NOTICE,
26 +                           "Ignored %s sha256sum mismatch.\n",
27 +                           pkg->name);
28 +              }
29           }
30          if (file_sha256)
31                free(file_sha256);