1+ #! /usr/bin/env bash
2+ #
3+ # #DO NOT RUN DIRECTLY
4+ # #Self: bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Github/Runners/bootstrap/cachyos.sh")
5+ # -------------------------------------------------------#
6+
7+ # -------------------------------------------------------#
8+ set -x
9+ # # No aarch64 docker yet: https://hub.docker.com/r/cachyos/cachyos/tags
10+ # # Official Response: https://discuss.cachyos.org/t/arm-future-for-cachyos/727/2
11+ # # https://github.com/CachyOS/docker
12+ if [ " $( uname -m) " == " aarch64" ]; then
13+ exit 0
14+ fi
15+ # -------------------------------------------------------#
16+
17+ # -------------------------------------------------------#
18+ # #Bootstrap
19+ pushd " $( mktemp -d) " > /dev/null 2>&1
20+ docker stop " cachyos-base" 2> /dev/null ; docker rm " cachyos-base" 2> /dev/null
21+ docker run --name " cachyos-base" --privileged " cachyos/cachyos-v3:latest" bash -l -c '
22+ #Bootstrap
23+ pacman -y --sync --refresh --refresh --sysupgrade --noconfirm --debug
24+ packages="bash binutils curl fakechroot fakeroot git wget"
25+ for pkg in $packages; do pacman -Sy "$pkg" --noconfirm ; done
26+ for pkg in $packages; do pacman -Sy "$pkg" --needed --noconfirm ; done
27+ #Fix & Patches
28+ sed ' \' ' /DownloadUser/d' \' ' -i "/etc/pacman.conf"
29+ #sed ' \' ' s/^.*Architecture\s*=.*$/Architecture = auto/' \' ' -i "/etc/pacman.conf"
30+ sed ' \' ' 0,/^.*SigLevel\s*=.*/s//SigLevel = Never/' \' ' -i "/etc/pacman.conf"
31+ #sed ' \' ' s/^.*SigLevel\s*=.*$/SigLevel = Never/' \' ' -i "/etc/pacman.conf"
32+ sed ' \' ' /#\[multilib\]/,/#Include = .*/s/^#//' \' ' -i "/etc/pacman.conf"
33+ echo -e "nameserver 8.8.8.8\nnameserver 2620:0:ccc::2" | tee "/etc/resolv.conf"
34+ echo -e "nameserver 1.1.1.1\nnameserver 2606:4700:4700::1111" | tee -a "/etc/resolv.conf"
35+ unlink "/var/lib/dbus/machine-id" 2>/dev/null
36+ unlink "/etc/machine-id" 2>/dev/null
37+ rm -rvf "/etc/machine-id"
38+ systemd-machine-id-setup --print 2>/dev/null | tee "/var/lib/dbus/machine-id"
39+ cat "/var/lib/dbus/machine-id" | tee "/etc/machine-id"
40+ pacman -Scc --noconfirm
41+ echo "disable-scdaemon" | tee "/etc/pacman.d/gnupg/gpg-agent.conf"
42+ curl -qfsSL "https://raw.githubusercontent.com/pkgforge/flatimage-base/refs/heads/main/archlinux_hooks.sh" -o "/arch_hooks.sh"
43+ chmod +x "/arch_hooks.sh" ; "/arch_hooks.sh"
44+ rm -rfv "/arch_hooks.sh"
45+ echo "LANG=en_US.UTF-8" | tee "/etc/locale.conf"
46+ echo "LANG=en_US.UTF-8" | tee -a "/etc/locale.conf"
47+ echo "LANGUAGE=en_US:en" | tee -a "/etc/locale.conf"
48+ echo "LC_ALL=en_US.UTF-8" | tee -a "/etc/locale.conf"
49+ echo "en_US.UTF-8 UTF-8" | tee -a "/etc/locale.gen"
50+ echo "LC_ALL=en_US.UTF-8" | tee -a "/etc/environment"
51+ locale-gen ; locale-gen "en_US.UTF-8"
52+ #Cleanup
53+ pacman -y --sync --refresh --refresh --sysupgrade --noconfirm
54+ pacman -Rsn base-devel --noconfirm
55+ pacman -Rsn perl --noconfirm
56+ pacman -Rsn python --noconfirm
57+ pacman -Scc --noconfirm
58+ #Fake-Sudo
59+ pacman -Rsndd sudo 2>/dev/null
60+ rm -rvf "/usr/bin/sudo" 2>/dev/null
61+ curl -qfsSL "https://github.com/pkgforge/flatimage-base/releases/download/$(uname -m)/fake-sudo-pkexec.tar.zst" -o "./fake-sudo-pkexec.tar.zst" && chmod +x "./fake-sudo-pkexec.tar.zst"
62+ pacman -Uddd "./fake-sudo-pkexec.tar.zst" --noconfirm
63+ pacman -Syy fakeroot --needed --noconfirm
64+ rm -rvf "./fake-sudo-pkexec.tar.zst"
65+ #Yay
66+ curl -qfsSL "https://github.com/pkgforge/flatimage-base/releases/download/$(uname -m)/yay" -o "/usr/bin/yay" && chmod +x "/usr/bin/yay"
67+ yay --version ; which fakeroot yay sudo
68+ #More cleanup
69+ rm -rfv "/usr/share/gtk-doc/"* 2>/dev/null
70+ rm -rfv "/usr/share/man/"* 2>/dev/null
71+ rm -rfv "/usr/share/help/"* 2>/dev/null
72+ rm -rfv "/usr/share/info/"* 2>/dev/null
73+ rm -rfv "/usr/share/doc/"* 2>/dev/null
74+ rm -rfv "/var/tmp/"* 2>/dev/null
75+ rm -rfv "/var/lib/pacman/sync/"* 2>/dev/null
76+ rm -rfv "/var/cache/pacman/pkg/"* 2>/dev/null
77+ find "/boot" -mindepth 1 -delete 2>/dev/null
78+ find "/dev" -mindepth 1 -delete 2>/dev/null
79+ find "/proc" -mindepth 1 -delete 2>/dev/null
80+ find "/run" -mindepth 1 -delete 2>/dev/null
81+ find "/sys" -mindepth 1 -delete 2>/dev/null
82+ find "/tmp" -mindepth 1 -delete 2>/dev/null
83+ find "/usr/include" -mindepth 1 -delete 2>/dev/null
84+ find "/usr/lib" -type f -name "*.a" -print -exec rm -rfv "{}" 2>/dev/null \; 2>/dev/null
85+ find "/usr/lib32" -type f -name "*.a" -print -exec rm -rfv "{}" 2>/dev/null \; 2>/dev/null
86+ find "/etc/pacman.d/gnupg" -type f -name "S.*" -print -exec rm -rfv "{}" 2>/dev/null \; 2>/dev/null
87+ find "/usr/share/locale" -mindepth 1 -maxdepth 1 ! -regex ".*/\(locale.alias\|en\|en_US\)$" -exec rm -rfv "{}" + 2>/dev/null
88+ find "/usr/share/doc" -mindepth 1 -delete 2>/dev/null
89+ find "/usr/share/gtk-doc" -mindepth 1 -delete 2>/dev/null
90+ find "/usr/share/help" -mindepth 1 -delete 2>/dev/null
91+ find "/usr/share/info" -mindepth 1 -delete 2>/dev/null
92+ find "/usr/share/man" -mindepth 1 -delete 2>/dev/null
93+ find "." -type d -name "__pycache__" -exec rm -rfv "{}" \; 2>/dev/null
94+ find "." -type f -name "*.pacnew" -exec rm -rfv "{}" \; 2>/dev/null
95+ find "." -type f -name "*.pacsave" -exec rm -rfv "{}" \; 2>/dev/null
96+ find "/var/log" -type f -name "*.log" -exec rm -rfv "{}" \; 2>/dev/null
97+ rm -rfv "/"{tmp,proc,sys,dev,run} 2>/dev/null
98+ mkdir -pv "/"{tmp,proc,sys,dev,run/media,mnt,media,home} 2>/dev/null
99+ rm -fv ""/etc/{host.conf,hosts,nsswitch.conf} 2>/dev/null
100+ touch ""/etc/{host.conf,hosts,nsswitch.conf} 2>/dev/null
101+ hostname 2>/dev/null; cat "/etc/os-release" 2>/dev/null'
102+ # #Export
103+ docker export " $( docker ps -aqf ' name=cachyos' ) " --output " rootfs.tar"
104+ if [[ -f " ./rootfs.tar" ]] && [[ $( stat -c%s " ./rootfs.tar" ) -gt 10000 ]]; then
105+ mkdir -pv " ./rootfs" && export ROOTFS_DIR=" $( realpath " ./rootfs" ) "
106+ rsync -achLv --mkpath " ./rootfs.tar" " /tmp/cachyos-base.tar"
107+ else
108+ echo " \n[-] FATAL: Failed to export ROOTFS\n"
109+ exit 1
110+ fi
111+ popd " $( mktemp -d) " > /dev/null 2>&1
112+ # -------------------------------------------------------#
113+
114+
115+ # -------------------------------------------------------#
116+ # #Push
117+ # ENV
118+ D_ID=" $( docker ps -qf ' name=cachyos-base' | tr -d ' [:space:]' ) "
119+ D_TAG=" v$( date +' %Y.%m.%d' | tr -d ' [:space:]' ) "
120+ export D_ID D_TAG
121+ # Tags
122+ docker commit " ${D_ID} " " pkgforge/cachyos-base:latest"
123+ docker commit " ${D_ID} " " ghcr.io/pkgforge/devscripts/cachyos-base:latest"
124+ docker commit " ${D_ID} " " pkgforge/cachyos-base:${DOCKER_TAG} "
125+ docker commit " ${D_ID} " " ghcr.io/pkgforge/devscripts/cachyos-base:${DOCKER_TAG} "
126+ docker commit " ${D_ID} " " pkgforge/cachyos-base:$( uname -m) "
127+ docker commit " ${D_ID} " " ghcr.io/pkgforge/devscripts/cachyos-base:$( uname -m) "
128+ # Push
129+ docker push " pkgforge/cachyos-base:latest"
130+ docker push " ghcr.io/pkgforge/devscripts/cachyos-base:latest"
131+ docker push " pkgforge/cachyos-base:${DOCKER_TAG} "
132+ docker push " ghcr.io/pkgforge/devscripts/cachyos-base:${DOCKER_TAG} "
133+ docker push " pkgforge/cachyos-base:$( uname -m) "
134+ docker push " ghcr.io/pkgforge/devscripts/cachyos-base:$( uname -m) "
135+ # -------------------------------------------------------#
0 commit comments