appimage: fix possible issue with the appimagetool binary (#14717)

Zero-out AppImage magic bytes from the ELF header extended ABI version so
binfmt+qemu can be used (e.g. when executed from `docker run --platform …`).

Cf.:
- https://github.com/AppImage/AppImageKit/issues/1056
- https://github.com/AppImage/AppImageSpec/blob/master/draft.md#type-2-image-format
- https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#:~:text=EI_ABIVERSION
This commit is contained in:
Benoit Pierre
2025-12-12 22:59:37 +01:00
committed by GitHub
parent 5c3dfb2d88
commit 3644299a66

View File

@@ -14,7 +14,16 @@ plugins/timesync.koplugin
$(filter-out tools/trace_require.lua tools/wbuilder.lua,$(wildcard tools/*)) $(filter-out tools/trace_require.lua tools/wbuilder.lua,$(wildcard tools/*))
endef endef
update: all appimagetool $(APPIMAGETOOL):
wget -O $(APPIMAGETOOL).part '$(APPIMAGETOOL_URL)'
# Zero-out AppImage magic bytes from the ELF header extended ABI version so
# binfmt+qemu can be used (e.g. when executed from `docker run --platform …`).
# Cf. https://github.com/AppImage/AppImageKit/issues/1056.
printf '\0\0\0' | dd conv=notrunc obs=1 seek=8 of=$(APPIMAGETOOL).part
chmod +x ./$(APPIMAGETOOL).part
mv $(APPIMAGETOOL).part $(APPIMAGETOOL)
update: all $(APPIMAGETOOL)
cd $(INSTALL_DIR)/koreader && '$(abspath tools/mkrelease.sh)' ../appimage/ . $(release_excludes) cd $(INSTALL_DIR)/koreader && '$(abspath tools/mkrelease.sh)' ../appimage/ . $(release_excludes)
cp $(APPIMAGE_DIR)/{AppRun,koreader.desktop} resources/koreader.png $(INSTALL_DIR)/appimage/ cp $(APPIMAGE_DIR)/{AppRun,koreader.desktop} resources/koreader.png $(INSTALL_DIR)/appimage/
sed -e 's/%%VERSION%%/$(VERSION)/' -e 's/%%DATE%%/$(RELEASE_DATE)/' $(PLATFORM_DIR)/common/koreader.metainfo.xml >$(INSTALL_DIR)/appimage/koreader.appdata.xml sed -e 's/%%VERSION%%/$(VERSION)/' -e 's/%%DATE%%/$(RELEASE_DATE)/' $(PLATFORM_DIR)/common/koreader.metainfo.xml >$(INSTALL_DIR)/appimage/koreader.appdata.xml
@@ -24,13 +33,9 @@ ifeq (,$(wildcard $(UBUNTU_LIBBSD)))
echo 'WARNING: not bundling missing $(UBUNTU_LIBBSD)' 1>&2 echo 'WARNING: not bundling missing $(UBUNTU_LIBBSD)' 1>&2
else else
cp $(UBUNTU_LIBBSD) $(INSTALL_DIR)/appimage/libs/ cp $(UBUNTU_LIBBSD) $(INSTALL_DIR)/appimage/libs/
endif
ifeq (,$(wildcard $(APPIMAGETOOL)))
# Download appimagetool.
wget '$(APPIMAGETOOL_URL)'
chmod a+x ./$(APPIMAGETOOL)
endif endif
# Generate AppImage. # Generate AppImage.
ARCH='$(APPIMAGE_ARCH)' ./$(APPIMAGETOOL) --appimage-extract-and-run $(INSTALL_DIR)/appimage $(KOREADER_APPIMAGE) ARCH='$(APPIMAGE_ARCH)' ./$(APPIMAGETOOL) --appimage-extract-and-run $(INSTALL_DIR)/appimage $(KOREADER_APPIMAGE)
PHONY += update PHONY += appimagetool update
SOUND += $(APPIMAGETOOL)