libopkg: drop custom md5 implementation, unconditionally enable sha256 support
[oweals/opkg-lede.git] / libopkg / opkg_install.c
index 55c124b3797f4c0c9737d5fa33628e7b0ab3760d..a2f97c96a321a62c56d32b8683c62c88ecb06718 100644 (file)
@@ -15,8 +15,6 @@
    General Public License for more details.
 */
 
-#include "config.h"
-
 #include <stdio.h>
 #include <time.h>
 #include <signal.h>
@@ -1151,15 +1149,12 @@ static int resolve_conffiles(pkg_t * pkg)
 
                if (file_exists(cf_backup)) {
                        /* Let's compute md5 to test if files are changed */
-#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) {
@@ -1270,9 +1265,7 @@ int opkg_install_pkg(pkg_t * pkg, int from_upgrade)
        abstract_pkg_t *ab_pkg = NULL;
        int old_state_flag;
        char *file_md5, *pkg_md5;
-#ifdef HAVE_SHA256
        char *file_sha256, *pkg_sha256;
-#endif
        sigset_t newset, oldset;
        const char *local_filename;
        time_t now;
@@ -1285,7 +1278,7 @@ int opkg_install_pkg(pkg_t * pkg, int from_upgrade)
        if (!pkg_arch_supported(pkg)) {
                opkg_msg(ERROR,
                         "INTERNAL ERROR: architecture %s for pkg %s is unsupported.\n",
-                        pkg_get_string(pkg, PKG_ARCHITECTURE), pkg->name);
+                        pkg_get_architecture(pkg), pkg->name);
                return -1;
        }
        if (pkg->state_status == SS_INSTALLED && conf->nodeps == 0) {
@@ -1386,9 +1379,8 @@ int opkg_install_pkg(pkg_t * pkg, int from_upgrade)
        }
 #endif
 
-#ifdef HAVE_MD5
        /* Check for md5 values */
-       pkg_md5 = pkg_get_string(pkg, PKG_MD5SUM);
+       pkg_md5 = pkg_get_md5(pkg);
        if (pkg_md5) {
                file_md5 = file_md5sum_alloc(local_filename);
                if (file_md5 && strcmp(file_md5, pkg_md5)) {
@@ -1407,11 +1399,9 @@ int opkg_install_pkg(pkg_t * pkg, int from_upgrade)
                if (file_md5)
                        free(file_md5);
        }
-#endif
 
-#ifdef HAVE_SHA256
        /* Check for sha256 value */
-       pkg_sha256 = pkg_get_string(pkg, PKG_SHA256SUM);
+       pkg_sha256 = pkg_get_sha256(pkg);
        if (pkg_sha256) {
                file_sha256 = file_sha256sum_alloc(local_filename);
                if (file_sha256 && strcmp(file_sha256, pkg_sha256)) {
@@ -1431,7 +1421,7 @@ int opkg_install_pkg(pkg_t * pkg, int from_upgrade)
                if (file_sha256)
                        free(file_sha256);
        }
-#endif
+
        if (conf->download_only) {
                if (conf->nodeps == 0) {
                        err = satisfy_dependencies_for(pkg);