clear messages
This commit is contained in:
+32
-14
@@ -7,11 +7,12 @@
|
||||
#
|
||||
# Copy it to the server, then: tar xzf movim-*.tar.gz && cd movim-* && ./install.sh
|
||||
#
|
||||
# Overridable: DEBIAN (default bookworm: Debian 12, also runs on 13 trixie),
|
||||
# RUST_IMAGE (default rust:1-$DEBIAN), DOCKER (default docker; podman works).
|
||||
# Overridable: DEBIAN (default trixie: Debian 13 and newer; bookworm for 12),
|
||||
# RUST_IMAGE (default rust:1-$DEBIAN), DOCKER (default docker; podman works),
|
||||
# REBUILD (yes/no; asked when a binary exists, default yes without a terminal).
|
||||
set -eu
|
||||
|
||||
DEBIAN=${DEBIAN:-bookworm}
|
||||
DEBIAN=${DEBIAN:-trixie}
|
||||
RUST_IMAGE=${RUST_IMAGE:-rust:1-$DEBIAN}
|
||||
DOCKER=${DOCKER:-docker}
|
||||
|
||||
@@ -19,8 +20,6 @@ die() { echo "error: $*" >&2; exit 1; }
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
[ -f Cargo.toml ] || die "run this from the movim-rs repository"
|
||||
command -v "$DOCKER" >/dev/null || die "$DOCKER not found"
|
||||
"$DOCKER" info >/dev/null 2>&1 || die "cannot reach $DOCKER; start it (sudo systemctl start docker) and make sure you may use it (docker group)"
|
||||
|
||||
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
|
||||
name="movim-$version-$DEBIAN"
|
||||
@@ -29,20 +28,39 @@ name="movim-$version-$DEBIAN"
|
||||
cache="target/docker-$DEBIAN"
|
||||
mkdir -p "$cache/cargo"
|
||||
|
||||
echo "==> Building $name in $RUST_IMAGE"
|
||||
"$DOCKER" run --rm \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
-v "$PWD:/src" -w /src \
|
||||
-e CARGO_HOME="/src/$cache/cargo" \
|
||||
-e CARGO_TARGET_DIR="/src/$cache" \
|
||||
"$RUST_IMAGE" \
|
||||
sh -c 'rustc --version && cargo build --release --locked'
|
||||
bin="$cache/release/movim"
|
||||
rebuild=${REBUILD:-}
|
||||
if [ -z "$rebuild" ] && [ -x "$bin" ]; then
|
||||
if [ -t 0 ]; then
|
||||
printf 'A binary exists (built %s). Rebuild? [Y/n] ' "$(date -r "$bin" '+%Y-%m-%d %H:%M')"
|
||||
read -r answer || answer=n
|
||||
case $answer in [nN]*) rebuild=no ;; *) rebuild=yes ;; esac
|
||||
else
|
||||
rebuild=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$rebuild" = no ]; then
|
||||
[ -x "$bin" ] || die "REBUILD=no but there is no binary at $bin"
|
||||
echo "==> Reusing $bin"
|
||||
else
|
||||
command -v "$DOCKER" >/dev/null || die "$DOCKER not found"
|
||||
"$DOCKER" info >/dev/null 2>&1 || die "cannot reach $DOCKER; start it (sudo systemctl start docker) and make sure you may use it (docker group)"
|
||||
echo "==> Building $name in $RUST_IMAGE"
|
||||
"$DOCKER" run --rm \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
-v "$PWD:/src" -w /src \
|
||||
-e CARGO_HOME="/src/$cache/cargo" \
|
||||
-e CARGO_TARGET_DIR="/src/$cache" \
|
||||
"$RUST_IMAGE" \
|
||||
sh -c 'rustc --version && cargo build --release --locked'
|
||||
fi
|
||||
|
||||
echo "==> Packing dist/$name.tar.gz"
|
||||
stage=$(mktemp -d)
|
||||
trap 'rm -rf "$stage"' EXIT
|
||||
mkdir "$stage/$name"
|
||||
cp "$cache/release/movim" install.sh "$stage/$name/"
|
||||
cp "$bin" install.sh "$stage/$name/"
|
||||
cp -R frontend templates "$stage/$name/"
|
||||
mkdir -p dist
|
||||
tar -C "$stage" -czf "dist/$name.tar.gz" "$name"
|
||||
|
||||
Reference in New Issue
Block a user