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/ubuntu.sh")
5+ # -------------------------------------------------------#
6+
7+ # -------------------------------------------------------#
8+ # # https://github.com/phusion/baseimage-docker
9+ # https://hub.docker.com/r/phusion/baseimage/tags
10+ set -x
11+ # -------------------------------------------------------#
12+
13+ # -------------------------------------------------------#
14+ # #Bootstrap
15+ pushd " $( mktemp -d) " > /dev/null 2>&1
16+ docker stop " ubuntu-base" 2> /dev/null ; docker rm " ubuntu-base" 2> /dev/null
17+ docker run --name " ubuntu-base" --privileged " phusion/baseimage:noble-1.0.0" sh -l -c '
18+ #Bootstrap
19+ #echo -e "nameserver 8.8.8.8\nnameserver 2620:0:ccc::2" | tee "/etc/resolv.conf"
20+ #echo -e "nameserver 1.1.1.1\nnameserver 2606:4700:4700::1111" | tee -a "/etc/resolv.conf"
21+ unlink "/var/lib/dbus/machine-id" 2>/dev/null
22+ unlink "/etc/machine-id" 2>/dev/null
23+ rm -rvf "/etc/machine-id"
24+ systemd-machine-id-setup --print 2>/dev/null | tee "/var/lib/dbus/machine-id"
25+ ln --symbolic --force --relative "/var/lib/dbus/machine-id" "/etc/machine-id"
26+ echo "LANG=en_US.UTF-8" | tee "/etc/locale.conf"
27+ echo "LANG=en_US.UTF-8" | tee -a "/etc/locale.conf"
28+ echo "LANGUAGE=en_US:en" | tee -a "/etc/locale.conf"
29+ echo "LC_ALL=en_US.UTF-8" | tee -a "/etc/locale.conf"
30+ echo "en_US.UTF-8 UTF-8" | tee -a "/etc/locale.gen"
31+ echo "LC_ALL=en_US.UTF-8" | tee -a "/etc/environment"
32+ chown -R _apt:root /var/cache/apt/archives/partial/
33+ dpkg-statoverride --remove /usr/bin/crontab
34+ ubuntu_FRONTEND="noninteractive" apt update -y
35+ ubuntu_FRONTEND="noninteractive" apt install bash binutils coreutils curl fakeroot git locales sudo wget -y --no-install-recommends --ignore-missing
36+ locale-gen "en_US.UTF-8"
37+ echo "debconf debconf/frontend select Noninteractive" | debconf-set-selections
38+ apt purge locales perl -y ; apt autoremove -y ; apt autoclean -y
39+ apt list --installed
40+ apt clean -y
41+ find "/boot" -mindepth 1 -delete 2>/dev/null
42+ find "/dev" -mindepth 1 -delete 2>/dev/null
43+ find "/proc" -mindepth 1 -delete 2>/dev/null
44+ find "/run" -mindepth 1 -delete 2>/dev/null
45+ find "/sys" -mindepth 1 -delete 2>/dev/null
46+ find "/tmp" -mindepth 1 -delete 2>/dev/null
47+ find "/usr/include" -mindepth 1 -delete 2>/dev/null
48+ find "/usr/lib" -type f -name "*.a" -print -exec rm -rfv "{}" 2>/dev/null \; 2>/dev/null
49+ find "/usr/lib32" -type f -name "*.a" -print -exec rm -rfv "{}" 2>/dev/null \; 2>/dev/null
50+ find "/usr/share/locale" -mindepth 1 -maxdepth 1 ! -regex ' \' ' .*/\(locale.alias\|en\|en_US\)$' \' ' -exec rm -rfv "{}" + 2>/dev/null
51+ find "/usr/share/doc" -mindepth 1 -delete 2>/dev/null
52+ find "/usr/share/gtk-doc" -mindepth 1 -delete 2>/dev/null
53+ find "/usr/share/help" -mindepth 1 -delete 2>/dev/null
54+ find "/usr/share/info" -mindepth 1 -delete 2>/dev/null
55+ find "/usr/share/man" -mindepth 1 -delete 2>/dev/null
56+ find "/" -type d -name "__pycache__" -exec rm -rfv "{}" \; 2>/dev/null
57+ find "/" -type f -name "*.pacnew" -exec rm -rfv "{}" \; 2>/dev/null
58+ find "/" -type f -name "*.pacsave" -exec rm -rfv "{}" \; 2>/dev/null
59+ find "/var/log" -type f -name "*.log" -exec rm -rfv "{}" \; 2>/dev/null
60+ rm -rfv "/var/lib/apt/lists/"*
61+ rm -rfv "/var/cache/apt/"*
62+ rm -rfv "/"{tmp,proc,sys,dev,run}
63+ mkdir -pv "/"{tmp,proc,sys,dev,run/media,mnt,media,home}
64+ rm -fv /etc/{host.conf,hosts,passwd,group,nsswitch.conf}
65+ touch /etc/{host.conf,hosts,passwd,group,nsswitch.conf}'
66+ # #Export
67+ docker export " $( docker ps -aqf ' name=ubuntu-base' ) " --output " rootfs.tar"
68+ if [[ -f " ./rootfs.tar" ]] && [[ $( stat -c%s " ./rootfs.tar" ) -gt 10000 ]]; then
69+ rsync -achLv --mkpath " ./rootfs.tar" " /tmp/rootfs.tar"
70+ else
71+ echo " \n[-] FATAL: Failed to export ROOTFS\n"
72+ exit 1
73+ fi
74+ popd " $( mktemp -d) " > /dev/null 2>&1
75+ # -------------------------------------------------------#
76+
77+
78+ # -------------------------------------------------------#
79+ # #Push
80+ # ENV
81+ D_ID=" $( docker ps -aqf ' name=ubuntu-base' | tr -d ' [:space:]' ) "
82+ D_TAG=" v$( date +' %Y.%m.%d' | tr -d ' [:space:]' ) "
83+ export D_ID D_TAG
84+ # Tags
85+ docker commit " ${D_ID} " " pkgforge/ubuntu-base:latest"
86+ docker commit " ${D_ID} " " ghcr.io/pkgforge/devscripts/ubuntu-base:latest"
87+ docker commit " ${D_ID} " " pkgforge/ubuntu-base:${D_TAG} "
88+ docker commit " ${D_ID} " " ghcr.io/pkgforge/devscripts/ubuntu-base:${D_TAG} "
89+ docker commit " ${D_ID} " " pkgforge/ubuntu-base:$( uname -m) "
90+ docker commit " ${D_ID} " " ghcr.io/pkgforge/devscripts/ubuntu-base:$( uname -m) "
91+ # Push
92+ docker push " pkgforge/ubuntu-base:latest"
93+ docker push " ghcr.io/pkgforge/devscripts/ubuntu-base:latest"
94+ docker push " pkgforge/ubuntu-base:${D_TAG} "
95+ docker push " ghcr.io/pkgforge/devscripts/ubuntu-base:${D_TAG} "
96+ docker push " pkgforge/ubuntu-base:$( uname -m) "
97+ docker push " ghcr.io/pkgforge/devscripts/ubuntu-base:$( uname -m) "
98+ # -------------------------------------------------------#
0 commit comments