This repository was archived by the owner on Mar 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathcompile
More file actions
executable file
·56 lines (43 loc) · 1.42 KB
/
compile
File metadata and controls
executable file
·56 lines (43 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir>
set -e
BUILD_DIR=$1
CACHE_DIR=$2
ENV_DIR=$3
BIN_PATH="$BUILD_DIR/bin"
LIB_PATH="$BUILD_DIR/vendor/wkhtmltox/lib"
TMP_PATH="$BUILD_DIR/tmp"
mkdir -p $CACHE_DIR $BIN_PATH $LIB_PATH $TMP_PATH
if [[ -f "$ENV_DIR/WKHTMLTOPDF_VERSION" ]]; then
WKHTMLTOPDF_VERSION=$(cat "$ENV_DIR/WKHTMLTOPDF_VERSION")
else
WKHTMLTOPDF_VERSION="0.12.3"
fi
WKHTMLTOPDF_URL="https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/${WKHTMLTOPDF_VERSION}/wkhtmltox-${WKHTMLTOPDF_VERSION}_linux-generic-amd64.tar.xz"
WKHTMLTOPDF_TAR="$CACHE_DIR/wkhtmltox.tar.xz"
WKHTMLTOPDF_PATH="$TMP_PATH/wkhtmltox"
WKHTMLTOPDF_BINARIES="$WKHTMLTOPDF_PATH/bin"
WKHTMLTOPDF_LIBS="$WKHTMLTOPDF_PATH/lib"
BIN_DIR=$(cd $(dirname $0); pwd)
FONTS_DIR=$(cd "$BIN_DIR/../fonts"; pwd)
if [ -f $WKHTMLTOPDF_TAR ]; then
echo "-----> Using wkhtmltopdf tar from cache"
else
echo "-----> Downloading wkhtmltopdf tar"
curl -L $WKHTMLTOPDF_URL -o $WKHTMLTOPDF_TAR
fi
echo "-----> Unpacking tar"
tar -xf $WKHTMLTOPDF_TAR -C $TMP_PATH
echo "-----> Setting permissions"
chmod +x $WKHTMLTOPDF_BINARIES/*
echo "-----> Moving binaries to the right place"
mv $WKHTMLTOPDF_BINARIES/* $BIN_PATH/
echo "-----> Moving libs to the right place"
mv $WKHTMLTOPDF_LIBS/* $LIB_PATH/
echo "-----> Cleaning up"
rm -rf $WKHTMLTOPDF_PATH
echo "-----> Installing fonts"
mkdir -p $1/.fonts
ls $FONTS_DIR
cp $FONTS_DIR/* $1/.fonts/
fc-cache -f $1/.fonts