From c9900278321a14071c6721fdfb702e39ca5e2a38 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 24 Jul 2020 09:57:27 -0700 Subject: 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. --- linux/Dockerfile | 30 ------------------ linux/Makefile | 18 ----------- linux/make_artifacts.sh | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ linux/make_deb.sh | 51 ------------------------------ linux/make_tarball.sh | 19 ------------ 5 files changed, 82 insertions(+), 118 deletions(-) delete mode 100644 linux/Dockerfile delete mode 100644 linux/Makefile create mode 100644 linux/make_artifacts.sh delete mode 100755 linux/make_deb.sh delete mode 100644 linux/make_tarball.sh (limited to 'linux') diff --git a/linux/Dockerfile b/linux/Dockerfile deleted file mode 100644 index f577d8765..000000000 --- a/linux/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# USE ALPINE LINUX -FROM alpine:3.11 -RUN apk --no-cache add \ - alpine-sdk \ - bash \ - ca-certificates \ - cabal \ - dpkg \ - fakeroot \ - ghc \ - git \ - gmp-dev \ - xz \ - zlib-dev \ - zlib-static -RUN mkdir -p /usr/src/ && \ - git clone https://github.com/jgm/pandoc /usr/src/pandoc -WORKDIR /usr/src/pandoc -CMD cabal --version && \ - ghc --version && \ - git pull && \ - git checkout -b work $TREE && \ - cabal new-update && \ - cabal new-clean && \ - cabal new-configure --enable-tests -f-export-dynamic -fstatic -fembed_data_files -fbibutils --ghc-options '-optc-Os -optl=-pthread -optl=-static -fPIC -split-sections' . pandoc-citeproc && \ - cabal new-build . pandoc-citeproc && \ - cabal new-test -j1 . pandoc-citeproc && \ - for f in $(find dist-newstyle -name 'pandoc*' -type f -perm +400); do cp $f /artifacts/; done && \ - bash linux/make_deb.sh && \ - bash linux/make_tarball.sh diff --git a/linux/Makefile b/linux/Makefile deleted file mode 100644 index 4e8eeb00a..000000000 --- a/linux/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TREE?=HEAD -ARTIFACTS=`pwd`/artifacts -REVISION?=1 - -build: - mkdir -p $(ARTIFACTS) - docker build -t alpine-pandoc . - docker run --env TREE=$(TREE) --env REVISION=$(REVISION) \ - -v $(ARTIFACTS):/artifacts alpine-pandoc - -interact: - docker run --env TREE=$(TREE) --env REVISION=$(REVISION) \ - -v $(ARTIFACTS):/artifacts -it alpine-pandoc bash - -setup: - docker pull alpine:edge - -.PHONY: build setup interact 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 diff --git a/linux/make_deb.sh b/linux/make_deb.sh deleted file mode 100755 index cbbc8a184..000000000 --- a/linux/make_deb.sh +++ /dev/null @@ -1,51 +0,0 @@ -set -e - -MACHINE=$(uname -m) -case "$MACHINE" in - x86_64) ARCHITECTURE=amd64;; - i686) ARCHITECTURE=i386;; - i386) ARCHITECTURE=i386;; -esac - -ARTIFACTS="${ARTIFACTS:-/artifacts}" - -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 - -PANDOC_CITEPROC_VERSION=`$ARTIFACTS/pandoc-citeproc --version | awk '{print $2;}'` - -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 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 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 - -fakeroot dpkg-deb --build $DIST -rm -rf $DIST -cp $BASE.deb $ARTIFACTS/ diff --git a/linux/make_tarball.sh b/linux/make_tarball.sh deleted file mode 100644 index 8961d7ee5..000000000 --- a/linux/make_tarball.sh +++ /dev/null @@ -1,19 +0,0 @@ -set -e - -ARTIFACTS="${ARTIFACTS:-/artifacts}" -VERSION=`$ARTIFACTS/pandoc --version | awk '{print $2; exit;}'` -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 /usr/src/pandoc/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 -- cgit v1.2.3