2017-03-19 16:24:52 +01:00
|
|
|
set -e
|
|
|
|
|
|
|
|
MACHINE=$(uname -m)
|
|
|
|
case "$MACHINE" in
|
2021-03-06 22:44:14 +01:00
|
|
|
x86_64) ARCHITECTURE=amd64;;
|
|
|
|
i686) ARCHITECTURE=i386;;
|
|
|
|
i386) ARCHITECTURE=i386;;
|
|
|
|
aarch64) ARCHITECTURE=arm64;;
|
2022-02-28 18:03:25 +01:00
|
|
|
armv6l | armv7l) ARCHITECTURE=armhf;;
|
2021-03-06 22:45:16 +01:00
|
|
|
*) ARCHITECTURE=unknown;;
|
2017-03-19 16:24:52 +01:00
|
|
|
esac
|
|
|
|
|
2017-10-23 06:19:17 +02:00
|
|
|
ARTIFACTS="${ARTIFACTS:-/artifacts}"
|
2017-03-19 16:24:52 +01:00
|
|
|
|
2021-03-09 00:02:26 +01:00
|
|
|
# This is our sentinel that tells us when we're done.
|
|
|
|
rm -f $ARTIFACTS/DONE
|
2021-03-08 23:51:03 +01:00
|
|
|
|
|
|
|
clean_up() {
|
|
|
|
echo "All done!" > "$ARTIFACTS/DONE"
|
|
|
|
}
|
|
|
|
trap clean_up EXIT
|
|
|
|
|
2020-07-24 18:57:27 +02:00
|
|
|
# build binaries
|
|
|
|
|
|
|
|
cabal --version
|
|
|
|
ghc --version
|
|
|
|
|
2022-08-16 03:59:13 +02:00
|
|
|
cabal update
|
|
|
|
cabal clean
|
2022-08-17 01:27:31 +02:00
|
|
|
cabal configure -f-export-dynamic -fembed_data_files --enable-executable-static --ghc-options '-j4 +RTS -A256m -RTS -split-sections -optc-Os -optl=-pthread' pandoc
|
2022-08-16 19:55:36 +02:00
|
|
|
cabal build -j4
|
|
|
|
for f in $(find dist-newstyle -name 'pandoc' -type f -perm /400); do cp $f $ARTIFACTS/; done
|
|
|
|
|
|
|
|
# Confirm that we have static builds
|
|
|
|
file $ARTIFACTS/pandoc | grep "statically linked"
|
2020-07-24 18:57:27 +02:00
|
|
|
|
2022-08-15 19:09:32 +02:00
|
|
|
make_deb() {
|
2022-08-17 01:27:31 +02:00
|
|
|
VERSION=`$ARTIFACTS/pandoc --version | awk '{print $2; exit;}'`
|
2022-08-15 19:09:32 +02:00
|
|
|
REVISION=${REVISION:-1}
|
|
|
|
DEBVER=$VERSION-$REVISION
|
2022-08-17 01:27:31 +02:00
|
|
|
BASE=pandoc-$DEBVER-$ARCHITECTURE
|
2022-08-15 23:37:06 +02:00
|
|
|
DIST=/mnt/$BASE
|
2022-08-15 19:09:32 +02:00
|
|
|
DEST=$DIST/usr
|
2022-08-17 01:27:31 +02:00
|
|
|
COPYRIGHT=$DEST/share/doc/pandoc/copyright
|
2022-08-15 19:09:32 +02:00
|
|
|
|
2022-08-16 02:38:05 +02:00
|
|
|
cd /mnt
|
2022-08-15 19:09:32 +02:00
|
|
|
mkdir -p $DEST/bin
|
|
|
|
mkdir -p $DEST/share/man/man1
|
2022-08-17 01:27:31 +02:00
|
|
|
mkdir -p $DEST/share/doc/pandoc
|
2022-08-15 19:09:32 +02:00
|
|
|
|
|
|
|
find $DIST -type d | xargs chmod 755
|
2022-08-17 01:27:31 +02:00
|
|
|
cp $ARTIFACTS/pandoc $DEST/bin/
|
|
|
|
cd $DEST/bin
|
|
|
|
strip pandoc
|
|
|
|
ln -s pandoc pandoc-server
|
|
|
|
cd /mnt
|
|
|
|
cp /mnt/man/pandoc.1 $DEST/share/man/man1/pandoc.1
|
|
|
|
gzip -9 $DEST/share/man/man1/pandoc.1
|
|
|
|
cp /mnt/man/pandoc-server.1 $DEST/share/man/man1/pandoc-server.1
|
|
|
|
gzip -9 $DEST/share/man/man1/pandoc-server.1
|
2022-08-15 19:09:32 +02:00
|
|
|
|
|
|
|
cp /mnt/COPYRIGHT $COPYRIGHT
|
|
|
|
echo "" >> $COPYRIGHT
|
|
|
|
|
|
|
|
INSTALLED_SIZE=$(du -k -s $DEST | awk '{print $1}')
|
|
|
|
mkdir $DIST/DEBIAN
|
2022-08-17 01:27:31 +02:00
|
|
|
perl -pe "s/VERSION/$DEBVER/" /mnt/linux/control.in | \
|
2022-08-15 19:09:32 +02:00
|
|
|
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/
|
|
|
|
}
|
|
|
|
|
2022-08-17 01:27:31 +02:00
|
|
|
# Make tarball for pandoc
|
2022-08-15 19:09:32 +02:00
|
|
|
make_tarball() {
|
2022-08-17 01:27:31 +02:00
|
|
|
TARGET=pandoc-$VERSION
|
2022-08-15 19:09:32 +02:00
|
|
|
cd $ARTIFACTS
|
|
|
|
rm -rf $TARGET
|
|
|
|
mkdir $TARGET
|
|
|
|
mkdir $TARGET/bin $TARGET/share $TARGET/share/man $TARGET/share/man/man1
|
2022-08-17 01:27:31 +02:00
|
|
|
cp /mnt/man/pandoc.1 $TARGET/share/man/man1
|
|
|
|
cp /mnt/man/pandoc-server.1 $TARGET/share/man/man1
|
|
|
|
mv pandoc $TARGET/bin
|
|
|
|
cd $TARGET/bin
|
|
|
|
strip pandoc
|
|
|
|
ln -s pandoc pandoc-server
|
|
|
|
cd $ARTIFACTS
|
|
|
|
gzip -9 $TARGET/share/man/man1/pandoc.1
|
|
|
|
gzip -9 $TARGET/share/man/man1/pandoc-server.1
|
2022-08-15 19:09:32 +02:00
|
|
|
|
|
|
|
tar cvzf $TARGET-linux-$ARCHITECTURE.tar.gz $TARGET
|
|
|
|
rm -r $TARGET
|
|
|
|
}
|
|
|
|
|
2022-08-17 01:27:31 +02:00
|
|
|
make_deb
|
|
|
|
make_tarball
|
2021-03-08 23:51:03 +01:00
|
|
|
|
|
|
|
exit 0
|