libopkg: fix SHA256 calculation for big endian system
authorJonas Gorski <jonas.gorski@gmail.com>
Sat, 18 Nov 2017 11:30:11 +0000 (12:30 +0100)
committerJonas Gorski <jonas.gorski@gmail.com>
Mon, 4 Dec 2017 14:01:01 +0000 (15:01 +0100)
The SHA256 implementation relied on WORDS_BIGENDIAN being defined for
big endian systems, but this was broken since the switch to cmake,
causing wrong checksums on big endian systems like ar71xx.

Fix this by adding a cmake check for endianess similar to the one done
by the original autotools.

Fixes: e6e6c5a21634 ("build: add cmake build system")
Acked-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
CMakeLists.txt

index 30a5d4410a11d7195a71f4d638cf2d79a22b0316..26230b32cc70447cf6e49910fc4e0f535217612b 100644 (file)
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 2.6)
 
 PROJECT(opkg C)
 
+INCLUDE(TestBigEndian)
+
 SET(HOST_CPU "" CACHE STRING "Override Host CPU")
 SET(BUILD_CPU "" CACHE STRING "Override Host CPU")
 SET(LOCK_FILE "/var/lock/opkg.lock" CACHE STRING "Override lock file path")
@@ -31,6 +33,8 @@ IF(NOT VERSION)
        SET(VERSION "unknown")
 ENDIF()
 
+TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
+
 ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -Wmissing-declarations
        -DDATADIR="/usr/share"
        -DOPKGETCDIR="/etc"
@@ -46,6 +50,10 @@ IF(ENABLE_USIGN)
        ADD_DEFINITIONS(-DHAVE_USIGN)
 ENDIF()
 
+IF(WORDS_BIGENDIAN)
+       ADD_DEFINITIONS(-DWORDS_BIGENDIAN)
+ENDIF()
+
 ADD_SUBDIRECTORY(libbb)
 ADD_SUBDIRECTORY(libopkg)
 ADD_SUBDIRECTORY(src)