|
root / scripts / package-binary.sh
package-binary.sh Bash 72 lines 2.2 KB
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
#
# repoman :: build a relocatable linux-amd64 binary release bundle.
#
# Produces:
#   dist/repoman-<version>-linux-amd64.tar.gz
#
# No checksum file: Isurus CI computes and publishes SHA-256/512/MD5 for every
# release asset automatically.
#
# The bundle mirrors a real `make install` tree (bin/ + share/repoman/...) under a
# usr/local/ prefix, plus a standalone install.sh so end users need no reefc/make.
#
# Usage: ./scripts/package-binary.sh [version]   (version defaults to reef.toml)
# Env:   REPOMAN_DIST  output dir (default: dist)

set -eu

script_dir="$(cd "$(dirname -- "$0")" && pwd)"
repo_dir="$(dirname -- "$script_dir")"
cd "$repo_dir"

# Version: explicit arg wins, else the single source of truth in reef.toml.
if [ "${1:-}" != "" ]; then
    version="$1"
else
    version="$(grep '^version' reef.toml | head -n1 | sed 's/.*"\([^"]*\)".*/\1/')"
fi
if [ -z "$version" ]; then
    echo "package-binary.sh: could not determine version" >&2
    exit 1
fi

name="repoman-${version}-linux-amd64"
dist="${REPOMAN_DIST:-dist}"

stage="$(mktemp -d)"
trap 'rm -rf "$stage"' EXIT

# Lay out the real install tree into the staging root. Reusing `make install`
# keeps one definition of the layout: new profiles/recipes are picked up for free.
make install DESTDIR="$stage/$name" PREFIX=/usr/local

# Metadata + standalone installer alongside the staged usr/local/ tree.
cp README.md LICENSE "$stage/$name/"

cat > "$stage/$name/install.sh" <<'EOF'
#!/bin/sh
# repoman standalone installer (bundled in the binary release).
# Copies the bundled usr/local/ tree into PREFIX. No reefc or make required.
#
# Usage: ./install.sh            # installs under /usr/local (may need sudo)
#        PREFIX=~/.local ./install.sh
set -eu
prefix="${PREFIX:-/usr/local}"
here="$(cd "$(dirname -- "$0")" && pwd)"
if [ ! -d "$here/usr/local" ]; then
    echo "install.sh: expected $here/usr/local — run from the unpacked bundle dir" >&2
    exit 1
fi
mkdir -p "$prefix"
cp -a "$here/usr/local/." "$prefix/"
echo "repoman installed under $prefix"
"$prefix/bin/repoman" --version
EOF
chmod +x "$stage/$name/install.sh"

mkdir -p "$dist"
tar -czf "$dist/$name.tar.gz" -C "$stage" "$name"

echo "built: $dist/$name.tar.gz"