From be1c5f5d1d07a386dac8de287c482ffda90e9d3d Mon Sep 17 00:00:00 2001 From: wardwouts Date: Wed, 1 Dec 2021 21:35:47 +0100 Subject: [PATCH] build: Added AppImage builder (#355) * Docker files to create an AppImage * Using ENTRYPOINT is a bit nicer here * typo * put with other dist files --- dist/AppImage/AppRun | 12 +++++++ dist/AppImage/Dockerfile | 61 ++++++++++++++++++++++++++++++++++++ dist/AppImage/ImHex.desktop | 6 ++++ dist/AppImage/README.md | 3 ++ dist/AppImage/build.sh | 14 +++++++++ dist/AppImage/extract.sh | 26 +++++++++++++++ dist/AppImage/imhex.png | Bin 0 -> 3410 bytes 7 files changed, 122 insertions(+) create mode 100644 dist/AppImage/AppRun create mode 100644 dist/AppImage/Dockerfile create mode 100644 dist/AppImage/ImHex.desktop create mode 100644 dist/AppImage/README.md create mode 100755 dist/AppImage/build.sh create mode 100755 dist/AppImage/extract.sh create mode 100644 dist/AppImage/imhex.png diff --git a/dist/AppImage/AppRun b/dist/AppImage/AppRun new file mode 100644 index 000000000..2f9426cc2 --- /dev/null +++ b/dist/AppImage/AppRun @@ -0,0 +1,12 @@ +#!/bin/sh +SELF=$(readlink -f "$0") +HERE=${SELF%/*} +export PATH="${HERE}/usr/bin/:${HERE}/usr/sbin/:${HERE}/usr/games/:${HERE}/bin/:${HERE}/sbin/${PATH:+:$PATH}" +export LD_LIBRARY_PATH="${HERE}/usr/lib/:${HERE}/usr/lib/i386-linux-gnu/:${HERE}/usr/lib/x86_64-linux-gnu/:${HERE}/usr/lib32/:${HERE}/usr/lib64/:${HERE}/lib/:${HERE}/lib/i386-linux-gnu/:${HERE}/lib/x86_64-linux-gnu/:${HERE}/lib32/:${HERE}/lib64/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" +export PYTHONPATH="${HERE}/usr/share/pyshared/${PYTHONPATH:+:$PYTHONPATH}" +export XDG_DATA_DIRS="${HERE}/usr/share/${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}" +export PERLLIB="${HERE}/usr/share/perl5/:${HERE}/usr/lib/perl5/${PERLLIB:+:$PERLLIB}" +export GSETTINGS_SCHEMA_DIR="${HERE}/usr/share/glib-2.0/schemas/${GSETTINGS_SCHEMA_DIR:+:$GSETTINGS_SCHEMA_DIR}" +export QT_PLUGIN_PATH="${HERE}/usr/lib/qt4/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt4/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt4/plugins/:${HERE}/usr/lib32/qt4/plugins/:${HERE}/usr/lib64/qt4/plugins/:${HERE}/usr/lib/qt5/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt5/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt5/plugins/:${HERE}/usr/lib32/qt5/plugins/:${HERE}/usr/lib64/qt5/plugins/${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}" +EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 1) +exec "${EXEC}" "$@" diff --git a/dist/AppImage/Dockerfile b/dist/AppImage/Dockerfile new file mode 100644 index 000000000..d52b3754e --- /dev/null +++ b/dist/AppImage/Dockerfile @@ -0,0 +1,61 @@ +FROM debian:bullseye-slim +LABEL maintainer Example + +ARG TAG=master + +USER root + +# Bring packages up to date +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get autoremove -y \ + && apt-get install -y \ + git \ + cmake \ + curl \ + libfuse2 \ + file + +# Fetch source and dependencies +RUN mkdir -p /source \ + && cd /source \ + && git clone https://github.com/WerWolv/ImHex.git \ + && cd ImHex \ + && git checkout $TAG \ + && git submodule update --init --recursive \ + && cd /source/ImHex/dist \ + && ./get_deps_debian.sh + +ARG CXX=g++-10 + +# Build ImHex +RUN mkdir -p /source/ImHex/build \ + && cd /source/ImHex/build \ + && cmake --install-prefix /usr -DCMAKE_BUILD_TYPE=Release .. \ + && make -j + +# Prepare for AppImage +RUN mkdir -p /source/ImHex.AppDir/usr/bin \ + && mkdir -p /source/ImHex.AppDir/usr/lib \ + && mkdir -p /source/ImHex.AppDir/usr/share/imhex/plugins \ + && cp /source/ImHex/build/imhex /source/ImHex.AppDir/usr/bin/imhex \ + && cp /source/ImHex/build/plugins/builtin/builtin.hexplug /source/ImHex.AppDir/usr/share/imhex/plugins + +COPY AppRun ImHex.desktop imhex.png /source/ImHex.AppDir/ +#RUN inkscape -z -o /source/ImHex.AppDir/imhex.png -w 128 -h 128 /source/ImHex/res/icon.svg + +# Gather the needed libraries +RUN chmod a+x /source/ImHex.AppDir/AppRun \ + && ldd /source/ImHex/build/imhex | awk '/ => /{print $3}' | xargs -I '{}' cp '{}' /source/ImHex.AppDir/usr/lib + +# Package the prepared AppDir +RUN cd /source \ + && curl -L https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage -o appimagetool-x86_64.AppImage \ + && chmod a+x appimagetool-x86_64.AppImage + +# All that remains is the following. However, due to docker limitations with fuse +# this cannot be done in a build container. +# +# /source/appimagetool-x86_64.AppImage ImHex.AppDir + +ENTRYPOINT sh -c '/source/appimagetool-x86_64.AppImage /source/ImHex.AppDir; sleep 60' diff --git a/dist/AppImage/ImHex.desktop b/dist/AppImage/ImHex.desktop new file mode 100644 index 000000000..87dc46e13 --- /dev/null +++ b/dist/AppImage/ImHex.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=ImHex +Exec=imhex +Icon=imhex +Type=Application +Categories=Utility; diff --git a/dist/AppImage/README.md b/dist/AppImage/README.md new file mode 100644 index 000000000..15a701ee2 --- /dev/null +++ b/dist/AppImage/README.md @@ -0,0 +1,3 @@ +The environment variable TAG can be set to build for a specific git tag. Without the master branch is build. + +First run `build.sh` to create a docker image. Then run `extract.sh` to get an AppImage. diff --git a/dist/AppImage/build.sh b/dist/AppImage/build.sh new file mode 100755 index 000000000..9a90ccc4c --- /dev/null +++ b/dist/AppImage/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Set the TAG environment variable to build a specific tag + +# Make sure we're in the same direcotry as this script +pushd $(dirname "$(realpath "$0")") + +if [ -z "$TAG" ]; then + docker build -t imhex-appimage-build . +else + docker build --build-arg=TAG=$TAG -t imhex-appimage-build-$TAG . +fi + +popd diff --git a/dist/AppImage/extract.sh b/dist/AppImage/extract.sh new file mode 100755 index 000000000..3c43e74bf --- /dev/null +++ b/dist/AppImage/extract.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Set the TAG environment variable to move to a versioned name while extracting + +# Make sure we're in the same direcotry as this script +pushd $(dirname "$(realpath "$0")") + +# Remove old containers +docker rm imhex 2>&1 > /dev/null + +# AppImage uses FUSE, which makes --device /dev/fuse --cap-add SYS_ADMIN necessary here +# on Debian --security-opt apparmor:unconfined is also needed +if [ -z "$TAG" ]; then + docker run -d --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined --name imhex imhex-appimage-build +else + docker run -d --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined --name imhex imhex-appimage-build-$TAG +fi +sleep 10 +docker cp imhex:/ImHex-x86_64.AppImage . + +# Move to tagged name if $TAG set +if [ -n "$TAG" ]; then + mv ImHex-x86_64.AppImage ImHex-${TAG}-x86_64.AppImage +fi + +popd diff --git a/dist/AppImage/imhex.png b/dist/AppImage/imhex.png new file mode 100644 index 0000000000000000000000000000000000000000..2f993194cbdf7f99d6cf1a8e9532bfb54df7f1d5 GIT binary patch literal 3410 zcmV-Y4XyHtP) z0008>0n+ITDgXcg8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H14Btsa zK~#90?VU}G97h$$|JC!g-|^ax92;ASu>m6@kpsvlBqT%t1rQRJI7YyMgAW{XfEyB0 zjtD7tBm`WzzzK1Q6cAVfg%1(1WFdkK#&&Eg_Ih{6vor3g$Du!_yQjLls=8{rcD8=j z?Cf~^> z`{zI2_|-Rmhp5&}kS{a_pa>FR`Z#;L^j7+yU{=#Rj4A#$lc|5%H0Fj3)7Frj;#s^-y`nm4P_N$9mC{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