summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2021-01-12 23:49:03 -0700
committerDan Allen <dan.j.allen@gmail.com>2021-01-13 04:39:19 -0700
commit569fa424d621eba7de5f5c3808fe76d9230b58ce (patch)
tree66461bdfb21112b0308c765b93ae8d3fa42cea0c /scripts
parent84744e1f8955f2be8bd7b9ef6fb302531fb2b854 (diff)
configure subset fonts script so it can be used with docker as an alternative to podman [skip ci]
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Dockerfile.fontforge2
-rwxr-xr-xscripts/subset-fonts.sh22
2 files changed, 21 insertions, 3 deletions
diff --git a/scripts/Dockerfile.fontforge b/scripts/Dockerfile.fontforge
index 1d586457..9cd98275 100644
--- a/scripts/Dockerfile.fontforge
+++ b/scripts/Dockerfile.fontforge
@@ -1,4 +1,6 @@
# podman build -t fontforge -f Dockerfile.fontforge
+# or
+# docker build -t fontforge -f Dockerfile.fontforge .
FROM fedora:31
RUN groupadd -g 1000 fontforge && \
diff --git a/scripts/subset-fonts.sh b/scripts/subset-fonts.sh
index 75cb1f49..b0b63281 100755
--- a/scripts/subset-fonts.sh
+++ b/scripts/subset-fonts.sh
@@ -2,7 +2,10 @@
# READ ME FIRST!
# To run this script, you must first build the podman/docker image using the command found at top of Dockerfile.fontforge.
-# This script will use that image to execute fontforge on the subset-fonts.pe script.
+# This script will use that image to execute the subset-fonts.pe script with fontforge in a container.
+# By default, this script will use podman to run the subset script in a container.
+# Prefix the script with CONTAINERIZER=docker to use docker instead.
+# Additionall, you may prefix the script with IMAGE=<name-of-image> to use a different image.
# NOTE only update when fonts are being changed
export SOURCE_DATE_EPOCH=$(date -d 2020-06-10T00:00:00 +%s)
@@ -16,6 +19,7 @@ BUILD_DIR=../data/fonts
mkdir -p $SOURCE_DIR
rm -f $SOURCE_DIR/*.ttf
+mkdir -p $BUILD_DIR
cd $SOURCE_DIR
@@ -56,12 +60,20 @@ cp font-awesome-$FONT_AWESOME_VERSION/*.ttf .
cd ..
-podman run --rm -t -u 0:0 \
+if [ "$CONTAINERIZER" == "docker" ]; then
+ IMAGE=${IMAGE:=fontforge:latest}
+ RUN="docker run --rm -t -u $(id -u)"
+else
+ IMAGE=${IMAGE:=localhost/fontforge:latest}
+ RUN='podman run --rm -t -u 0:0'
+fi
+
+$RUN \
-e "SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}" \
-v `pwd`:/home/fontforge/scripts:Z \
-v `pwd`/$BUILD_DIR:/home/fontforge/scripts/build:Z \
-w /home/fontforge/scripts \
- localhost/fontforge:latest -script subset-fonts.pe $SOURCE_DIR build > /tmp/subset-fonts.log 2>&1
+ $IMAGE -script subset-fonts.pe $SOURCE_DIR build > /tmp/subset-fonts.log 2>&1
exitcode=$?
@@ -70,4 +82,8 @@ if [ -d build ]; then
rmdir build
fi
+if [ $exitcode -gt 0 ]; then
+ echo 'Process did not complete successfully. See log at /tmp/subset-fonts.log for details.'
+fi
+
exit $exitcode