mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2024-12-22 11:01:50 +00:00
[FEATURE] Create linux AppImage for building CCExtractor (#1592)
* feat!: Add script for building AppImage * chore(delete): Remove `build-static.sh` file * refactor: Add link for logo photo * chore: Replace dead link
This commit is contained in:
parent
89a12a7dd0
commit
f08febfd61
@ -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;
|
|
63
linux/build_appimage.sh
Executable file
63
linux/build_appimage.sh
Executable file
@ -0,0 +1,63 @@
|
|||||||
|
#!/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"
|
||||||
|
|
||||||
|
# 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://ccextractor.org/images/ccextractor.png"
|
||||||
|
|
||||||
|
# Download the image and put it in AppDir
|
||||||
|
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
|
||||||
|
|
||||||
|
# Move resulted AppImage binary to base directory
|
||||||
|
mv ccextractor*.AppImage "$OLD_CWD"
|
Loading…
Reference in New Issue
Block a user