File indexing completed on 2024-11-10 04:05:17
0001 #!/usr/bin/env bash 0002 # 0003 # SPDX-License-Identifier: GPL-3.0-or-later 0004 # 0005 0006 set -x 0007 set -e 0008 0009 APPIMAGE_PATH="${1}" 0010 CHANNEL="${2}" 0011 GPG_KEY="${3}" 0012 0013 if [ -z $APPIMAGE_PATH ]; then 0014 echo "path to appimage (arg1) is not set" 0015 exit 1 0016 fi 0017 0018 if [ -z $CHANNEL ]; then 0019 echo "channel (arg2) is not set" 0020 exit 1 0021 fi 0022 0023 if [ -z $GPG_KEY ]; then 0024 echo "gpg key id (arg3) is not set" 0025 exit 1 0026 fi 0027 0028 tempdir="$(mktemp strip_appimage_signature.XXXXXX -d -p /tmp)" 0029 0030 destination=$(basename $APPIMAGE_PATH) 0031 0032 ascfile="${tempdir}/${destination}.digest.asc" 0033 digestfile="${tempdir}/${destination}.digest" 0034 sigkeyfile="${tempdir}/sig_pubkey" 0035 0036 if [ -f $digestfile ]; then rm $digestfile; fi 0037 if [ -f $ascfile ]; then rm $ascfile; fi 0038 if [ -f $sigkeyfile ]; then rm $sigkeyfile; fi 0039 0040 # get offsets and lengths of .sha256_sig and .sig_key sections of the AppImage 0041 SIG_OFFSET=$(objdump -h "${APPIMAGE_PATH}" | grep .sha256_sig | awk '{print $6}') 0042 SIG_LENGTH=$(objdump -h "${APPIMAGE_PATH}" | grep .sha256_sig | awk '{print $3}') 0043 0044 KEY_OFFSET=$(objdump -h "${APPIMAGE_PATH}" | grep .sig_key | awk '{print $6}') 0045 KEY_LENGTH=$(objdump -h "${APPIMAGE_PATH}" | grep .sig_key | awk '{print $3}') 0046 0047 # Null the sections 0048 dd if=/dev/zero bs=1 seek=$(($(echo 0x$SIG_OFFSET))) count=$(($(echo 0x$SIG_LENGTH))) of="${APPIMAGE_PATH}" conv=notrunc 0049 dd if=/dev/zero bs=1 seek=$(($(echo 0x$KEY_OFFSET))) count=$(($(echo 0x$KEY_LENGTH))) of="${APPIMAGE_PATH}" conv=notrunc 0050 0051 # regenerate zsync file 0052 # TODO: replace with real urls 0053 if [ "$CHANNEL" = "Next" ]; then 0054 URL="http://localhost:8000/nightly" 0055 elif [ "$CHANNEL" = "Plus" ]; then 0056 URL="http://localhost:8000/nightly" 0057 elif [ "$CHANNEL" = "Stable" ]; then 0058 URL="http://localhost:8000/stable" 0059 elif [ "$CHANNEL" = "Beta" ]; then 0060 URL="http://localhost:8000/unstable" 0061 fi 0062 0063 zsyncmake -u "${URL}/$(basename ${APPIMAGE_PATH})" -o $APPIMAGE_PATH.zsync.new $APPIMAGE_PATH 0064 ret=$? 0065 if [ $ret -eq 0 ]; then 0066 mv $APPIMAGE_PATH.zsync.new Krita-${CHANNEL}-x86_64.AppImage.zsync 0067 fi 0068 0069 # cleanup 0070 rm -rf $tempdir