diff --git a/Makefile b/Makefile index 23c4b0c17..0119c09f1 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ endif # releases do not contain tests and misc data IS_RELEASE := $(if $(or $(EMULATE_READER),$(WIN32)),,1) -IS_RELEASE := $(if $(or $(IS_RELEASE),$(APPIMAGE),$(DEBIAN),$(MACOS)),1,) +IS_RELEASE := $(if $(or $(IS_RELEASE),$(APPIMAGE),$(LINUX),$(MACOS)),1,) ifeq ($(ANDROID_ARCH), arm64) ANDROID_ABI?=arm64-v8a @@ -31,6 +31,21 @@ endif ANDROID_VERSION?=$(shell git rev-list --count HEAD) ANDROID_NAME?=$(VERSION) +LINUX_ARCH?=native +ifeq ($(LINUX_ARCH), native) + LINUX_ARCH_NAME:=$(shell uname -m) +else ifeq ($(LINUX_ARCH), arm64) + LINUX_ARCH_NAME:=aarch64 +else ifeq ($(LINUX_ARCH), arm) + LINUX_ARCH_NAME:=armv7l +endif +LINUX_ARCH_NAME?=$(LINUX_ARCH) + +# set PATH to find CC in managed toolchains +ifeq ($(TARGET), android) + PATH:=$(ANDROID_TOOLCHAIN)/bin:$(PATH) +endif + MACHINE=$(shell $(CC) -dumpmachine 2>/dev/null) ifdef KODEBUG MACHINE:=$(MACHINE)-debug @@ -55,7 +70,7 @@ ANDROID_LIBS_ROOT:=$(ANDROID_LAUNCHER_DIR)/libs ANDROID_LIBS_ABI:=$(ANDROID_LIBS_ROOT)/$(ANDROID_ABI) APPIMAGE_DIR=$(PLATFORM_DIR)/appimage CERVANTES_DIR=$(PLATFORM_DIR)/cervantes -DEBIAN_DIR=$(PLATFORM_DIR)/debian +LINUX_DIR=$(PLATFORM_DIR)/linux KINDLE_DIR=$(PLATFORM_DIR)/kindle KOBO_DIR=$(PLATFORM_DIR)/kobo MACOS_DIR=$(PLATFORM_DIR)/mac @@ -100,9 +115,10 @@ endif ifdef ANDROID cd $(INSTALL_DIR)/koreader && \ ln -sf ../../$(ANDROID_DIR)/*.lua . -endif + @echo "[*] Install update once marker" @echo "# This file indicates that update once patches have not been applied yet." > $(INSTALL_DIR)/koreader/update_once.marker +endif ifdef WIN32 @echo "[*] Install runtime libraries for win32..." cd $(INSTALL_DIR)/koreader && cp ../../$(WIN32_DIR)/*.dll . @@ -414,31 +430,44 @@ androidupdate: all cp $(ANDROID_LAUNCHER_DIR)/bin/NativeActivity.apk \ koreader-android-$(ANDROID_ARCH)$(KODEDUG_SUFFIX)-$(VERSION).apk -debianupdate: all +LINUX_PACKAGE:=koreader-linux-$(LINUX_ARCH_NAME)$(KODEDUG_SUFFIX)-$(VERSION).tar.xz +linuxupdate: all mkdir -pv \ - $(INSTALL_DIR)/debian/usr/bin \ - $(INSTALL_DIR)/debian/usr/lib \ - $(INSTALL_DIR)/debian/usr/share/pixmaps \ - $(INSTALL_DIR)/debian/usr/share/applications \ - $(INSTALL_DIR)/debian/usr/share/doc/koreader \ - $(INSTALL_DIR)/debian/usr/share/man/man1 - - cp -pv resources/koreader.png $(INSTALL_DIR)/debian/usr/share/pixmaps - cp -pv $(DEBIAN_DIR)/koreader.desktop $(INSTALL_DIR)/debian/usr/share/applications - cp -pv $(DEBIAN_DIR)/copyright COPYING $(INSTALL_DIR)/debian/usr/share/doc/koreader - cp -pv $(DEBIAN_DIR)/koreader.sh $(INSTALL_DIR)/debian/usr/bin/koreader - cp -Lr $(INSTALL_DIR)/koreader $(INSTALL_DIR)/debian/usr/lib - - gzip -cn9 $(DEBIAN_DIR)/changelog > $(INSTALL_DIR)/debian/usr/share/doc/koreader/changelog.Debian.gz - gzip -cn9 $(DEBIAN_DIR)/koreader.1 > $(INSTALL_DIR)/debian/usr/share/man/man1/koreader.1.gz + $(INSTALL_DIR)/linux/usr/bin \ + $(INSTALL_DIR)/linux/usr/lib \ + $(INSTALL_DIR)/linux/usr/share/pixmaps \ + $(INSTALL_DIR)/linux/usr/share/applications \ + $(INSTALL_DIR)/linux/usr/share/doc/koreader \ + $(INSTALL_DIR)/linux/usr/share/man/man1 + + cp -pv resources/koreader.png $(INSTALL_DIR)/linux/usr/share/pixmaps + cp -pv $(LINUX_DIR)/koreader.desktop $(INSTALL_DIR)/linux/usr/share/applications + cp -pv $(LINUX_DIR)/copyright COPYING $(INSTALL_DIR)/linux/usr/share/doc/koreader + cp -pv $(LINUX_DIR)/koreader.sh $(INSTALL_DIR)/linux/usr/bin/koreader + cp -Lr $(INSTALL_DIR)/koreader $(INSTALL_DIR)/linux/usr/lib + + gzip -cn9 $(LINUX_DIR)/koreader.1 > $(INSTALL_DIR)/linux/usr/share/man/man1/koreader.1.gz chmod 644 \ - $(INSTALL_DIR)/debian/usr/share/doc/koreader/changelog.Debian.gz \ - $(INSTALL_DIR)/debian/usr/share/doc/koreader/copyright \ - $(INSTALL_DIR)/debian/usr/share/man/man1/koreader.1.gz + $(INSTALL_DIR)/linux/usr/share/doc/koreader/copyright \ + $(INSTALL_DIR)/linux/usr/share/man/man1/koreader.1.gz rm -rf \ - $(INSTALL_DIR)/debian/usr/lib/koreader/{ota,cache,clipboard,screenshots,spec,tools,resources/fonts,resources/icons/src} + $(INSTALL_DIR)/linux/usr/lib/koreader/{ota,cache,clipboard,screenshots,spec,tools,l10n/templates,resources/fonts,resources/icons/src} + + # remove leftovers + find $(INSTALL_DIR)/linux -type f \( -name ".git" -o -name ".gitignore" -o -name "discovery2spore" -o -name "wadl2spore" -o -name "*.txt" -o -name "LICENSE*" -o -name "NOTICE" -o -name "README.md" \) -print0 | xargs -0 rm -rf + find $(INSTALL_DIR)/linux -type d \( -name "test" -o -name ".github" \) -print0 | xargs -0 rm -rf + + # fix permissions + find $(INSTALL_DIR)/linux -type d -print0 | xargs -0 chmod 755 + find $(INSTALL_DIR)/linux -executable -type f -print0 | xargs -0 chmod 755 + find $(INSTALL_DIR)/linux -type f \( -name "COPYING" -o -name "git-rev" -o -name "*manifest" -o -name "*.cff" -o -name "*.css" -o -name "*.desktop" -o -name "*.json" -o -name "*.html" -o -name "*.lua" -o -name "*.pattern" -o -name "*.png" -o -name "*.otf" -o -name "*.po*" -o -name "*.so*" -o -name "*.svg" -o -name "*.template" -o -name "*.tpl" -o -name "*.ttf" \) -print0 | xargs -0 chmod 644 + find $(INSTALL_DIR)/linux -type f -name "reader.lua" -print0 | xargs -0 chmod 755 + cd $(INSTALL_DIR)/linux/usr && \ + XZ_OPT=9 tar -cvJf ../../../$(LINUX_PACKAGE) * + + rm -rf $(INSTALL_DIR)/linux macosupdate: all mkdir -p \ @@ -561,18 +590,8 @@ else ifeq ($(TARGET), remarkable) make remarkableupdate else ifeq ($(TARGET), ubuntu-touch) make utupdate -else ifeq ($(TARGET), debian) - make debianupdate - $(CURDIR)/platform/debian/do_debian_package.sh $(INSTALL_DIR) -else ifeq ($(TARGET), debian-armel) - make debianupdate - $(CURDIR)/platform/debian/do_debian_package.sh $(INSTALL_DIR) armel -else ifeq ($(TARGET), debian-armhf) - make debianupdate - $(CURDIR)/platform/debian/do_debian_package.sh $(INSTALL_DIR) armhf -else ifeq ($(TARGET), debian-arm64) - make debianupdate - $(CURDIR)/platform/debian/do_debian_package.sh $(INSTALL_DIR) arm64 +else ifeq ($(TARGET), linux) + make linuxupdate else ifeq ($(TARGET), macos) make macosupdate $(CURDIR)/platform/mac/do_mac_bundle.sh $(INSTALL_DIR) diff --git a/kodev b/kodev index 423b71602..eb2e52d0f 100755 --- a/kodev +++ b/kodev @@ -154,10 +154,7 @@ SUPPORTED_TARGETS=" pocketbook ubuntu-touch appimage - debian Debian package for current arch - debian-armel Debian package for generic armel devices - debian-armhf Debian package for generic armhf devices - debian-arm64 Debian package for generic 64 bits arm devices + linux macos MacOS app bundle. You need a mac to build this package emu (*default) If no TARGET is given, assume emulator win32 @@ -268,20 +265,8 @@ ${SUPPORTED_TARGETS}" make TARGET=appimage assert_ret_zero $? ;; - debian) - make TARGET=debian - assert_ret_zero $? - ;; - debian-armel) - make TARGET=debian-armel - assert_ret_zero $? - ;; - debian-armhf) - make TARGET=debian-armhf - assert_ret_zero $? - ;; - debian-arm64) - make TARGET=debian-arm64 + linux) + make TARGET=linux assert_ret_zero $? ;; macos) @@ -389,17 +374,8 @@ ${SUPPORTED_TARGETS}" appimage) make TARGET=appimage clean ;; - debian) - make TARGET=debian clean - ;; - debian-armel) - make TARGET=debian-armel clean - ;; - debian-armhf) - make TARGET=debian-armhf clean - ;; - debian-arm64) - make TARGET=debian-arm64 clean + linux) + make TARGET=linux clean ;; macos) is_mac @@ -540,21 +516,9 @@ ${SUPPORTED_RELEASE_TARGETS}" kodev-build appimage make TARGET=appimage update ;; - debian) - kodev-build debian - make TARGET=debian update - ;; - debian-armel) - kodev-build debian-armel - make TARGET=debian-armel update - ;; - debian-armhf) - kodev-build debian-armhf - make TARGET=debian-armhf update - ;; - debian-arm64) - kodev-build debian-arm64 - make TARGET=debian-arm64 update + linux) + kodev-build linux + make TARGET=linux update ;; macos) is_mac diff --git a/platform/debian/changelog b/platform/debian/changelog deleted file mode 100644 index 75b094a00..000000000 --- a/platform/debian/changelog +++ /dev/null @@ -1,11 +0,0 @@ -koreader (0.1) unstable; urgency=low - - * Fixes most lintian errors and warnings - - -- Martín Fdez Thu, 14 May 2020 00:00:00 +0100 - -koreader (0.0.1) experimental; urgency=low - - * Initial release as Debian package (Closes: https://github.com/koreader/koreader/issues/3108) - - -- Martín Fdez Tue, 03 Jan 2019 00:00:00 +0100 diff --git a/platform/debian/do_debian_package.sh b/platform/debian/do_debian_package.sh deleted file mode 100755 index 0be09c495..000000000 --- a/platform/debian/do_debian_package.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash -# Script to generate debian packages for KOReader -if [ -z "${1}" ]; then - echo "${0}: can't find KOReader build, please specify a path" - exit 1 -else - INSTALL_DIR="${1}" - VERSION="$(cut -f2 -dv "${1}/koreader/git-rev" | cut -f1,2 -d-)" -fi - -uname_to_debian() { - if [ "$(uname -m)" == "x86_64" ]; then - echo "amd64" - elif [ "$(uname -m)" == "i686" ]; then - echo "i686" - elif [ "$(uname -m)" == "arm64" ]; then - echo "aarch64" - else - echo "any" - fi -} - -link_fonts() { - syspath="../../../../share/fonts/truetype/$(basename "${1}")" - for FILE in *.ttf; do - rm -rf "${FILE}" - ln -s "${syspath}/${FILE}" "${FILE}" - done -} - -if [ -z "${2}" ]; then - ARCH="$(uname_to_debian)" -else - ARCH="${2}" -fi - -command_exists() { - type "$1" >/dev/null 2>/dev/null -} - -# Run only if dpkg-deb exists -COMMAND="dpkg-deb" -if command_exists "${COMMAND}"; then - BASE_DIR="${INSTALL_DIR}/debian/usr" - - # populate debian control file - mkdir -p "${INSTALL_DIR}/debian/DEBIAN" - { - echo "Section: graphics" - echo "Priority: optional" - echo "Depends: libsdl2-2.0-0, fonts-noto-hinted, fonts-droid-fallback, libc6 (>= 2.2.3)" - echo "Architecture: ${ARCH}" - echo "Version: ${VERSION}" - echo "Installed-Size: $(du -ks "${INSTALL_DIR}/debian/usr/" | cut -f 1)" - echo "Package: koreader" - echo "Maintainer: Martín Fdez " - echo "Homepage: https://koreader.rocks" - echo "Description: Ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats" - echo " KOReader is a document viewer for E Ink devices." - echo " Supported fileformats include EPUB, PDF, DjVu, XPS, CBT," - echo " CBZ, FB2, PDB, TXT, HTML, RTF, CHM, DOC, MOBI and ZIP files." - echo " It’s available for Kindle, Kobo, PocketBook, Android and desktop Linux." - - } >"${INSTALL_DIR}/debian/DEBIAN/control" - - # remove leftovers - find "${BASE_DIR}" -type f -name ".git" -print0 | xargs -0 rm -rf - find "${BASE_DIR}" -type f -name ".gitignore" -print0 | xargs -0 rm -rf - find "${BASE_DIR}" -type f -name "discovery2spore" -print0 | xargs -0 rm -rf - find "${BASE_DIR}" -type f -name "wadl2spore" -print0 | xargs -0 rm -rf - find "${BASE_DIR}" -type d -name "test" -print0 | xargs -0 rm -rf - find "${BASE_DIR}" -type f -name "*.txt" -print0 | xargs -0 rm -rf - find "${BASE_DIR}" -type f -name "LICENSE" -print0 | xargs -0 rm -rf - find "${BASE_DIR}" -type f -name "NOTICE" -print0 | xargs -0 rm -rf - find "${BASE_DIR}" -type f -name "README.md" -print0 | xargs -0 rm -rf - find "${BASE_DIR}/lib" -type f -name "COPYING" -print0 | xargs -0 rm -rf - - # fix permissions - find "${BASE_DIR}" -type d -print0 | xargs -0 chmod 755 - find "${BASE_DIR}" -executable -type f -print0 | xargs -0 chmod 755 - find "${BASE_DIR}" -type f -name "*.cff" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "*.html" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "*.lua" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "*manifest" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "*.pattern" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "*.png" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "*.otf" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "*.po*" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "*.so*" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "*.ttf" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "git-rev" -print0 | xargs -0 chmod 644 - find "${BASE_DIR}" -type f -name "reader.lua" -print0 | xargs -0 chmod 755 - - # use absolute path to luajit in reader.lua - sed -i 's/.\/luajit/\/usr\/lib\/koreader\/luajit/' "${BASE_DIR}/lib/koreader/reader.lua" - - # use debian packaged fonts instead of our embedded ones to save a couple of MB. - # Note: avoid linking against fonts-noto-cjk-extra, cause it weights ~200MB. - (cd "${BASE_DIR}/lib/koreader/fonts/noto" && link_fonts "$(pwd)") - - # DroidSansMono has a restrictive license. Replace it with DroidSansFallback - ( - cd "${BASE_DIR}/lib/koreader/fonts/droid" && rm -rf DroidSansMono.ttf && - ln -s ../../../../share/fonts-droid-fallback/truetype/DroidSansFallback.ttf DroidSansMono.ttf - ) - - # try to remove rpath - if command_exists chrpath; then - find "${BASE_DIR}/lib/koreader/libs" -type f -name "*.so*" -print0 | xargs -0 chrpath -d - else - echo "chrpath tool not found. Skipping RPATH deletion" - fi - - (cd "${INSTALL_DIR}/.." && - fakeroot dpkg-deb -b "${INSTALL_DIR}/debian" "koreader-${VERSION}-${ARCH}.deb") -else - echo "${COMMAND} not found, unable to build Debian package" - exit 1 -fi diff --git a/platform/debian/copyright b/platform/linux/copyright similarity index 100% rename from platform/debian/copyright rename to platform/linux/copyright diff --git a/platform/linux/do_debian_package.sh b/platform/linux/do_debian_package.sh new file mode 100755 index 000000000..50ab6739e --- /dev/null +++ b/platform/linux/do_debian_package.sh @@ -0,0 +1,120 @@ +#!/bin/bash + +# Script to generate debian packages for KOReader + +command_exists() { + type "$1" >/dev/null 2>/dev/null +} + +link_fonts() { + syspath="../../../../share/fonts/truetype/$(basename "${1}")" + for FILE in *.ttf; do + rm -rf "${FILE}" + ln -s "${syspath}/${FILE}" "${FILE}" + done +} + +uname_to_debian() { + if [ "${1}" == "x86_64" ]; then + echo "amd64" + elif [ "${1}" == "armv7l" ]; then + echo "armhf" + elif [ "${1}" == "aarch64" ]; then + echo "arm64" + else + echo "${1}" + fi +} + +write_changelog() { + CHANGELOG_PATH="${1}/share/doc/koreader/changelog.Debian.gz" + CHANGELOG=$(cat << 'END_HEREDOC' +koreader (0.1) unstable; urgency=low + + * Fixes most lintian errors and warnings + + -- Martín Fdez Thu, 14 May 2020 00:00:00 +0100 + +koreader (0.0.1) experimental; urgency=low + + * Initial release as Debian package (Closes: https://github.com/koreader/koreader/issues/3108) + + -- Martín Fdez Tue, 03 Jan 2019 00:00:00 +0100 +END_HEREDOC +) + +echo "${CHANGELOG}" | gzip -cn9 > "${CHANGELOG_PATH}" +chmod 644 "${CHANGELOG_PATH}" +} + + +if [ -z "${1}" ]; then + echo "${0}: can't find KOReader archive, please specify a path to a KOReader tar.gz" + exit 1 +else + mkdir -p tmp-debian/usr + chmod 0755 tmp-debian/usr + tar -xf "${1}" -C tmp-debian/usr + ARCH="$(echo "${1}" | cut -d '-' -f3)" + VERSION="$(cut -f2 -dv "tmp-debian/usr/lib/koreader/git-rev" | cut -f1,2 -d-)" + DEB_ARCH="$(uname_to_debian "${ARCH}")" +fi + +# Run only if dpkg-deb exists +COMMAND="dpkg-deb" +if command_exists "${COMMAND}"; then + BASE_DIR="tmp-debian" + + # populate debian control file + mkdir -p "${BASE_DIR}/DEBIAN" + { + echo "Section: graphics" + echo "Priority: optional" + echo "Depends: libsdl2-2.0-0, fonts-noto-hinted, fonts-droid-fallback, libc6 (>= 2.2.3)" + echo "Architecture: ${DEB_ARCH}" + echo "Version: ${VERSION}" + echo "Installed-Size: $(du -ks "${BASE_DIR}/usr/" | cut -f 1)" + echo "Package: koreader" + echo "Maintainer: Martín Fdez " + echo "Homepage: https://koreader.rocks" + echo "Description: Ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats" + echo " KOReader is a document viewer for E Ink devices." + echo " Supported fileformats include EPUB, PDF, DjVu, XPS, CBT," + echo " CBZ, FB2, PDB, TXT, HTML, RTF, CHM, DOC, MOBI and ZIP files." + echo " It’s available for Kindle, Kobo, PocketBook, Android and desktop Linux." + + } > "${BASE_DIR}/DEBIAN/control" + + # use absolute path to luajit in reader.lua + sed -i 's/.\/luajit/\/usr\/lib\/koreader\/luajit/' "${BASE_DIR}/usr/lib/koreader/reader.lua" + + # use debian packaged fonts instead of our embedded ones to save a couple of MB. + # Note: avoid linking against fonts-noto-cjk-extra, cause it weights ~200MB. + (cd "${BASE_DIR}/usr/lib/koreader/fonts/noto" && link_fonts "$(pwd)") + + # DroidSansMono has a restrictive license. Replace it with DroidSansFallback + ( + cd "${BASE_DIR}/usr/lib/koreader/fonts/droid" && rm -rf DroidSansMono.ttf && + ln -s ../../../../share/fonts-droid-fallback/truetype/DroidSansFallback.ttf DroidSansMono.ttf + ) + + # add debian changelog + write_changelog "${BASE_DIR}/usr" + + # try to remove rpath + if command_exists chrpath; then + find "${BASE_DIR}/usr/lib/koreader/libs" -type f -name "*.so*" -print0 | xargs -0 chrpath -d + else + echo "chrpath tool not found. Skipping RPATH deletion" + fi + + fakeroot dpkg-deb -b "${BASE_DIR}" "koreader-${VERSION}-${DEB_ARCH}.deb" +else + echo "${COMMAND} not found, unable to build Debian package" + exit 1 +fi + + +rm -rf tmp-debian + +#echo "${1} -> koreader-$DEB_ARCH-$VERSION.deb" diff --git a/platform/debian/koreader.1 b/platform/linux/koreader.1 similarity index 100% rename from platform/debian/koreader.1 rename to platform/linux/koreader.1 diff --git a/platform/debian/koreader.desktop b/platform/linux/koreader.desktop similarity index 100% rename from platform/debian/koreader.desktop rename to platform/linux/koreader.desktop diff --git a/platform/debian/koreader.sh b/platform/linux/koreader.sh similarity index 100% rename from platform/debian/koreader.sh rename to platform/linux/koreader.sh