From ceabafe6bdc59d0395054c78bd8a9dcae6fff230 Mon Sep 17 00:00:00 2001 From: IshanGrover2004 Date: Sun, 11 Feb 2024 00:21:16 +0530 Subject: [PATCH 1/4] feat!: Add script for building AppImage --- linux/build_appimage.sh | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 linux/build_appimage.sh diff --git a/linux/build_appimage.sh b/linux/build_appimage.sh new file mode 100755 index 000000000..757f749f7 --- /dev/null +++ b/linux/build_appimage.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +set -x +set -e + +# store the path of where the script is +OLD_CWD=$(readlink -f .) + +# store repo root as variable +REPO_ROOT=$(dirname $OLD_CWD) + +# Make a temp directory for building stuff which will be cleaned automatically +BUILD_DIR="$OLD_CWD/temp" + +# Check if temp directory exist, and if so then remove contents from it +# if not then create temp directory +if [ -d "$BUILD_DIR" ]; then + rm -r "$BUILD_DIR/*" | true +else + mkdir -p "$BUILD_DIR" +fi + +# make sure to clean up build dir, even if errors occur +cleanup() { + if [ -d "$BUILD_DIR" ]; then + rm -rf "$BUILD_DIR" + fi +} + +# Automatically trigger Cleanup function +trap cleanup EXIT + +# switch to build dir +pushd "$BUILD_DIR" + +# configure build files with CMake +# we need to explicitly set the install prefix, as CMake's default is /usr/local for some reason... +cmake "$REPO_ROOT/src" + +# build project and install files into AppDir +make -j$(nproc) ENABLE_OCR=yes + +# download linuxdeploy tool +wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage + +# make them executable +chmod +x linuxdeploy*.AppImage + +# Create AppDir +mkdir -p "$BUILD_DIR/AppDir" + +# TODO: Put link of CCExtractor image here of correct resolution(8x8, 16x16, 20x20, 22x22, 24x24, 28x28, 32x32, 36x36, 42x42, +# 48x48, 64x64, 72x72, 96x96, 128x128, 160x160, 192x192, 256x256, 384x384, 480x480, 512x512) in png extension +# PNG_LINK="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.iconsdb.com%2Ficons%2Fpreview%2Fwhite%2Fupload-xxl.png&f=1&nofb=1&ipt=6433f94c4defca121707ebe098aa2a81a1fc6e3c574e598dcaa354d32e092b5a&ipo=images" + +# Download the image and put it in AppDir +# wget "$PNG_LINK" AppDir/ccextractor.png + +# Delete these lines afterwards +# For my temporary usage +cp ~/tempdir/QtQuickApp/temp/AppDir/usr/share/icons/hicolor/128x128/apps/qtquickapp.png AppDir/ccextractor.png + +# now, build AppImage using linuxdeploy +./linuxdeploy-x86_64.AppImage --appdir=AppDir -e ccextractor --create-desktop-file --output appimage -i AppDir/ccextractor.png + +# Move resulted AppImage binary to base directory +mv ccextractor*.AppImage "$OLD_CWD" From bf4c1949183a81e129288d509a7c6ad79124f40c Mon Sep 17 00:00:00 2001 From: IshanGrover2004 Date: Sun, 11 Feb 2024 00:27:03 +0530 Subject: [PATCH 2/4] chore(delete): Remove `build-static.sh` file --- linux/build-static.sh | 107 ------------------------------------------ 1 file changed, 107 deletions(-) delete mode 100755 linux/build-static.sh diff --git a/linux/build-static.sh b/linux/build-static.sh deleted file mode 100755 index c7920a0ad..000000000 --- a/linux/build-static.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env -S sh -ex - -#################################################################### -# setup by tracey apr 2012 -# updated version dec 2016 -# see: http://www.ccextractor.org/doku.php -#################################################################### - - -# build it static! -# simplest way is with linux alpine -# hop onto box with docker on it and cd to dir of the file you are staring at -# You will get a static-compiled binary and english language library file in the end. -if [ ! -e /tmp/cc/ccextractor-README.txt ]; then - rm -rf /tmp/cc; - mkdir -p -m777 /tmp/cc; - mkdir -p -m777 ../lib/tessdata/; - cp ccextractor-README.txt /tmp/cc/; - sudo docker run -v /tmp/cc:/tmp/cc --rm -it alpine:latest /tmp/cc/ccextractor-README.txt; - # NOTE: _AFTER_ testing/validating, you can promote it from "ccextractor.next" to "ccextractor"... ;-) - cp /tmp/cc/*traineddata ../lib/tessdata/; - chmod go-w ../lib/tessdata/; - exit 0; -fi - -# NOW we are inside docker container... -cd /tmp/cc; - - -# we want tesseract (for OCR) -echo ' -http://dl-cdn.alpinelinux.org/alpine/v3.5/main -http://dl-cdn.alpinelinux.org/alpine/v3.5/community -' >| /etc/apk/repositories; -apk update; apk upgrade; - -apk add --update bash zsh alpine-sdk perl; - -# (needed by various static builds below) -# Even though we're going to (re)builid tesseract from source statically, get its dependencies setup by -# installing it now, too. -apk add autoconf automake libtool tesseract-ocr-dev; - - -# Now comes the not-so-fun parts... Many packages _only_ provide .so files in their distros -- not the .a -# needed files for building something with it statically. Step through them now... - - -# libgif -wget https://sourceforge.net/projects/giflib/files/giflib-5.1.4.tar.gz; -zcat giflib*tar.gz | tar xf -; -cd giflib*/; -./configure --disable-shared --enable-static; make; make install; -hash -r; -cd -; - - -# libwebp -git clone https://github.com/webmproject/libwebp; -cd libwebp; -./autogen.sh; -./configure --disable-shared --enable-static; make; make install; -cd -; - - -# leptonica -wget http://www.leptonica.org/source/leptonica-1.73.tar.gz; -zcat leptonica*tar.gz | tar xf -; -cd leptonica*/; -./configure --disable-shared --enable-static; make; make install; -hash -r; -cd -; - - -# tesseract -git clone https://github.com/tesseract-ocr/tesseract; -cd tesseract; -./autogen.sh; -./configure --disable-shared --enable-static; make; make install; -cd -; - - -# ccextractor -- build static -git clone https://github.com/CCExtractor/ccextractor; -cd ccextractor/linux/; -perl -i -pe 's/O3 /O3 -static /' Makefile; -set +e; # this _will_ FAIL at the end.. -make ENABLE_OCR=yes; -set -e; -# I confess hand-compiling (cherrypicking which .a to use when there are 2, etc.) is fragile... -# But it was the _only_ way I could get a fully static build after hours of thrashing... -gcc -Wno-write-strings -Wno-pointer-sign -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -O3 -std=gnu99 -s -DENABLE_OCR -DPNG_NO_CONFIG_H -I/usr/local/include/tesseract -I/usr/local/include/leptonica objs/*.o -o ccextractor \ - --static -lm -lgpac \ - /usr/local/lib/libtesseract.a \ - /usr/local/lib/liblept.a \ - /usr/local/lib/libgif.a \ - /usr/local/lib/libwebp.a \ - /usr/lib/libjpeg.a \ - /usr/lib/libtiff.a \ - /usr/lib/libgomp.a \ - -lstdc++; - -cp ccextractor /tmp/cc/ccextractor.next; -cd -; - -# get english lang trained data -wget https://github.com/tesseract-ocr/tessdata/raw/master/eng.traineddata; From 2f50feb203ffb500a8b402f7b77137ff7993c4a6 Mon Sep 17 00:00:00 2001 From: IshanGrover2004 Date: Sun, 11 Feb 2024 08:22:06 +0530 Subject: [PATCH 3/4] refactor: Add link for logo photo --- linux/build_appimage.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/linux/build_appimage.sh b/linux/build_appimage.sh index 757f749f7..4867c9bd0 100755 --- a/linux/build_appimage.sh +++ b/linux/build_appimage.sh @@ -49,16 +49,12 @@ chmod +x linuxdeploy*.AppImage # Create AppDir mkdir -p "$BUILD_DIR/AppDir" -# TODO: Put link of CCExtractor image here of correct resolution(8x8, 16x16, 20x20, 22x22, 24x24, 28x28, 32x32, 36x36, 42x42, +# Link of CCExtractor image of any of these resolution(8x8, 16x16, 20x20, 22x22, 24x24, 28x28, 32x32, 36x36, 42x42, # 48x48, 64x64, 72x72, 96x96, 128x128, 160x160, 192x192, 256x256, 384x384, 480x480, 512x512) in png extension -# PNG_LINK="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.iconsdb.com%2Ficons%2Fpreview%2Fwhite%2Fupload-xxl.png&f=1&nofb=1&ipt=6433f94c4defca121707ebe098aa2a81a1fc6e3c574e598dcaa354d32e092b5a&ipo=images" +PNG_LINK="https://raw.githubusercontent.com/CCExtractor/website/master/static/images/ccextractor.png" # Download the image and put it in AppDir -# wget "$PNG_LINK" AppDir/ccextractor.png - -# Delete these lines afterwards -# For my temporary usage -cp ~/tempdir/QtQuickApp/temp/AppDir/usr/share/icons/hicolor/128x128/apps/qtquickapp.png AppDir/ccextractor.png +wget "$PNG_LINK" AppDir/ccextractor.png # now, build AppImage using linuxdeploy ./linuxdeploy-x86_64.AppImage --appdir=AppDir -e ccextractor --create-desktop-file --output appimage -i AppDir/ccextractor.png From f3145e385e3ca17aec0c0f866746719614b09d64 Mon Sep 17 00:00:00 2001 From: IshanGrover2004 Date: Sun, 11 Feb 2024 08:49:22 +0530 Subject: [PATCH 4/4] chore: Replace dead link --- linux/build_appimage.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/build_appimage.sh b/linux/build_appimage.sh index 4867c9bd0..d586c4eb0 100755 --- a/linux/build_appimage.sh +++ b/linux/build_appimage.sh @@ -51,10 +51,10 @@ mkdir -p "$BUILD_DIR/AppDir" # Link of CCExtractor image of any of these resolution(8x8, 16x16, 20x20, 22x22, 24x24, 28x28, 32x32, 36x36, 42x42, # 48x48, 64x64, 72x72, 96x96, 128x128, 160x160, 192x192, 256x256, 384x384, 480x480, 512x512) in png extension -PNG_LINK="https://raw.githubusercontent.com/CCExtractor/website/master/static/images/ccextractor.png" +PNG_LINK="https://ccextractor.org/images/ccextractor.png" # Download the image and put it in AppDir -wget "$PNG_LINK" AppDir/ccextractor.png +wget "$PNG_LINK" -P AppDir # now, build AppImage using linuxdeploy ./linuxdeploy-x86_64.AppImage --appdir=AppDir -e ccextractor --create-desktop-file --output appimage -i AppDir/ccextractor.png