opam-graph/packaging/FreeBSD/create_package.sh

43 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2022-07-21 08:22:14 +00:00
#!/bin/sh -e
# only execute anything if either
2022-07-27 08:15:22 +00:00
# - running under orb with package = opam-graph
2022-07-21 08:22:14 +00:00
# - not running under opam at all
if [ "$ORB_BUILDING_PACKAGE" != "opam-graph" -a "$OPAM_PACKAGE_NAME" != "" ]; then
exit 0;
fi
basedir=$(realpath "$(dirname "$0")"/../..)
pdir=$basedir/packaging/FreeBSD
2022-07-21 08:22:14 +00:00
bdir=$basedir/_build/install/default/bin
tmpd=$basedir/_build/stage
manifest=$tmpd/+MANIFEST
2022-08-24 12:42:22 +00:00
rootdir=$tmpd/rootdir
2022-07-21 08:22:14 +00:00
bindir=$rootdir/usr/local/bin
trap 'rm -rf $tmpd' 0 INT EXIT
mkdir -p "$bindir"
install -U "$bdir/opam-graph" "$bindir/opam-graph"
flatsize=$(find "$rootdir" -type f -exec stat -f %z {} + |
awk 'BEGIN {s=0} {s+=$1} END {print s}')
2022-08-24 12:52:53 +00:00
sed -e "s:%%FLATSIZE%%:${flatsize}:" -e "/^[Vv]ersion:/s/-/./g" "$pdir/MANIFEST" > "$manifest"
2022-07-21 08:22:14 +00:00
{
printf '\nfiles {\n'
find "$rootdir" -type f -exec sha256 -r {} + | sort |
awk '{print " " $2 ": \"" $1 "\","}'
fidn "$rootdir" -type l | sort |
awk '{print " " $1 ": -,"}'
printf '}\n'
} | sed -e "s:${rootdir}::" >> "$manifest"
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=format:%ct)
pkg create -r "$rootdir" -M "$manifest" -o "$basedir/"
2022-07-27 08:15:22 +00:00
mv "$basedir"/opam-graph-*.pkg "$basedir/opam-graph.pkg"
echo 'bin: [ "opam-graph.pkg" ]' > "$basedir/opam-graph.install"
echo 'doc: [ "README.md" ]' >> "$basedir/opam-graph.install"