aboutsummaryrefslogtreecommitdiff
path: root/linux/make_artifacts.sh
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-07-24 09:57:27 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-08-11 21:33:21 -0700
commitc9900278321a14071c6721fdfb702e39ca5e2a38 (patch)
tree1724171740a0569330e7c48d055e13735878a4b4 /linux/make_artifacts.sh
parent5d4932d7ef8e1edec31d99661ffe8e2f4a77244f (diff)
downloadpandoc-c9900278321a14071c6721fdfb702e39ca5e2a38.tar.gz
Linux rc build: use ghc-musl container.
This simplifies our build process a bit (over using a customized alpine container). Use new `--enable-executable-static` flag in build. make_artifacts.sh: Fix deprecated find -perm syntax.
Diffstat (limited to 'linux/make_artifacts.sh')
-rw-r--r--linux/make_artifacts.sh82
1 files changed, 82 insertions, 0 deletions
diff --git a/linux/make_artifacts.sh b/linux/make_artifacts.sh
new file mode 100644
index 000000000..3cb892a8e
--- /dev/null
+++ b/linux/make_artifacts.sh
@@ -0,0 +1,82 @@
+set -e
+
+MACHINE=$(uname -m)
+case "$MACHINE" in
+ x86_64) ARCHITECTURE=amd64;;
+ i686) ARCHITECTURE=i386;;
+ i386) ARCHITECTURE=i386;;
+esac
+
+ARTIFACTS="${ARTIFACTS:-/artifacts}"
+
+# build binaries
+
+cabal --version
+ghc --version
+
+cabal v2-update
+cabal v2-clean
+cabal v2-configure --enable-tests -f-export-dynamic -fstatic -fembed_data_files -fbibutils --enable-executable-static --ghc-options '-optc-Os -optl=-pthread -split-sections' . pandoc-citeproc
+cabal v2-build . pandoc-citeproc
+cabal v2-test -j1 . pandoc-citeproc
+for f in $(find dist-newstyle -name 'pandoc*' -type f -perm /400); do cp $f /artifacts/; done
+
+# make deb
+
+VERSION=`$ARTIFACTS/pandoc --version | awk '{print $2; exit;}'`
+REVISION=${REVISION:-1}
+DEBVER=$VERSION-$REVISION
+BASE=pandoc-$DEBVER-$ARCHITECTURE
+DIST=`pwd`/$BASE
+DEST=$DIST/usr
+COPYRIGHT=$DEST/share/doc/pandoc/copyright
+
+mkdir -p $DEST/bin
+mkdir -p $DEST/share/man/man1
+mkdir -p $DEST/share/doc/pandoc
+
+mkdir -p $DEST/share/doc/pandoc-citeproc
+find $DIST -type d | xargs chmod 755
+cp $ARTIFACTS/pandoc $DEST/bin/
+cp $ARTIFACTS/pandoc-citeproc $DEST/bin/
+strip $DEST/bin/pandoc
+strip $DEST/bin/pandoc-citeproc
+cp /mnt/man/pandoc.1 $DEST/share/man/man1/pandoc.1
+$ARTIFACTS/pandoc-citeproc --man > $DEST/share/man/man1/pandoc-citeproc.1
+gzip -9 $DEST/share/man/man1/pandoc.1
+gzip -9 $DEST/share/man/man1/pandoc-citeproc.1
+
+cp /mnt/COPYRIGHT $COPYRIGHT
+echo "" >> $COPYRIGHT
+echo "pandoc-citeproc" >> $COPYRIGHT
+$ARTIFACTS/pandoc-citeproc --license >> $COPYRIGHT
+
+INSTALLED_SIZE=$(du -k -s $DEST | awk '{print $1}')
+mkdir $DIST/DEBIAN
+perl -pe "s/VERSION/$DEBVER/" linux/control.in | \
+ perl -pe "s/ARCHITECTURE/$ARCHITECTURE/" | \
+ perl -pe "s/INSTALLED_SIZE/$INSTALLED_SIZE/" \
+ > $DIST/DEBIAN/control
+
+# we limit compression to avoid OOM error
+fakeroot dpkg-deb -Zgzip -z9 --build $DIST
+rm -rf $DIST
+cp $BASE.deb $ARTIFACTS/
+
+# Make tarball
+
+TARGET=pandoc-$VERSION
+cd $ARTIFACTS
+rm -rf $TARGET
+mkdir $TARGET
+mkdir $TARGET/bin $TARGET/share $TARGET/share/man $TARGET/share/man/man1
+./pandoc-citeproc --man > $TARGET/share/man/man1/pandoc-citeproc.1
+cp /mnt/man/pandoc.1 $TARGET/share/man/man1
+mv pandoc pandoc-citeproc $TARGET/bin
+strip $TARGET/bin/pandoc
+strip $TARGET/bin/pandoc-citeproc
+gzip -9 $TARGET/share/man/man1/pandoc.1
+gzip -9 $TARGET/share/man/man1/pandoc-citeproc.1
+
+tar cvzf $TARGET-linux-amd64.tar.gz $TARGET
+rm -r $TARGET