Skip to content

Commit a2a9d60

Browse files
committed
♻️ Synced dbin 📦 <-- Update stubdl ⌚
1 parent 01d997e commit a2a9d60

File tree

1 file changed

+16
-37
lines changed

1 file changed

+16
-37
lines changed

stubdl

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,30 @@
11
#!/bin/sh
22

3-
DEST="${TMPDIR:-/tmp}/._bdlstub_dbin.bin"
4-
5-
# Determine architecture
63
ARCH="$(uname -m)"
74
case "$ARCH" in
8-
x86_64) ARCH_SUFFIX="amd64" ;;
9-
aarch64) ARCH_SUFFIX="arm64" ;;
10-
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
5+
x86_64|amd64) ARCH="amd64" ;;
6+
aarch64|arm64) ARCH="arm64" ;;
7+
riscv64) ARCH="riscv64" ;;
8+
loongarch64|loong64) ARCH="loong64" ;;
9+
*) echo "dbin: unsupported architecture: $ARCH" >&2; exit 1 ;;
1110
esac
1211

13-
DBIN_URL="https://github.com/xplshn/dbin/releases/latest/download/dbin_${ARCH_SUFFIX}.upx"
12+
DEST="${TMPDIR:-/tmp}/.dbin_$ARCH"
13+
URL="https://github.com/xplshn/dbin/releases/download/1.7/dbin_$ARCH"
14+
[ "$ARCH" = "amd64" ] || [ "$ARCH" = "arm64" ] && URL="$URL.upx"
1415

15-
# Handle --install option
16-
if [ "$1" = "--install" ]; then
17-
DEST="$2"
18-
shift 2
19-
fi
16+
[ "$1" = "--install" ] && { DEST="$2"; shift 2; }
2017

21-
# Function to download the binary
22-
download_dbin() {
18+
if [ ! -x "$DEST" ]; then
2319
if command -v curl >/dev/null 2>&1; then
24-
curl -qfsSL "$DBIN_URL" -o "$DEST"
20+
curl -fsSL "$URL" -o "$DEST" || exit 1
2521
elif command -v wget >/dev/null 2>&1; then
26-
wget -q "$DBIN_URL" -O "$DEST"
22+
wget -q "$URL" -O "$DEST" || exit 1
2723
else
28-
echo "Neither curl nor wget are available."
29-
exit 1
24+
echo "dbin: curl or wget required" >&2; exit 1
3025
fi
31-
}
32-
33-
# Check if binary exists and is executable
34-
if [ -e "$DEST" ] && [ ! "$1" = "--install" ]; then
35-
# Run the binary
36-
"$DEST" "$@"
37-
else
38-
# Download and install the binary
39-
mkdir -p "$(dirname "$DEST")"
40-
download_dbin
41-
42-
if [ "$1" = "--install" ]; then
43-
chmod +x "$DEST"
44-
echo "DBIN IS NOW AVAILABLE. ($DEST)"
45-
exit 0
46-
fi
47-
48-
# Make the binary executable and run it
4926
chmod +x "$DEST"
50-
"$DEST" "$@"
27+
[ "$1" = "--install" ] && { echo "dbin: installed to $DEST"; exit 0; }
5128
fi
29+
30+
exec "$DEST" "$@"

0 commit comments

Comments
 (0)