diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..64e377c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +.git +.github +build +dist +KindleComicConverter.egg-info +.dockerignore +.gitignore +.travis.yml +Dockerfile +other +venv +*.md +LICENSE.txt +MANIFEST.in \ No newline at end of file diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..69468bb --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,36 @@ +name: Docker + +on: + workflow_dispatch: + #schedule: + # - cron: '39 5 * * *' + push: +# branches: [ master, pipeline_test, docker_test ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + + # Don't trigger if it's just a documentation update + paths-ignore: + - '**.md' + - '**.MD' + - '**.yml' + - 'docs/**' + - 'LICENSE' + - '.gitattributes' + - '.gitignore' + - '.dockerignore' + + +jobs: + build_and_push: + uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main + with: + platform_linux_arm32v7_enabled: true + platform_linux_arm64v8_enabled: true + platform_linux_amd64_enabled: true + push_enabled: true + build_nohealthcheck: false + ghcr_repo_owner: ${{ github.repository_owner }} + ghcr_repo: ${{ github.repository }} + secrets: + ghcr_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/package-linux.yml b/.github/workflows/package-linux.yml new file mode 100644 index 0000000..909f4c0 --- /dev/null +++ b/.github/workflows/package-linux.yml @@ -0,0 +1,81 @@ +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: build KCC for Linux + +on: + workflow_dispatch: + push: + tags: + - "v*.*.*" + + # Don't trigger if it's just a documentation update + paths-ignore: + - '**.md' + - '**.MD' + - '**.yml' + - '**.sh' + - 'docs/**' + - 'Dockerfile' + - 'LICENSE' + - '.gitattributes' + - '.gitignore' + - '.dockerignore' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: 3.8 + cache: 'pip' + - name: Install python dependencies + run: | + sudo apt-get update + sudo apt-get install -y libpng-dev libjpeg-dev p7zip-full python3-pyqt5 squashfs-tools + python -m pip install --upgrade pip setuptools wheel pyinstaller + pip install -r requirements.txt + - name: build binary + run: | + python setup.py build_binary + chmod +x dist/kcc_linux* + - name: upload build + uses: actions/upload-artifact@v3 + with: + name: linux-build + path: dist/kcc_linux* +# issue with this action, disabled and commented out +# see https://github.com/AppImageCrafters/build-appimage/issues/5 +# see https://appimage-builder.readthedocs.io/en/latest/intro/install.html#install-appimagetool +# - name: Build AppImage +# uses: AppImageCrafters/build-appimage-action@master +# env: +# UPDATE_INFO: gh-releases-zsync|darodi|kcc|latest|*x86_64.AppImage.zsync +# with: +# recipe: AppImageBuilder.yml + - name: Build AppImage + run: | + wget -O appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage + chmod +x appimage-builder-x86_64.AppImage + sudo mv appimage-builder-x86_64.AppImage /usr/local/bin/appimage-builder + appimage-builder --recipe AppImageBuilder.yml --skip-test + env: + UPDATE_INFO: gh-releases-zsync|darodi|kcc|latest|*x86_64.AppImage.zsync + + - name: upload artifact + uses: actions/upload-artifact@v2 + with: + name: AppImage + path: './*.AppImage*' + - name: Release + uses: softprops/action-gh-release@v1 + with: + prerelease: true + generate_release_notes: true + files: | + CHANGELOG.md + LICENSE.txt + dist/kcc_linux* + *.AppImage* diff --git a/.github/workflows/package-macos.yml b/.github/workflows/package-macos.yml index 093a086..5b3a672 100644 --- a/.github/workflows/package-macos.yml +++ b/.github/workflows/package-macos.yml @@ -7,17 +7,29 @@ on: tags: - "v*.*.*" + # Don't trigger if it's just a documentation update + paths-ignore: + - '**.md' + - '**.MD' + - '**.yml' + - '**.sh' + - 'docs/**' + - 'Dockerfile' + - 'LICENSE' + - '.gitattributes' + - '.gitignore' + - '.dockerignore' + jobs: build: - runs-on: macos-latest - steps: - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: - python-version: "3.8" + python-version: 3.8 + cache: 'pip' - name: Install python dependencies run: | python -m pip install --upgrade pip setuptools wheel pyinstaller diff --git a/.github/workflows/package-windows.yml b/.github/workflows/package-windows.yml index 0f5a3d1..969242d 100644 --- a/.github/workflows/package-windows.yml +++ b/.github/workflows/package-windows.yml @@ -7,17 +7,29 @@ on: tags: - "v*.*.*" + # Don't trigger if it's just a documentation update + paths-ignore: + - '**.md' + - '**.MD' + - '**.yml' + - '**.sh' + - 'docs/**' + - 'Dockerfile' + - 'LICENSE' + - '.gitattributes' + - '.gitignore' + - '.dockerignore' + jobs: build: - runs-on: windows-latest - steps: - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: - python-version: "3.8" + python-version: 3.8 + cache: 'pip' - name: Install python dependencies run: | python -m pip install --upgrade pip setuptools wheel pyinstaller diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..742d161 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,48 @@ +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Publish Python distributions to PyPI and TestPyPI + +on: + push: + tags: + - "v*.*.*" + + # Don't trigger if it's just a documentation update + paths-ignore: + - '**.md' + - '**.MD' + - '**.yml' + - '**.sh' + - 'docs/**' + - 'Dockerfile' + - 'LICENSE' + - '.gitattributes' + - '.gitignore' + - '.dockerignore' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: 3.8 + cache: 'pip' + - name: Install python dependencies + run: | + python -m pip install --upgrade pip setuptools wheel pyinstaller + pip install -r requirements.txt + - name: Build Dist + run: | + python setup.py sdist + - name: Release On TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + skip_existing: true + verbose: true + print_hash: true diff --git a/.gitignore b/.gitignore index 46a8f3b..fc09bb9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,8 @@ kindlecomicconverter/sentry.py other/windows/kindlegen.exe dist/ build/ -KindleComicConverter.egg-info/ +KindleComicConverter*.egg-info/ .idea/ /venv/ -/kindlegen.exe +/kindlegen* +/kcc.bat diff --git a/AppImageBuilder.yml b/AppImageBuilder.yml new file mode 100644 index 0000000..0e356fe --- /dev/null +++ b/AppImageBuilder.yml @@ -0,0 +1,70 @@ +# appimage-builder recipe see https://appimage-builder.readthedocs.io for details +version: 1 +script: + - rm -rf AppDir || true + - mkdir -p AppDir/usr/share/icons/hicolor/64x64/apps/ + - cp -a dist/kcc_linux* AppDir/ && mv AppDir/kcc_linux* AppDir/kcc_linux + - cp icons/comic2ebook.png AppDir/usr/share/icons/hicolor/64x64/apps/ +AppDir: + path: AppDir + app_info: + id: com.github.darodi.kcc + name: kindleComicConverter + icon: comic2ebook + version: latest + exec: ./kcc_linux + exec_args: $@ + apt: + arch: + - amd64 + allow_unauthenticated: true + sources: + - sourceline: deb http://archive.ubuntu.com/ubuntu focal main restricted + - sourceline: deb http://archive.ubuntu.com/ubuntu focal-updates main restricted + - sourceline: deb http://archive.ubuntu.com/ubuntu focal universe + - sourceline: deb http://archive.ubuntu.com/ubuntu focal-updates universe + - sourceline: deb http://archive.ubuntu.com/ubuntu focal multiverse + - sourceline: deb http://archive.ubuntu.com/ubuntu focal-updates multiverse + - sourceline: deb http://archive.ubuntu.com/ubuntu focal-backports main restricted + universe multiverse + - sourceline: deb http://security.ubuntu.com/ubuntu focal-security main restricted + - sourceline: deb http://security.ubuntu.com/ubuntu focal-security universe + - sourceline: deb http://security.ubuntu.com/ubuntu focal-security multiverse + include: + - zlib1g:amd64 + files: + include: + - /lib/x86_64-linux-gnu/libGLX.so.0 + - /lib/x86_64-linux-gnu/libGLdispatch.so.0 + - /usr/lib/locale/locale-archive + exclude: + - usr/share/man + - usr/share/doc/*/README.* + - usr/share/doc/*/changelog.* + - usr/share/doc/*/NEWS.* + - usr/share/doc/*/TODO.* + test: + fedora-30: + image: appimagecrafters/tests-env:fedora-30 + command: ./AppRun + use_host_x: true + debian-stable: + image: appimagecrafters/tests-env:debian-stable + command: ./AppRun + use_host_x: true + archlinux-latest: + image: appimagecrafters/tests-env:archlinux-latest + command: ./AppRun + use_host_x: true + centos-7: + image: appimagecrafters/tests-env:centos-7 + command: ./AppRun + use_host_x: true + ubuntu-xenial: + image: appimagecrafters/tests-env:ubuntu-xenial + command: ./AppRun + use_host_x: true +AppImage: + arch: x86_64 + update-information: !ENV ${UPDATE_INFO} + sign-key: None \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e8c3487 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,165 @@ +FROM --platform=linux/amd64 python:3.8-slim-buster as compile-amd64 +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT +RUN echo "I'm building for $TARGETOS/$TARGETARCH/$TARGETVARIANT" + + +COPY requirements.txt /opt/kcc/ +ENV PATH="/opt/venv/bin:$PATH" +RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && apt-get -yq upgrade && \ + apt-get install -y libpng-dev libjpeg-dev p7zip-full unrar-free libgl1 python3-pyqt5 && \ + python -m pip install --upgrade pip && \ + python -m venv /opt/venv && \ + python -m pip install -r /opt/kcc/requirements.txt + + +###################################################################################### + +FROM --platform=linux/arm64 python:3.8-slim-buster as compile-arm64 +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT +RUN echo "I'm building for $TARGETOS/$TARGETARCH/$TARGETVARIANT" + +ENV LC_ALL=C.UTF-8 \ + LANG=C.UTF-8 \ + LANGUAGE=en_US:en + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN set -x && \ + TEMP_PACKAGES=() && \ + KEPT_PACKAGES=() && \ + # Packages only required during build + TEMP_PACKAGES+=(build-essential) && \ + TEMP_PACKAGES+=(cmake) && \ + TEMP_PACKAGES+=(libfreetype6-dev) && \ + TEMP_PACKAGES+=(libfontconfig1-dev) && \ + TEMP_PACKAGES+=(libpng-dev) && \ + TEMP_PACKAGES+=(libjpeg-dev) && \ + TEMP_PACKAGES+=(libssl-dev) && \ + TEMP_PACKAGES+=(libxft-dev) && \ + TEMP_PACKAGES+=(make) && \ + TEMP_PACKAGES+=(python3-dev) && \ + TEMP_PACKAGES+=(python3-setuptools) && \ + TEMP_PACKAGES+=(python3-wheel) && \ + # Packages kept in the image + KEPT_PACKAGES+=(bash) && \ + KEPT_PACKAGES+=(ca-certificates) && \ + KEPT_PACKAGES+=(chrpath) && \ + KEPT_PACKAGES+=(locales) && \ + KEPT_PACKAGES+=(locales-all) && \ + KEPT_PACKAGES+=(libfreetype6) && \ + KEPT_PACKAGES+=(libfontconfig1) && \ + KEPT_PACKAGES+=(p7zip-full) && \ + KEPT_PACKAGES+=(python3) && \ + KEPT_PACKAGES+=(python3-pip) && \ + KEPT_PACKAGES+=(python-pyqt5) && \ + KEPT_PACKAGES+=(qt5-default) && \ + KEPT_PACKAGES+=(unrar-free) && \ + # Install packages + DEBIAN_FRONTEND=noninteractive apt-get update -y && apt-get -yq upgrade && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + ${KEPT_PACKAGES[@]} \ + ${TEMP_PACKAGES[@]} \ + && \ + # Install required python modules + python -m pip install --upgrade pip && \ +# python -m pip install -r /opt/kcc/requirements.txt && \ + python -m venv /opt/venv && \ + python -m pip install --upgrade pillow python-slugify psutil raven mozjpeg-lossless-optimization + + +###################################################################################### + +FROM --platform=linux/arm/v7 python:3.8-slim-buster as compile-armv7 +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT +RUN echo "I'm building for $TARGETOS/$TARGETARCH/$TARGETVARIANT" + +ENV LC_ALL=C.UTF-8 \ + LANG=C.UTF-8 \ + LANGUAGE=en_US:en + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN set -x && \ + TEMP_PACKAGES=() && \ + KEPT_PACKAGES=() && \ + # Packages only required during build + TEMP_PACKAGES+=(build-essential) && \ + TEMP_PACKAGES+=(cmake) && \ + TEMP_PACKAGES+=(libffi-dev) && \ + TEMP_PACKAGES+=(libfreetype6-dev) && \ + TEMP_PACKAGES+=(libfontconfig1-dev) && \ + TEMP_PACKAGES+=(libpng-dev) && \ + TEMP_PACKAGES+=(libjpeg-dev) && \ + TEMP_PACKAGES+=(libssl-dev) && \ + TEMP_PACKAGES+=(libxft-dev) && \ + TEMP_PACKAGES+=(make) && \ + TEMP_PACKAGES+=(python3-dev) && \ + TEMP_PACKAGES+=(python3-setuptools) && \ + TEMP_PACKAGES+=(python3-wheel) && \ + # Packages kept in the image + KEPT_PACKAGES+=(bash) && \ + KEPT_PACKAGES+=(ca-certificates) && \ + KEPT_PACKAGES+=(chrpath) && \ + KEPT_PACKAGES+=(locales) && \ + KEPT_PACKAGES+=(locales-all) && \ + KEPT_PACKAGES+=(libfreetype6) && \ + KEPT_PACKAGES+=(libfontconfig1) && \ + KEPT_PACKAGES+=(p7zip-full) && \ + KEPT_PACKAGES+=(python3) && \ + KEPT_PACKAGES+=(python3-pip) && \ + KEPT_PACKAGES+=(python-pyqt5) && \ + KEPT_PACKAGES+=(qt5-default) && \ + KEPT_PACKAGES+=(unrar-free) && \ + # Install packages + DEBIAN_FRONTEND=noninteractive apt-get update -y && apt-get -yq upgrade && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + ${KEPT_PACKAGES[@]} \ + ${TEMP_PACKAGES[@]} \ + && \ + # Install required python modules + python -m pip install --upgrade pip && \ +# python -m pip install -r /opt/kcc/requirements.txt && \ + python -m venv /opt/venv && \ + python -m pip install --upgrade pillow python-slugify psutil raven mozjpeg-lossless-optimization + + +###################################################################################### +FROM --platform=linux/amd64 python:3.8-slim-buster as build-amd64 +COPY --from=compile-amd64 /opt/venv /opt/venv + +FROM --platform=linux/arm64 python:3.8-slim-buster as build-arm64 +COPY --from=compile-arm64 /opt/venv /opt/venv + +FROM --platform=linux/arm/v7 python:3.8-slim-buster as build-armv7 +COPY --from=compile-armv7 /opt/venv /opt/venv +###################################################################################### + +# Select final stage based on TARGETARCH ARG +FROM build-${TARGETARCH}${TARGETVARIANT} +LABEL com.kcc.name="Kindle Comic Converter" +LABEL com.kcc.author="Ciro Mattia Gonano and Paweł Jastrzębski" +LABEL org.opencontainers.image.description='Kindle Comic Converter' +LABEL org.opencontainers.image.documentation='https://github.com/darodi/kcc' +LABEL org.opencontainers.image.source='https://github.com/darodi/kcc' +LABEL org.opencontainers.image.authors='darodi' +LABEL org.opencontainers.image.url='https://github.com/darodi/kcc' +LABEL org.opencontainers.image.documentation='https://github.com/darodi/kcc' +LABEL org.opencontainers.image.vendor='darodi' +LABEL org.opencontainers.image.licenses='ISC' +LABEL org.opencontainers.image.title="Kindle Comic Converter" + + +ENV PATH="/opt/venv/bin:$PATH" +WORKDIR /opt/kcc +COPY . /opt/kcc +RUN ln -s /app/kindlegen /bin/kindlegen && \ + cat /opt/kcc/kindlecomicconverter/__init__.py | grep version | awk '{print $3}' | sed "s/'//g" > /IMAGE_VERSION + +ENTRYPOINT ["/opt/kcc/kcc-c2e.py"] +CMD ["-h"] \ No newline at end of file diff --git a/README.md b/README.md index 85c0462..2d53bc0 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,32 @@ You can find the latest released binary at the following links: pip install --user KindleComicConverter ``` +beta version +``` +pip install --index-url https://test.pypi.org/simple/ KindleComicConverterDarodi +``` + +## DOCKER + + + +install kindlegen in your working directory and get last docker image +``` +wget -qO- https://archive.org/download/kindlegen_linux_2_6_i386_v2_9/kindlegen_linux_2.6_i386_v2_9.tar.gz | tar xvz kindlegen +docker pull ghcr.io/darodi/kcc:latest +``` + +execute kcc-c2e +``` +docker run --rm -v "$(pwd):/app" ghcr.io/darodi/kcc:latest +``` + +execute kcc-c2p +``` +docker run --entrypoint /opt/kcc/kcc-c2p.py --rm -v "$(pwd):/app" ghcr.io/darodi/kcc:latest +``` + + ## DEPENDENCIES Following software is required to run Linux version of **KCC** and/or bare sources: - Python 3.3+ @@ -82,8 +108,8 @@ Options: MAIN: -p PROFILE, --profile=PROFILE Device profile (Available options: K1, K2, K34, K578, - KDX, KPW, KPW5, KV, KO, KoMT, KoG, KoGHD, KoA, KoAHD, KoAH2O, - KoAO, KoC, KoL, KoF) [Default=KV] + KDX, KPW, KPW5, KV, KO, KoMT, KoG, KoGHD, KoA, KoAHD, + KoAH2O, KoAO, KoC, KoL, KoF) [Default=KV] -m, --manga-style Manga style (right-to-left reading and splitting) -q, --hq Try to increase the quality of magnification -2, --two-panel Display two not four panels in Panel View mode @@ -103,6 +129,8 @@ Options: separate volume [Default=0] PROCESSING: + -n, --noprocessing Do not modify image and ignore any profil or + processing option -u, --upscale Resize images smaller than device's resolution -s, --stretch Stretch images to device's resolution -r SPLITTER, --splitter=SPLITTER @@ -120,6 +148,8 @@ Options: --whiteborders Disable autodetection and force white borders --forcecolor Don't convert images to grayscale --forcepng Create PNG files instead JPEG + --mozjpeg Create JPEG files using mozJpeg + --maximizestrips Turn 1x4 strips to 2x2 strips CUSTOM PROFILE: --customwidth=CUSTOMWIDTH @@ -174,12 +204,11 @@ The app relies and includes the following scripts: _Originally posted by @hhtien1408 in https://github.com/ciromattia/kcc/issues/438#issuecomment-1281159452_ - I wrote step-by-step instructions to install the lastest beta KCC-5.5.3-beta-darodi.6 based on @hiagpofranco idea - +``` $ git clone -branch beta_release https://github.com/darodi/kcc.git +``` - -Then I installed the necessary packages. You can do it by running the following command. The requirements.txt file is inside this repository, you will see it when you clone the repo. +Then install the necessary packages. You can do it by running the following command. The requirements.txt file is inside this repository, you will see it when you clone the repo. ``` $ pip3 install -r 'requirements.txt' @@ -195,7 +224,6 @@ If the packages are in the wrong version, you can try to upgrade them by running ``` $ pip3 install --upgrade name_of_the_package - ``` Now, it should be all done. You can go to the folder of this repo and run @@ -203,8 +231,10 @@ Now, it should be all done. You can go to the folder of this repo and run $ wget https://archive.org/download/kindlegen_linux_2_6_i386_v2_9/kindlegen_linux_2.6_i386_v2_9.tar.gz ``` ``` -$ unzip kindlegen_linux_2.6_i386_v2_9.tar.gz +$ tar xvzf kindlegen_linux_2.6_i386_v2_9.tar.gz kindlegen ``` +Download and copy kindlegen into '/usr/local/bin' and grant execute permissions for MOBI conversion. + ``` $ sudo cp -R '/home/user/Desktop/kindlegen' '/usr/local/bin' ``` @@ -212,7 +242,6 @@ $ sudo cp -R '/home/user/Desktop/kindlegen' '/usr/local/bin' $ sudo chmod +rwx '/usr/local/bin/kindlegen' ``` -Download and copy kindlegen into '/usr/local/bin' and grant execute permissions for MOBI conversion. Run python file for KCC GUI ``` diff --git a/application-vnd.appimage.svg b/application-vnd.appimage.svg new file mode 100644 index 0000000..83ac565 --- /dev/null +++ b/application-vnd.appimage.svg @@ -0,0 +1,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/setup.py b/setup.py index 79c5a8c..c3a473f 100755 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ import setuptools import distutils.cmd from kindlecomicconverter import __version__ -NAME = 'KindleComicConverter' +NAME = 'KindleComicConverterDarodi' MAIN = 'kcc.py' VERSION = __version__ @@ -49,7 +49,11 @@ class BuildBinaryCommand(distutils.cmd.Command): os.system('appdmg kcc.json dist/KindleComicConverter_osx_' + VERSION + '.dmg') exit(0) elif sys.platform == 'win32': - os.system('pyinstaller -y -F -i icons\\comic2ebook.ico -n KCC -w --noupx kcc.py') + os.system('pyinstaller -y -F -i icons\\comic2ebook.ico -n KCC_' + VERSION + ' -w --noupx kcc.py') + exit(0) + elif sys.platform == 'linux': + os.system( + 'pyinstaller --hidden-import=queue -y -F -i icons/comic2ebook.ico -n kcc_linux_' + VERSION + ' kcc.py') exit(0) else: exit(0)