Switched to alpine:latest instead curlimages/curl

Switched to alpine:latest instead curlimages/curl; this uses the root account, which has permissions to run `apk` install commands
This commit is contained in:
2026-08-26 08:08:55 +01:00
parent 6cd574fe10
commit 2b6703253c
+53 -169
View File
@@ -1,184 +1,68 @@
when:
- event: [manual, push]
branch: [main, master]
event: manual
steps:
- name: build-arch-iso
image: archlinux/archlinux:latest
- name: build
image: archlinux:latest
privileged: true
commands:
- |
# 1. Install dependencies
pacman -Sy --noconfirm \
archiso squashfs-tools xorriso dosfstools \
p7zip curl util-linux binutils jq \
gcc pkgconf readline
- pacman -Sy --noconfirm --needed base-devel git sudo
- useradd -m builder
- echo "builder ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/builder
- pacman-key --init
- pacman-key --populate archlinux
- git clone https://aur.archlinux.org/wezterm-git.git /home/builder/wezterm-git
- chown -R builder:builder /home/builder/wezterm-git
- (cd /home/builder/wezterm-git && sed -i '/pkgver() {/,/}/c\pkgver() {\n cd "$srcdir/wezterm"\n printf "%s.%s.%s" "$(date +%Y%m%d)" "$(date +%H%M%S)" "$(git rev-parse --short HEAD)"\n}' PKGBUILD)
- sudo -u builder bash -lc 'cd ~/wezterm-git && export MAKEFLAGS="-j$(nproc)" && makepkg --noconfirm --needed --skippgpcheck -s'
- cp /home/builder/wezterm-git/*.pkg.tar.zst "$CI_WORKSPACE/"
- cd "$CI_WORKSPACE"
- ls *.pkg.tar.zst > pkg_files.txt
- main_pkg=$(grep -v -- '-debug-' pkg_files.txt | head -n 1)
- echo "${main_pkg%-x86_64.pkg.tar.zst}" > pkg_ver.txt
- date '+%Y%m%d_%H%M%S' > release_tag.txt
# 2. Determine build timestamp
BUILD_TS="${BUILD_DATE}"
[ -z "$BUILD_TS" ] && BUILD_TS=$(date '+%Y%m%d_%H%M%S')
echo "Build Timestamp: $BUILD_TS"
# 3. Prepare XFCE profile
PROFILE=xfce-profile
rm -rf "$PROFILE"
cp -r /usr/share/archiso/configs/releng "$PROFILE"
mkdir -p \
"$PROFILE/airootfs/root" \
"$PROFILE/airootfs/etc/lightdm" \
"$PROFILE/airootfs/etc/systemd/system/multi-user.target.wants"
for pkg in \
xfce4 xfce4-goodies xorg-server xorg-xinit \
lightdm lightdm-gtk-greeter networkmanager \
firefox htop iotop gparted network-manager-applet \
ncdu sbctl
do
echo "$pkg" >> "$PROFILE/packages.x86_64"
done
# Enable NetworkManager service on boot
ln -s /usr/lib/systemd/system/NetworkManager.service \
"$PROFILE/airootfs/etc/systemd/system/multi-user.target.wants/NetworkManager.service"
# Create nm-applet autostart file
mkdir -p "$PROFILE/airootfs/root/.config/autostart"
AUTOSTART="$PROFILE/airootfs/root/.config/autostart/nm-applet.desktop"
echo '[Desktop Entry]' > "$AUTOSTART"
echo 'Type=Application' >> "$AUTOSTART"
echo 'Name=Network Manager Applet' >> "$AUTOSTART"
echo 'Exec=nm-applet --indicator' >> "$AUTOSTART"
echo 'OnlyShowIn=XFCE;' >> "$AUTOSTART"
echo 'Terminal=false' >> "$AUTOSTART"
echo 'X-GNOME-Autostart-enabled=true' >> "$AUTOSTART"
sed -i \
-e 's/^iso_name=.*/iso_name="archlinux-xfce"/' \
-e 's/^iso_label=.*/iso_label="ARCH_XFCE"/' \
"$PROFILE/profiledef.sh"
# ZSTD compression tweaks
sed -i "s|'-comp' 'xz'|'-comp' 'zstd' '-Xcompression-level' '5'|" "$PROFILE/profiledef.sh"
sed -i "s|'-Xbcj' 'x86'||" "$PROFILE/profiledef.sh"
sed -i "s|'-Xdict-size' '1M'||" "$PROFILE/profiledef.sh"
# Force script and binary permissions in profiledef.sh
sed -i '/file_permissions=(/a\ ["/root/arch.sh"]="0:0:755"\n ["/root/eficlean.sh"]="0:0:755"\n ["/usr/local/bin/diskviz"]="0:0:755"' "$PROFILE/profiledef.sh"
# 4. Build and embed diskviz binary (corrected raw endpoint path)
BIN_DIR="$PROFILE/airootfs/usr/local/bin"
mkdir -p "$BIN_DIR"
curl -fsSL -H "Authorization: token $GITEA_TOKEN" \
"https://git.georgetech.co.uk/api/v1/repos/george/systems-programming/raw/main/diskviz/diskviz.c" \
-o diskviz.c
gcc -O2 -Wall $(pkg-config --cflags --libs fdisk blkid) -lreadline \
-o "$BIN_DIR/diskviz" diskviz.c
chmod +x "$BIN_DIR/diskviz"
# 5. Download custom installation scripts (corrected raw endpoint paths)
curl -fsSL -H "Authorization: token $GITEA_TOKEN" \
"https://git.georgetech.co.uk/api/v1/repos/george/arch/raw/master/arch.sh" \
-o "$PROFILE/airootfs/root/arch.sh"
chmod +x "$PROFILE/airootfs/root/arch.sh"
curl -fsSL -H "Authorization: token $GITEA_TOKEN" \
"https://git.georgetech.co.uk/api/v1/repos/george/arch/raw/master/eficlean.sh" \
-o "$PROFILE/airootfs/root/eficlean.sh"
chmod +x "$PROFILE/airootfs/root/eficlean.sh"
# Setup Bash profile environment & welcome banner
BP="$PROFILE/airootfs/root/.bash_profile"
echo 'chmod +x /root/arch.sh /root/eficlean.sh' >> "$BP"
echo 'systemctl start NetworkManager.service' >> "$BP"
echo "printf '\n\e[1;36m========================================================\e[0m\n'" >> "$BP"
echo "printf '\e[1;36m Arch Linux Live Environment\e[0m\n'" >> "$BP"
echo "printf '\e[1;36m========================================================\e[0m\n\n'" >> "$BP"
echo "printf ' \e[1;32mdiskviz\e[0m - inspect and partition your disks\n'" >> "$BP"
echo "printf ' \e[1;32m./arch.sh\e[0m - start the Arch installation\n'" >> "$BP"
echo "printf ' \e[1;32m./eficlean.sh\e[0m - manage EFI boot entries\n\n'" >> "$BP"
echo "printf ' Tip: run \e[1;32mdiskviz\e[0m first if you need help partitioning,\n'" >> "$BP"
echo "printf ' then run \e[1;32m./arch.sh\e[0m to begin.\n'" >> "$BP"
echo "printf '\e[1;36m========================================================\e[0m\n\n'" >> "$BP"
echo 'root:x:0:0:root:/root:/bin/bash' > "$PROFILE/airootfs/etc/passwd"
echo 'exec startxfce4' > "$PROFILE/airootfs/root/.xinitrc"
echo '[Seat:*]' > "$PROFILE/airootfs/etc/lightdm/lightdm.conf"
echo 'autologin-user=root' >> "$PROFILE/airootfs/etc/lightdm/lightdm.conf"
echo 'autologin-session=xfce' >> "$PROFILE/airootfs/etc/lightdm/lightdm.conf"
# Console keymap & font
mkdir -p "$PROFILE/airootfs/etc"
echo "KEYMAP=uk" > "$PROFILE/airootfs/etc/vconsole.conf"
echo "XKBLAYOUT=gb" >> "$PROFILE/airootfs/etc/vconsole.conf"
echo "FONT=ter-922b" >> "$PROFILE/airootfs/etc/vconsole.conf"
# Pacman hook to clean unwanted firmware
mkdir -p "$PROFILE/airootfs/etc/pacman.d/hooks"
HOOK_FILE="$PROFILE/airootfs/etc/pacman.d/hooks/remove-unneeded-fw.hook"
echo '[Trigger]' > "$HOOK_FILE"
echo 'Operation = Install' >> "$HOOK_FILE"
echo 'Type = Package' >> "$HOOK_FILE"
echo 'Target = linux-firmware' >> "$HOOK_FILE"
echo >> "$HOOK_FILE"
echo '[Action]' >> "$HOOK_FILE"
echo 'Description = Remove unneeded firmware directories' >> "$HOOK_FILE"
echo 'When = PostTransaction' >> "$HOOK_FILE"
echo 'Exec = /usr/bin/rm -rf /usr/lib/firmware/nvidia /usr/lib/firmware/mrvl' >> "$HOOK_FILE"
# 6. Build the ISO
OUT=out
mkarchiso -v -o "$OUT" "$PROFILE"
ISO=$(find "$OUT" -maxdepth 1 -type f -name '*.iso' -print -quit)
[ -z "$ISO" ] && { echo "ERROR: ISO not found!" >&2; exit 1; }
# 7. Verify permissions inside squashfs
SQFS=$(find . -type f -name 'airootfs.sfs' -print -quit)
[ -z "$SQFS" ] && { echo "ERROR: airootfs.sfs not found!" >&2; exit 1; }
EXTRACT_DIR=$(mktemp -d)
unsquashfs -d "$EXTRACT_DIR/extracted" "$SQFS" root/arch.sh root/eficlean.sh usr/local/bin/diskviz
[ -x "$EXTRACT_DIR/extracted/root/arch.sh" ] || { echo "ERROR: arch.sh not executable!" >&2; exit 1; }
[ -x "$EXTRACT_DIR/extracted/root/eficlean.sh" ] || { echo "ERROR: eficlean.sh not executable!" >&2; exit 1; }
[ -x "$EXTRACT_DIR/extracted/usr/local/bin/diskviz" ] || { echo "ERROR: diskviz not executable!" >&2; exit 1; }
rm -rf "$EXTRACT_DIR"
# 8. Stage ISO inside the workspace repository directory
mkdir -p release
cp "$ISO" release/archlinux-xfce-$BUILD_TS.iso
- name: release
image: alpine:latest
environment:
GITEA_TOKEN:
from_secret: gitea_token
- name: upload-iso-to-gitea
image: archlinux/archlinux:latest
commands:
- pacman -Sy --noconfirm curl jq
- apk add --no-cache curl jq
- pkg_ver=$(cat pkg_ver.txt)
- release_tag=$(cat release_tag.txt)
- |
ISO_FILE=$(find release -name '*.iso' -print -quit)
if [ -z "$ISO_FILE" ]; then
echo "Error: ISO file not found in workspace release directory."
response=$(curl -s -w '\n%{http_code}' -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${release_tag}\",\"name\":\"${pkg_ver}\",\"body\":\"Build: wezterm-git\\nVersion: ${pkg_ver}\"}" \
"https://git.georgetech.co.uk/api/v1/repos/george/linux-software-to-compile/releases")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
if [ "$http_code" != "201" ]; then
echo "Release creation failed (HTTP $http_code):"
echo "$body"
exit 1
fi
TARGET_TAG="1.0.1"
RELEASE_ID=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
"https://git.georgetech.co.uk/api/v1/repos/george/systems-programming/releases/tags/$TARGET_TAG" | jq '.id')
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
echo "Error: Release $TARGET_TAG not found on Gitea."
release_id=$(echo "$body" | jq -r '.id')
if [ -z "$release_id" ] || [ "$release_id" = "null" ]; then
echo "Could not parse release id from response:"
echo "$body"
exit 1
fi
curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@$ISO_FILE" \
"https://git.georgetech.co.uk/api/v1/repos/george/systems-programming/releases/$RELEASE_ID/assets"
environment:
GITEA_TOKEN:
from_secret: gitea_token
echo "$release_id" > release_id.txt
- |
release_id=$(cat release_id.txt)
while read -r pkg_file; do
asset_response=$(curl -s -w '\n%{http_code}' -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-F "attachment=@${pkg_file}" \
"https://git.georgetech.co.uk/api/v1/repos/george/linux-software-to-compile/releases/${release_id}/assets?name=${pkg_file}")
asset_http_code=$(echo "$asset_response" | tail -n1)
asset_body=$(echo "$asset_response" | sed '$d')
if [ "$asset_http_code" != "201" ]; then
echo "Asset upload failed for ${pkg_file} (HTTP $asset_http_code):"
echo "$asset_body"
exit 1
fi
done < pkg_files.txt