Initial commit
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
resolve_root() {
|
||||
dir=$1
|
||||
set -- "$dir"/*
|
||||
if [ "$#" -eq 1 ] && [ -d "$1" ]; then
|
||||
printf '%s\n' "$1"
|
||||
else
|
||||
printf '%s\n' "$dir"
|
||||
fi
|
||||
}
|
||||
|
||||
depot_install() {
|
||||
: "${DESTDIR:?DESTDIR is not set}"
|
||||
|
||||
bin_archive=
|
||||
src_archive=
|
||||
|
||||
for f in ./*.tar.gz; do
|
||||
[ -f "$f" ] || continue
|
||||
case "$(basename "$f")" in
|
||||
pandoc-*-linux-amd64.tar.gz) bin_archive=$f ;;
|
||||
*) src_archive=$f ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "${bin_archive}" ] || {
|
||||
echo "missing pandoc binary archive" >&2
|
||||
exit 1
|
||||
}
|
||||
[ -n "${src_archive}" ] || {
|
||||
echo "missing pandoc source archive" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
trap 'rm -rf "$tmpdir"' EXIT HUP INT TERM
|
||||
|
||||
bin_unpack=$tmpdir/bin
|
||||
src_unpack=$tmpdir/src
|
||||
mkdir -p "$bin_unpack" "$src_unpack"
|
||||
|
||||
tar -xzf "$bin_archive" -C "$bin_unpack"
|
||||
tar -xzf "$src_archive" -C "$src_unpack"
|
||||
|
||||
bin_root=$(resolve_root "$bin_unpack")
|
||||
src_root=$(resolve_root "$src_unpack")
|
||||
|
||||
install -d "$DESTDIR/usr"
|
||||
install -d "$DESTDIR/usr/share/pandoc"
|
||||
|
||||
cp -a "$bin_root/bin" "$bin_root/share" "$DESTDIR/usr/"
|
||||
cp -a "$src_root/data" "$src_root/citeproc" "$DESTDIR/usr/share/pandoc/"
|
||||
|
||||
install -Dm644 "$src_root/COPYRIGHT" "$DESTDIR/usr/share/pandoc/COPYRIGHT"
|
||||
install -Dm644 "$src_root/MANUAL.txt" "$DESTDIR/usr/share/pandoc/MANUAL.txt"
|
||||
|
||||
"$bin_root/bin/pandoc" --bash-completion | \
|
||||
install -Dm644 /dev/stdin "$DESTDIR/usr/share/bash-completion/completions/pandoc"
|
||||
}
|
||||
Reference in New Issue
Block a user