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 UPDURL="${2}" 0011 0012 if [ -z $APPIMAGE_PATH ]; then 0013 echo "path to appimage (arg1) is not set" 0014 exit 1 0015 fi 0016 0017 if [ -z $UPDURL ]; then 0018 echo "update url (arg2) is not set" 0019 exit 1 0020 fi 0021 0022 0023 tempdir="$(mktemp rewrite_appimage_updinfo.XXXXXX -d -p /tmp)" 0024 0025 destination=$(basename $APPIMAGE_PATH) 0026 updinfo_file="${tempdir}/upd_info" 0027 0028 echo -n "zsync|${UPDURL}" > $updinfo_file 0029 0030 # get offsets and lengths of .upd_info section of the AppImage 0031 OFFSET=$(objdump -h "${APPIMAGE_PATH}" | grep .upd_info | awk '{print $6}') 0032 LENGTH=$(objdump -h "${APPIMAGE_PATH}" | grep .upd_info | awk '{print $3}') 0033 0034 # Null the section 0035 dd if=/dev/zero bs=1 seek=$(($(echo 0x$OFFSET))) count=$(($(echo 0x$LENGTH))) of="${APPIMAGE_PATH}" conv=notrunc 0036 0037 # Embed the updinfo 0038 dd if=${updinfo_file} bs=1 seek=$(($(echo 0x$OFFSET))) count=$(($(echo 0x$LENGTH))) of="${APPIMAGE_PATH}" conv=notrunc 0039 0040 # cleanup 0041 rm -rf $tempdir