From 49ae3803682e68e87e9fab2718ed8641832a0d72 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 30 Nov 2018 23:19:42 +0100 Subject: [PATCH 01/32] Make build of digest and validate tools depend on availability of libssl --- src/CMakeLists.txt | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 622d9a344..d4c740663 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,28 +73,32 @@ target_compile_definitions(AppRun add_sanitizers(AppRun) -add_executable(validate validate.c) +if (NOT libssl) + message(WARNING "Could not find suitable libssl, skipping build of validate and digest") +else() + add_executable(validate validate.c) -target_link_libraries(validate - libappimage_shared - libglib - libssl -) + target_link_libraries(validate + libappimage_shared + libglib + libssl + ) -target_include_directories(validate - PUBLIC $ - INTERFACE $ + INTERFACE $ Date: Fri, 30 Nov 2018 23:21:50 +0100 Subject: [PATCH 02/32] Add cross-compiling CMake toolchain file --- cmake/toolchains/arm-linux-gnueabihf.cmake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cmake/toolchains/arm-linux-gnueabihf.cmake diff --git a/cmake/toolchains/arm-linux-gnueabihf.cmake b/cmake/toolchains/arm-linux-gnueabihf.cmake new file mode 100644 index 000000000..6c755e66e --- /dev/null +++ b/cmake/toolchains/arm-linux-gnueabihf.cmake @@ -0,0 +1,20 @@ +# toolchain file that can be used for cross-compiling AppImageKit using the respective AppImageBuild container + +set(CMAKE_SYSTEM_NAME Linux CACHE STRING "" FORCE) +set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "" FORCE) + +set(triple arm-linux-gnueabihf CACHE STRING "" FORCE) + +set(CMAKE_C_COMPILER "${triple}-gcc" CACHE STRING "" FORCE) +set(CMAKE_CXX_COMPILER "${triple}-g++" CACHE STRING "" FORCE) + +set(TOOLS_PREFIX "${triple}-" CACHE STRING "" FORCE) + +set(DEPENDENCIES_CFLAGS "-I/deps/include" CACHE STRING "" FORCE) +set(DEPENDENCIES_CPPFLAGS "${DEPENDENCIES_CFLAGS}" CACHE STRING "" FORCE) +set(DEPENDENCIES_LDFLAGS "-L/deps/lib/" CACHE STRING "" FORCE) + +# host = target system +# build = build system +# both must be specified +set(EXTRA_CONFIGURE_FLAGS "--host=${triple}" "--build=x86_64-pc-linux-gnu" "--target=${triple}" CACHE STRING "" FORCE) From 281cffbd587149653ac95191f4faabd13a2d3574 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 30 Nov 2018 23:27:51 +0100 Subject: [PATCH 03/32] Cross-build ARM (hard-float) binaries on Travis --- .travis.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 53d4ae62b..eaab9858c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,17 @@ compiler: gcc services: - docker -env: - - ARCH=x86_64 DOCKER_IMAGE=quay.io/appimage/appimagebuild - - ARCH=i686 DOCKER_IMAGE=quay.io/appimage/appimagebuild-i386 +matrix: + include: + - env: ARCH=x86_64 DOCKER_IMAGE=quay.io/appimage/appimagebuild + - env: ARCH=i686 DOCKER_IMAGE=quay.io/appimage/appimagebuild-i386 + - env: ARCH=armhf DOCKER_IMAGE=quay.io/appimage/appimagebuild-armhf-cross + addons: + apt: + # install binfmt support system-wide (for use in Docker containers) + - binfmt-support + # sets up the required binfmt interpreters so that qemu will actually be used (for use in Docker containers) + - qemu-user-static script: - bash travis/travis-build.sh @@ -24,7 +32,7 @@ notifications: - "chat.freenode.net#AppImage" on_success: always # options: [always|never|change] default: always on_failure: always # options: [always|never|change] default: always - on_start: always # options: [always|never|change] default: always + on_start: always # options: [always|never|change] default: always template: - "%{repository} build %{build_number}: %{result} %{build_url}" use_notice: true From 309b6583e6f5c419a2b462d874999b4463bda223 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 30 Nov 2018 23:35:06 +0100 Subject: [PATCH 04/32] Fix Travis build script --- travis/travis-build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/travis/travis-build.sh b/travis/travis-build.sh index 76bc37429..d7810825d 100644 --- a/travis/travis-build.sh +++ b/travis/travis-build.sh @@ -68,7 +68,8 @@ sudo chown -R travis.travis . # remove binaries from output directory ls -al out/ -rm -r out/{appimagetool,validate,digest,mksquashfs,*.AppDir} +rm -r out/{appimagetool,mksquashfs,*.AppDir} +rm -r out/{validate,digest} || true # inspect runtime xxd out/runtime | head -n 1 From 5ce00aecc92a8504a1583fe5bd636c04ed2dd076 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 30 Nov 2018 23:55:49 +0100 Subject: [PATCH 05/32] Fix Travis config file, mk. 1 --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index eaab9858c..b0e5159ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: c -compiler: gcc +sudo: required services: - docker @@ -11,7 +11,6 @@ matrix: - env: ARCH=armhf DOCKER_IMAGE=quay.io/appimage/appimagebuild-armhf-cross addons: apt: - # install binfmt support system-wide (for use in Docker containers) - binfmt-support # sets up the required binfmt interpreters so that qemu will actually be used (for use in Docker containers) - qemu-user-static From f1d2709964818fc88a0e8d0adb10a2062a4d0dff Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 30 Nov 2018 23:57:14 +0100 Subject: [PATCH 06/32] Fix check in CMake --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d4c740663..85a9c0b39 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,7 +73,7 @@ target_compile_definitions(AppRun add_sanitizers(AppRun) -if (NOT libssl) +if (NOT TARGET libssl) message(WARNING "Could not find suitable libssl, skipping build of validate and digest") else() add_executable(validate validate.c) From 9db1117f9e772ec8d904bc9a3aa96227285824ee Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 30 Nov 2018 23:59:10 +0100 Subject: [PATCH 07/32] Fix Travis config file, mk. 2 --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0e5159ef..ded67dabf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,12 @@ matrix: - env: ARCH=armhf DOCKER_IMAGE=quay.io/appimage/appimagebuild-armhf-cross addons: apt: - - binfmt-support - # sets up the required binfmt interpreters so that qemu will actually be used (for use in Docker containers) - - qemu-user-static + update: true + packages: + # install binfmt support system-wide (for use in Docker containers) + - binfmt-support + # sets up the required binfmt interpreters so that qemu will actually be used (for use in Docker containers) + - qemu-user-static script: - bash travis/travis-build.sh From 397a57912f1e7d6cc99b308879bc01f03e822422 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 00:19:00 +0100 Subject: [PATCH 08/32] Use CMake toolchain file for ARM builds --- build.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 315b10c0a..1cec5faf6 100755 --- a/build.sh +++ b/build.sh @@ -72,7 +72,12 @@ cd build # make sure that deps in separate install tree are found export PKG_CONFIG_PATH=/deps/lib/pkgconfig/ -cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON -DAPPIMAGEKIT_PACKAGE_DEBS=ON +# make CMake use the right tools for ARM cross-compiling using toolchain file +if [ "$ARCH" == "armhf" ]; then + export EXTRA_CMAKE_FLAGS="-DCMAKE_TOOLCHAIN_FILE=$HERE/cmake/toolchains/arm-linux-gnueabihf.cmake" +fi + +cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON -DAPPIMAGEKIT_PACKAGE_DEBS=ON "${EXTRA_CMAKE_FLAGS[@]}" make -j$JOBS make install DESTDIR=install_prefix/ From 2c98913d96938ddec7987be606de4d746f926cc4 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 00:39:13 +0100 Subject: [PATCH 09/32] Make CMake find arch specific tools, mk. 1 --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index 1cec5faf6..678a34ed3 100755 --- a/build.sh +++ b/build.sh @@ -74,6 +74,7 @@ export PKG_CONFIG_PATH=/deps/lib/pkgconfig/ # make CMake use the right tools for ARM cross-compiling using toolchain file if [ "$ARCH" == "armhf" ]; then + export PATH=/deps/bin:"$PATH" export EXTRA_CMAKE_FLAGS="-DCMAKE_TOOLCHAIN_FILE=$HERE/cmake/toolchains/arm-linux-gnueabihf.cmake" fi From 47f8043d92b9924d65964b117ac4f3756356adf9 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 01:07:40 +0100 Subject: [PATCH 10/32] Update libappimage --- lib/libappimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libappimage b/lib/libappimage index 8b3969667..36a71a915 160000 --- a/lib/libappimage +++ b/lib/libappimage @@ -1 +1 @@ -Subproject commit 8b3969667004659f0033c71556a161bca3d60690 +Subproject commit 36a71a915737617c5d0e4d00c173d444b7bfe5e8 From f391f65ce60200ef22746b508c2ff989b39438bb Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 01:13:55 +0100 Subject: [PATCH 11/32] Update libappimage --- lib/libappimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libappimage b/lib/libappimage index 36a71a915..e03f497a5 160000 --- a/lib/libappimage +++ b/lib/libappimage @@ -1 +1 @@ -Subproject commit 36a71a915737617c5d0e4d00c173d444b7bfe5e8 +Subproject commit e03f497a53db8a4cbfa4cee1e872a0cacc8fbe90 From dadaf8c0f6d4e95419d0a6d993c7f09203cdbe08 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 01:36:14 +0100 Subject: [PATCH 12/32] Make libssl optional in CMake --- cmake/dependencies.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index d702f96dd..9f7901f00 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -8,8 +8,10 @@ include(${PROJECT_SOURCE_DIR}/lib/libappimage/cmake/scripts.cmake) # the names of the targets need to differ from the library filenames # this is especially an issue with libcairo, where the library is called libcairo # therefore, all libs imported this way have been prefixed with lib -import_pkgconfig_target(TARGET_NAME libssl PKGCONFIG_TARGET openssl) import_pkgconfig_target(TARGET_NAME libfuse PKGCONFIG_TARGET fuse) +# openssl is required for optional tools only, and doesn't need to be enforced +# FIXME: remove dependency to openssl by implementing own SHA hashes in libappimage_hashlib +import_pkgconfig_target(TARGET_NAME libssl PKGCONFIG_TARGET openssl OPTIONAL) if(USE_CCACHE) From c5acd4e4f4ff8f823aca044a2e3e100bf882d2c0 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 01:36:41 +0100 Subject: [PATCH 13/32] Update libappimage --- lib/libappimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libappimage b/lib/libappimage index e03f497a5..521beb6fe 160000 --- a/lib/libappimage +++ b/lib/libappimage @@ -1 +1 @@ -Subproject commit e03f497a53db8a4cbfa4cee1e872a0cacc8fbe90 +Subproject commit 521beb6fe51be81fff162d1eeadc8d3f37375eaf From 2343501cf97bb3a5814cb4ece85c39623ecd6b55 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 01:49:40 +0100 Subject: [PATCH 14/32] Update libappimage --- lib/libappimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libappimage b/lib/libappimage index 521beb6fe..1a99ca0c8 160000 --- a/lib/libappimage +++ b/lib/libappimage @@ -1 +1 @@ -Subproject commit 521beb6fe51be81fff162d1eeadc8d3f37375eaf +Subproject commit 1a99ca0c8fa67307502e2cd3ffb6a77352f92db8 From 6d57b671bf3ad74726b14309240b263151e54b64 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 01:52:51 +0100 Subject: [PATCH 15/32] Don't create new releases if not on main branch --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ded67dabf..75fd123d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,8 @@ after_success: - ls -lh out/* # <= wrong line: see https://travis-ci.org/AppImage/AppImageKit/jobs/347965050#L4211 - ls -lh build/out/* - wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh + # make sure only pushes to rewrite create a new release, otherwise pretend PR and upload to transfer.sh + - if [ "$TRAVIS_BRANCH" != "$TRAVIS_TAG" ] && [ "$TRAVIS_BRANCH" != "appimagetool/master" ]; then export TRAVIS_EVENT_TYPE=pull_request; fi - bash ./upload.sh build/out/* notifications: From 1693cb60b69a4966517f7d4cb1f267f6a6d24799 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 02:10:20 +0100 Subject: [PATCH 16/32] Fix copying of libffi --- build-appdir.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build-appdir.sh b/build-appdir.sh index 6291a3419..153f980e5 100644 --- a/build-appdir.sh +++ b/build-appdir.sh @@ -36,7 +36,11 @@ if [ -d /deps/ ]; then # https://mail.gnome.org/archives/gtk-devel-list/2012-July/msg00062.html if [ "$ARCH" == "x86_64" ]; then cp /usr/lib64/libffi.so.5 "$APPIMAGETOOL_APPDIR"/usr/lib/ - else + elif [ "$ARCH" == "i686" ]; then cp /usr/lib/libffi.so.5 "$APPIMAGETOOL_APPDIR"/usr/lib/ + elif [ "$ARCH" == "armhf" ]; then + cp /deps/lib/libffi.so.6 "$APPIMAGETOOL_APPDIR"/usr/lib/ + else + echo "WARNING: unknown architecture, not bundling libffi" fi fi From e409754848b2b6190594a420c7eed0d4e4fa06d4 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 02:32:56 +0100 Subject: [PATCH 17/32] Make sure the prebuilt libraries in the container will be found --- travis/build-binaries.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/travis/build-binaries.sh b/travis/build-binaries.sh index 75c722780..3292291f5 100644 --- a/travis/build-binaries.sh +++ b/travis/build-binaries.sh @@ -7,4 +7,7 @@ cd /AppImageKit ./build.sh "$@" +# make sure the prebuilt libraries in the container will be found +export LD_LIBRARY_PATH=/deps/lib:"$LD_LIBRARY_PATH" + ./test-appimagetool.sh build/install_prefix/usr/bin/appimagetool From 933a189c9873c3193ca6e87b88847aa49c697151 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 03:29:32 +0100 Subject: [PATCH 18/32] Fix embedding of sections in runtime --- src/build-runtime.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/build-runtime.cmake b/src/build-runtime.cmake index 950f8ef61..563e71140 100644 --- a/src/build-runtime.cmake +++ b/src/build-runtime.cmake @@ -52,15 +52,15 @@ endif() # therefore, we generate 3 suitable files containing blank bytes in the right sizes add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/16_blank_bytes - COMMAND printf '\\0%.0s' {0..15} > ${CMAKE_CURRENT_BINARY_DIR}/16_blank_bytes + COMMAND dd if=/dev/zero bs=1 count=16 of=${CMAKE_CURRENT_BINARY_DIR}/16_blank_bytes ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/1024_blank_bytes - COMMAND printf '\\0%.0s' {0..1023} > ${CMAKE_CURRENT_BINARY_DIR}/1024_blank_bytes + COMMAND dd if=/dev/zero bs=1 count=1024 of=${CMAKE_CURRENT_BINARY_DIR}/1024_blank_bytes ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/8192_blank_bytes - COMMAND printf '\\0%.0s' {0..8191} > ${CMAKE_CURRENT_BINARY_DIR}/8192_blank_bytes + COMMAND dd if=/dev/zero bs=1 count=8192 of=${CMAKE_CURRENT_BINARY_DIR}/8192_blank_bytes ) # compile first raw object (not linked yet) into which the sections will be embedded @@ -77,7 +77,7 @@ add_custom_command( # TODO: find out whether all the sections can be embedded in a single objcopy call add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtime.1.o - COMMAND ${OBJCOPY} --add-section .digest_md5=16_blank_bytes --set-section-flags .digest_md5=noload,readonly runtime.0.o runtime.1.o + COMMAND ${OBJCOPY} --add-section .digest_md5=8192_blank_bytes --set-section-flags .digest_md5=noload,readonly runtime.0.o runtime.1.o MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/runtime.0.o DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/16_blank_bytes WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} From e661277e90fbba63fd0760fd30164cff131c8e38 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 1 Dec 2018 13:17:30 +0100 Subject: [PATCH 19/32] Fix embedding of .digest_md5 section --- src/build-runtime.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build-runtime.cmake b/src/build-runtime.cmake index 563e71140..3cdcb268d 100644 --- a/src/build-runtime.cmake +++ b/src/build-runtime.cmake @@ -77,7 +77,7 @@ add_custom_command( # TODO: find out whether all the sections can be embedded in a single objcopy call add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtime.1.o - COMMAND ${OBJCOPY} --add-section .digest_md5=8192_blank_bytes --set-section-flags .digest_md5=noload,readonly runtime.0.o runtime.1.o + COMMAND ${OBJCOPY} --add-section .digest_md5=16_blank_bytes --set-section-flags .digest_md5=noload,readonly runtime.0.o runtime.1.o MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/runtime.0.o DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/16_blank_bytes WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} From fa8f874f5b4934e27c6e5312efdf1cf764f7409c Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sun, 2 Dec 2018 22:03:19 +0100 Subject: [PATCH 20/32] Also build 64-bit ARM binaries on Travis --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.travis.yml b/.travis.yml index 75fd123d4..7cc9b7802 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,15 @@ matrix: - binfmt-support # sets up the required binfmt interpreters so that qemu will actually be used (for use in Docker containers) - qemu-user-static + - env: ARCH=aarch64 DOCKER_IMAGE=quay.io/appimage/appimagebuild-aarch64-cross + addons: + apt: + update: true + packages: + # install binfmt support system-wide (for use in Docker containers) + - binfmt-support + # sets up the required binfmt interpreters so that qemu will actually be used (for use in Docker containers) + - qemu-user-static script: - bash travis/travis-build.sh From 2c9c45d8ed6162409dfd21b0e710e53529e11106 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sun, 2 Dec 2018 22:51:39 +0100 Subject: [PATCH 21/32] Use proper toolchain for 64-bit ARM builds --- build.sh | 3 +++ cmake/dependencies.cmake | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 678a34ed3..b69e99ab0 100755 --- a/build.sh +++ b/build.sh @@ -76,6 +76,9 @@ export PKG_CONFIG_PATH=/deps/lib/pkgconfig/ if [ "$ARCH" == "armhf" ]; then export PATH=/deps/bin:"$PATH" export EXTRA_CMAKE_FLAGS="-DCMAKE_TOOLCHAIN_FILE=$HERE/cmake/toolchains/arm-linux-gnueabihf.cmake" +elif [ "$ARCH" == "aarch64" ]; then + export PATH=/deps/bin:"$PATH" + export EXTRA_CMAKE_FLAGS="-DCMAKE_TOOLCHAIN_FILE=$HERE/cmake/toolchains/aarch64-linux-gnu.cmake" fi cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON -DAPPIMAGEKIT_PACKAGE_DEBS=ON "${EXTRA_CMAKE_FLAGS[@]}" diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 9f7901f00..c329e8ac0 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -58,7 +58,7 @@ ExternalProject_Add(mksquashfs COMMAND ${SED} -i "s|LIBS += -llzma|LIBS += -Bstatic ${mksquashfs_ldflags}|g" /squashfs-tools/Makefile COMMAND ${SED} -i "s|install: mksquashfs unsquashfs|install: mksquashfs|g" squashfs-tools/Makefile COMMAND ${SED} -i "/cp unsquashfs/d" squashfs-tools/Makefile - BUILD_COMMAND env CC=${CC} CXX=${CXX} LDFLAGS=${LDFLAGS} ${MAKE} -C squashfs-tools/ XZ_SUPPORT=1 mksquashfs + BUILD_COMMAND env CC=${CC} CXX=${CXX} LDFLAGS=${LDFLAGS} CFLAGS=-ggdb ${MAKE} -C squashfs-tools/ XZ_SUPPORT=1 mksquashfs # ${MAKE} install unfortunately expects unsquashfs to be built as well, hence can't install the binary # therefore using built file in SOURCE_DIR # TODO: implement building out of source From 5fd394bbdd7402cbb986d0a76683662d87b94011 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sun, 2 Dec 2018 22:53:40 +0100 Subject: [PATCH 22/32] No need to build mksquashfs with debug information --- cmake/dependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index c329e8ac0..9f7901f00 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -58,7 +58,7 @@ ExternalProject_Add(mksquashfs COMMAND ${SED} -i "s|LIBS += -llzma|LIBS += -Bstatic ${mksquashfs_ldflags}|g" /squashfs-tools/Makefile COMMAND ${SED} -i "s|install: mksquashfs unsquashfs|install: mksquashfs|g" squashfs-tools/Makefile COMMAND ${SED} -i "/cp unsquashfs/d" squashfs-tools/Makefile - BUILD_COMMAND env CC=${CC} CXX=${CXX} LDFLAGS=${LDFLAGS} CFLAGS=-ggdb ${MAKE} -C squashfs-tools/ XZ_SUPPORT=1 mksquashfs + BUILD_COMMAND env CC=${CC} CXX=${CXX} LDFLAGS=${LDFLAGS} ${MAKE} -C squashfs-tools/ XZ_SUPPORT=1 mksquashfs # ${MAKE} install unfortunately expects unsquashfs to be built as well, hence can't install the binary # therefore using built file in SOURCE_DIR # TODO: implement building out of source From 15e6583e583180833be0970d5f0b7787e4fab66b Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Mon, 3 Dec 2018 01:29:48 +0100 Subject: [PATCH 23/32] Actually add aarch64 toolchain --- cmake/toolchains/aarch64-linux-gnu.cmake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cmake/toolchains/aarch64-linux-gnu.cmake diff --git a/cmake/toolchains/aarch64-linux-gnu.cmake b/cmake/toolchains/aarch64-linux-gnu.cmake new file mode 100644 index 000000000..4b35337c3 --- /dev/null +++ b/cmake/toolchains/aarch64-linux-gnu.cmake @@ -0,0 +1,20 @@ +# toolchain file that can be used for cross-compiling AppImageKit using the respective AppImageBuild container + +set(CMAKE_SYSTEM_NAME Linux CACHE STRING "" FORCE) +set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "" FORCE) + +set(triple aarch64-linux-gnu CACHE STRING "" FORCE) + +set(CMAKE_C_COMPILER "${triple}-gcc" CACHE STRING "" FORCE) +set(CMAKE_CXX_COMPILER "${triple}-g++" CACHE STRING "" FORCE) + +set(TOOLS_PREFIX "${triple}-" CACHE STRING "" FORCE) + +set(DEPENDENCIES_CFLAGS "-I/deps/include" CACHE STRING "" FORCE) +set(DEPENDENCIES_CPPFLAGS "${DEPENDENCIES_CFLAGS}" CACHE STRING "" FORCE) +set(DEPENDENCIES_LDFLAGS "-L/deps/lib/" CACHE STRING "" FORCE) + +# host = target system +# build = build system +# both must be specified +set(EXTRA_CONFIGURE_FLAGS "--host=${triple}" "--build=x86_64-pc-linux-gnu" "--target=${triple}" CACHE STRING "" FORCE) From 3f9363971893a131e3a3fdadbc7cd79dc9bb7f15 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Mon, 3 Dec 2018 23:58:00 +0100 Subject: [PATCH 24/32] Fix permissions --- travis/build-appimage.sh | 0 travis/build-binaries.sh | 0 travis/test-appimage.sh | 0 travis/travis-build.sh | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 travis/build-appimage.sh mode change 100644 => 100755 travis/build-binaries.sh mode change 100644 => 100755 travis/test-appimage.sh mode change 100644 => 100755 travis/travis-build.sh diff --git a/travis/build-appimage.sh b/travis/build-appimage.sh old mode 100644 new mode 100755 diff --git a/travis/build-binaries.sh b/travis/build-binaries.sh old mode 100644 new mode 100755 diff --git a/travis/test-appimage.sh b/travis/test-appimage.sh old mode 100644 new mode 100755 diff --git a/travis/travis-build.sh b/travis/travis-build.sh old mode 100644 new mode 100755 From c777bd4012980259d850994b031041795770a488 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Tue, 4 Dec 2018 22:22:42 +0100 Subject: [PATCH 25/32] Bundle libffi on aarch64, too --- build-appdir.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-appdir.sh b/build-appdir.sh index 153f980e5..6aaa7b3ad 100644 --- a/build-appdir.sh +++ b/build-appdir.sh @@ -38,7 +38,7 @@ if [ -d /deps/ ]; then cp /usr/lib64/libffi.so.5 "$APPIMAGETOOL_APPDIR"/usr/lib/ elif [ "$ARCH" == "i686" ]; then cp /usr/lib/libffi.so.5 "$APPIMAGETOOL_APPDIR"/usr/lib/ - elif [ "$ARCH" == "armhf" ]; then + elif [ "$ARCH" == "armhf" ] || [ "$ARCH" == "aarch64" ]; then cp /deps/lib/libffi.so.6 "$APPIMAGETOOL_APPDIR"/usr/lib/ else echo "WARNING: unknown architecture, not bundling libffi" From 42afa7327d0b1a3144ac1aa9bcf464c0e1de1e93 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Tue, 4 Dec 2018 23:29:11 +0100 Subject: [PATCH 26/32] Cannot test cross-compiled ARM AppImages outside suitable environment --- travis/travis-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/travis-build.sh b/travis/travis-build.sh index d7810825d..f1645cda6 100755 --- a/travis/travis-build.sh +++ b/travis/travis-build.sh @@ -57,7 +57,7 @@ cd build/ # test AppImages [ "$ARCH" == "i686" ] && sudo apt-get update && sudo apt-get install -y gcc-multilib lib32z1 libfuse2 libfuse2:i386 libglib2.0-0:i386 libcairo2:i386 -bash -x ../travis/test-appimage.sh +[ "$ARCH" != "armhf" ] && [ "$ARCH" != "aarch64" ] && bash -x ../travis/test-appimage.sh # install more tools # (vim-common contains xxd) From b53f21f39c0659b9dbdea06b7432d3a403f3e2af Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Tue, 4 Dec 2018 23:42:57 +0100 Subject: [PATCH 27/32] Make script crash on error --- travis/build-appimage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/build-appimage.sh b/travis/build-appimage.sh index 5ec704cdc..6b6b05cfa 100755 --- a/travis/build-appimage.sh +++ b/travis/build-appimage.sh @@ -8,4 +8,4 @@ cd out/ ./appimagetool.AppDir/AppRun ./appimagetool.AppDir/ -s -v \ -u "gh-releases-zsync|AppImage|AppImageKit|continuous|appimagetool-$ARCH.AppImage.zsync" \ - appimagetool-"$ARCH".AppImage || true + appimagetool-"$ARCH".AppImage From f5426cedd90db348df5592dd4843891438bd32bd Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Tue, 4 Dec 2018 23:45:28 +0100 Subject: [PATCH 28/32] Deploy the right zsyncmake and desktop-file-validate --- build-appdir.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-appdir.sh b/build-appdir.sh index 6aaa7b3ad..51cce0dd9 100644 --- a/build-appdir.sh +++ b/build-appdir.sh @@ -20,6 +20,8 @@ mkdir -p "$APPIMAGETOOL_APPDIR"/usr/lib/appimagekit/ # Copy AppDir specific files cp ../resources/AppRun "$APPIMAGETOOL_APPDIR" cp install_prefix/usr/lib/appimagekit/mksquashfs "$APPIMAGETOOL_APPDIR"/usr/lib/appimagekit/ +# prefer binaries from /deps, if available +export PATH=/deps/bin:"$PATH" cp $(which desktop-file-validate) "$APPIMAGETOOL_APPDIR"/usr/bin/ cp $(which zsyncmake) "$APPIMAGETOOL_APPDIR"/usr/bin/ From 3de952d1f6b94218a25bc88bbb59a943a06ba1f5 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Wed, 5 Dec 2018 10:29:38 +0100 Subject: [PATCH 29/32] Fix embedding of magic bytes Screw you once again, printf! --- src/build-runtime.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build-runtime.cmake b/src/build-runtime.cmake index 3cdcb268d..5f579f8b5 100644 --- a/src/build-runtime.cmake +++ b/src/build-runtime.cmake @@ -127,7 +127,7 @@ if(APPIMAGEKIT_EMBED_MAGIC_BYTES) add_custom_command( TARGET runtime POST_BUILD - COMMAND printf '\\x41\\x49\\x02' | dd of=runtime bs=1 seek=8 count=3 conv=notrunc + COMMAND echo -en '\\x41\\x49\\x02' | dd of=runtime bs=1 seek=8 count=3 conv=notrunc ) endif() From d48de6d288101e46c8c2822a086dfebd771396d5 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Wed, 5 Dec 2018 10:50:13 +0100 Subject: [PATCH 30/32] Make sure magic bytes were embedded correctly Not bullet proof, as it doesn't check whether they're at the right position, but it should help recognize major issues with embedding before uploading binaries. --- travis/travis-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/travis-build.sh b/travis/travis-build.sh index f1645cda6..3c0e4749c 100755 --- a/travis/travis-build.sh +++ b/travis/travis-build.sh @@ -72,7 +72,7 @@ rm -r out/{appimagetool,mksquashfs,*.AppDir} rm -r out/{validate,digest} || true # inspect runtime -xxd out/runtime | head -n 1 +xxd out/runtime | head -n 1 | grep "4149 0200" # fix filename for upload mv out/runtime out/runtime-"$ARCH" From 8fa356a772b33d9edccf94d645494e41ce7af3c8 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Wed, 5 Dec 2018 12:29:31 +0100 Subject: [PATCH 31/32] Fix embedding of magic bytes, mk. 2 --- src/build-runtime.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build-runtime.cmake b/src/build-runtime.cmake index 5f579f8b5..e17698378 100644 --- a/src/build-runtime.cmake +++ b/src/build-runtime.cmake @@ -127,7 +127,7 @@ if(APPIMAGEKIT_EMBED_MAGIC_BYTES) add_custom_command( TARGET runtime POST_BUILD - COMMAND echo -en '\\x41\\x49\\x02' | dd of=runtime bs=1 seek=8 count=3 conv=notrunc + COMMAND echo -en 'AI\\x02' | dd of=runtime bs=1 seek=8 count=3 conv=notrunc ) endif() From 0691b2c0d9d2c8d7c583a1b283fe69c3a67e0bc5 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Wed, 5 Dec 2018 12:35:24 +0100 Subject: [PATCH 32/32] Fix embedding of magic bytes, mk. 3 --- src/build-runtime.cmake | 2 +- src/embed-magic-bytes-in-file.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100755 src/embed-magic-bytes-in-file.sh diff --git a/src/build-runtime.cmake b/src/build-runtime.cmake index e17698378..4a28d4a16 100644 --- a/src/build-runtime.cmake +++ b/src/build-runtime.cmake @@ -127,7 +127,7 @@ if(APPIMAGEKIT_EMBED_MAGIC_BYTES) add_custom_command( TARGET runtime POST_BUILD - COMMAND echo -en 'AI\\x02' | dd of=runtime bs=1 seek=8 count=3 conv=notrunc + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/embed-magic-bytes-in-file.sh ${CMAKE_CURRENT_BINARY_DIR}/runtime ) endif() diff --git a/src/embed-magic-bytes-in-file.sh b/src/embed-magic-bytes-in-file.sh new file mode 100755 index 000000000..23a8a97a4 --- /dev/null +++ b/src/embed-magic-bytes-in-file.sh @@ -0,0 +1,8 @@ +#! /bin/bash + +if [ "$1" == "" ]; then + echo "Usage: bash $0 " + exit 2 +fi + +echo -ne 'AI\x02' | dd of="$1" bs=1 count=3 seek=8 conv=notrunc