omega-packages
aien-dev/omega-packages
Brought by drakestapleton
omega-packages / debian / build-deb.sh
| 1 | #!/bin/sh |
| 2 | # build-deb.sh OMC OUTDIR -- package an already hash-checked omc (scripts/omc-from-seed.sh) as |
| 3 | # OUTDIR/omc_<version>-1_arm64.deb. Binary package only, assembled with dpkg-deb; the build itself |
| 4 | # is the seed chain, which needs no compiler, so there is no debhelper source package. |
| 5 | set -eu |
| 6 | here=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) |
| 7 | . "$here/pins.env" |
| 8 | [ $# -eq 2 ] || { echo "usage: build-deb.sh OMC OUTDIR" >&2; exit 2; } |
| 9 | omc=$1 out=$2 |
| 10 | got=$(sha256sum "$omc" | cut -d' ' -f1) |
| 11 | [ "$got" = "$OMC_SHA256" ] || { echo "FAIL omc sha256 $got, pinned $OMC_SHA256" >&2; exit 1; } |
| 12 | ver=$OMC_VERSION-1 |
| 13 | mkdir -p "$out" |
| 14 | root=$(mktemp -d) |
| 15 | trap 'rm -rf "$root"' EXIT |
| 16 | install -Dm0755 "$omc" "$root/usr/bin/omc" |
| 17 | install -Dm0644 "$here/LICENSE" "$root/usr/share/doc/omc/copyright" |
| 18 | install -Dm0644 "$here/examples/hello.om" "$root/usr/share/doc/omc/examples/hello.om" |
| 19 | mkdir -p "$root/DEBIAN" |
| 20 | size=$(du -sk "$root/usr" | cut -f1) |
| 21 | sed -e "s/@VERSION@/$ver/" -e "s/@SIZE@/$size/" -e "s/@COMMIT@/$OMEGA_MV_COMMIT/" \ |
| 22 | -e "s/@OMC_SHA256@/$OMC_SHA256/" "$here/debian/control.in" > "$root/DEBIAN/control" |
| 23 | deb=$out/omc_${ver}_arm64.deb |
| 24 | SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-0} dpkg-deb --root-owner-group -Zxz --build "$root" "$deb" >/dev/null |
| 25 | echo "$deb" |