Skip to content

Commit add5dab

Browse files
committed
Add aptly
1 parent 1f053a3 commit add5dab

2 files changed

Lines changed: 139 additions & 0 deletions

File tree

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ RUN dnf -y install createrepo_c devscripts reprepro jq wget2-wget tree rpm-sign
1515

1616
# From the line of the binutils is the requirements of the SELinux config rpm builder
1717

18+
COPY aptly.sh /tmp/aptly.sh
19+
RUN /tmp/aptly.sh
20+
1821
RUN gem update --system --no-document &&\
1922
gem install fpm --no-document &&\
2023
gem clean &&\

aptly.sh

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# ============================================================
5+
# User-configurable variables (must start with APTLY_)
6+
# ============================================================
7+
8+
# Target release tag, without "v"
9+
APTLY_TAG="1.6.2"
10+
11+
# SHA256 checksums for the release zip files
12+
# Fill in the exact 64-hex-character SHA256 values for the given tag
13+
APTLY_SHA256_AMD64="c180d6d3c1e78f08a9e36cb07f64f3d98a5dba4111b02f58050b06f220a76c15"
14+
APTLY_SHA256_ARM64="6fe08d26a2d2a84ce91630e72122495ed76157f02dff172cfa83c06ae4deb70c"
15+
16+
# ============================================================
17+
# Internal configuration
18+
# ============================================================
19+
20+
APTLY_REPO="aptly-dev/aptly"
21+
APTLY_GITHUB_API="https://api.github.com"
22+
APTLY_TMP="/tmp"
23+
APTLY_WORKDIR="$(mktemp -d -p "$APTLY_TMP" aptly-install.XXXXXX)"
24+
25+
# Cleanup temporary directory on exit
26+
cleanup() {
27+
rm -rf "$APTLY_WORKDIR"
28+
}
29+
trap cleanup EXIT
30+
31+
# Root privileges are required for installation paths
32+
if [[ "${EUID:-$(id -u)}" -ne 0 ]]; then
33+
echo "ERROR: This script must be run as root (e.g. via sudo)." >&2
34+
exit 1
35+
fi
36+
37+
# Detect system architecture
38+
APTLY_UNAME_M="$(uname -m)"
39+
case "$APTLY_UNAME_M" in
40+
x86_64)
41+
APTLY_ARCH="amd64"
42+
;;
43+
aarch64|arm64)
44+
APTLY_ARCH="arm64"
45+
;;
46+
*)
47+
echo "ERROR: Unsupported architecture: $APTLY_UNAME_M" >&2
48+
exit 1
49+
;;
50+
esac
51+
52+
echo "Detected architecture: $APTLY_ARCH"
53+
echo "Target aptly tag: $APTLY_TAG"
54+
55+
# ------------------------------------------------------------
56+
# Fetch release metadata for the specified tag using curl
57+
# ------------------------------------------------------------
58+
59+
APTLY_RELEASE_JSON="$APTLY_WORKDIR/release.json"
60+
61+
curl -fsSL \
62+
-H "Accept: application/vnd.github+json" \
63+
"$APTLY_GITHUB_API/repos/$APTLY_REPO/releases/tags/v$APTLY_TAG" \
64+
-o "$APTLY_RELEASE_JSON"
65+
66+
# Determine the correct asset name and download URL
67+
APTLY_ZIP_NAME="aptly_${APTLY_TAG}_linux_${APTLY_ARCH}.zip"
68+
APTLY_ZIP_URL="$(
69+
jq -r --arg name "$APTLY_ZIP_NAME" '
70+
.assets[]
71+
| select(.name == $name)
72+
| .browser_download_url
73+
' "$APTLY_RELEASE_JSON"
74+
)"
75+
76+
if [[ -z "$APTLY_ZIP_URL" || "$APTLY_ZIP_URL" == "null" ]]; then
77+
echo "ERROR: Release asset not found: $APTLY_ZIP_NAME" >&2
78+
exit 1
79+
fi
80+
81+
echo "Downloading: $APTLY_ZIP_NAME"
82+
83+
# Download the zip file
84+
APTLY_ZIP_PATH="$APTLY_WORKDIR/$APTLY_ZIP_NAME"
85+
wget -O "$APTLY_ZIP_PATH" "$APTLY_ZIP_URL"
86+
87+
# Select expected SHA256 based on architecture
88+
case "$APTLY_ARCH" in
89+
amd64)
90+
APTLY_EXPECTED_SHA256="$APTLY_SHA256_AMD64"
91+
;;
92+
arm64)
93+
APTLY_EXPECTED_SHA256="$APTLY_SHA256_ARM64"
94+
;;
95+
esac
96+
97+
# Ensure SHA256 variables are properly set
98+
if [[ "$APTLY_EXPECTED_SHA256" == "PUT_AMD64_ZIP_SHA256_HERE" || \
99+
"$APTLY_EXPECTED_SHA256" == "PUT_ARM64_ZIP_SHA256_HERE" ]]; then
100+
echo "ERROR: SHA256 checksum variable is not set correctly." >&2
101+
exit 1
102+
fi
103+
104+
echo "Verifying SHA256 checksum"
105+
echo "${APTLY_EXPECTED_SHA256} ${APTLY_ZIP_PATH}" | sha256sum -c -
106+
107+
# Extract the zip archive
108+
echo "Extracting archive"
109+
unzip -q "$APTLY_ZIP_PATH" -d "$APTLY_WORKDIR"
110+
111+
APTLY_EXTRACT_DIR="$APTLY_WORKDIR/aptly_${APTLY_TAG}_linux_${APTLY_ARCH}"
112+
if [[ ! -d "$APTLY_EXTRACT_DIR" ]]; then
113+
echo "ERROR: Expected extraction directory not found: $APTLY_EXTRACT_DIR" >&2
114+
exit 1
115+
fi
116+
117+
# ============================================================
118+
# Installation steps
119+
# ============================================================
120+
121+
echo "Installing aptly binary to /usr/bin"
122+
install -m 0755 "$APTLY_EXTRACT_DIR/aptly" /usr/bin/aptly
123+
124+
echo "Installing LICENSE to /usr/share/doc/aptly"
125+
install -d -m 0755 /usr/share/doc/aptly
126+
install -m 0644 "$APTLY_EXTRACT_DIR/LICENSE" /usr/share/doc/aptly/LICENSE
127+
128+
echo "Installing bash completion"
129+
install -d -m 0755 /usr/share/bash-completion/completions
130+
install -m 0644 \
131+
"$APTLY_EXTRACT_DIR/completion/bash_completion.d/aptly" \
132+
/usr/share/bash-completion/completions/aptly
133+
134+
echo "Installation completed successfully."
135+
echo "aptly version: $APTLY_TAG"
136+
echo "architecture: $APTLY_ARCH"

0 commit comments

Comments
 (0)