blob: 9af784d6d637cbe99ff3c90d5e1056534d87d71f (
plain)
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
72
73
74
75
76
|
#!/usr/bin/env bash
# Install one or more built dispatch packages with yay -U.
#
# Default: installs the freshest dispatch + dispatch-systemd from packaging/.
# Pass package names (without version) to install a custom set.
#
# Usage:
# bin/install-pkg # dispatch + dispatch-systemd + code-search
# bin/install-pkg dispatch dispatch-s6 # dispatch + dispatch-s6
# bin/install-pkg dispatch dispatch-electron # dispatch + electron wrapper
# bin/install-pkg --all # every freshest pkg found
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
PACKAGING_DIR="$PROJECT_DIR/packaging"
ELECTRON_DIR="$PROJECT_DIR/packaging/electron"
# Find the most recent .pkg.tar.zst matching a package name in a given dir.
find_pkg() {
local name="$1" dir="$2"
ls -t "$dir"/"$name"-[0-9]*-x86_64.pkg.tar.zst 2>/dev/null | head -1
}
# Resolve a package name to its freshest tarball, searching both dirs.
resolve_pkg() {
local name="$1" path
path=$(find_pkg "$name" "$PACKAGING_DIR")
[ -n "$path" ] || path=$(find_pkg "$name" "$ELECTRON_DIR")
echo "$path"
}
declare -a names
declare -a paths
if [ $# -eq 0 ]; then
names=(dispatch dispatch-systemd)
# code-search ships a self-contained `cs` binary pinned to _cs_commit in the
# PKGBUILD; it rarely changes. Skip reinstalling it if it's already present —
# run `bin/install-pkg code-search` to force a reinstall (e.g. after a bump).
if pacman -Qq code-search &>/dev/null; then
echo "code-search already installed — skipping (run 'bin/install-pkg code-search' to force)"
else
names+=(code-search)
fi
elif [ "${1:-}" = "--all" ]; then
names=(dispatch dispatch-systemd dispatch-s6 dispatch-electron code-search)
else
names=("$@")
fi
for name in "${names[@]}"; do
path=$(resolve_pkg "$name")
if [ -z "$path" ]; then
# --all is lenient: skip missing packages
if [ "${1:-}" = "--all" ]; then
echo "warn: no built package found for '$name', skipping" >&2
continue
fi
echo "error: no built package found for '$name'" >&2
echo " run bin/build-pkg (or bin/build-pkg-electron) first." >&2
exit 1
fi
paths+=("$path")
done
if [ ${#paths[@]} -eq 0 ]; then
echo "error: nothing to install." >&2
exit 1
fi
echo "Installing:"
printf ' %s\n' "${paths[@]}"
echo ""
yay -U "${paths[@]}"
|