-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharchlinux-builder.dockerfile
More file actions
218 lines (212 loc) · 10.9 KB
/
archlinux-builder.dockerfile
File metadata and controls
218 lines (212 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# syntax=docker/dockerfile:1
#------------------------------------------------------------------------------------#
#https://hub.docker.com/r/pkgforge/archlinux-builder
FROM pkgforge/archlinux:latest
#------------------------------------------------------------------------------------#
##Base Deps
RUN <<EOS
#Base
set +e
pacman -Syu --noconfirm
packages="base-devel bash bison ca-certificates coreutils curl dos2unix findutils gettext git gnupg gperf imagemagick jq less lzip lzlib moreutils micro nano ncdu pacutils p7zip rsync sudo texinfo tmux unzip util-linux wget xz zip"
for pkg in $packages; do pacman "$pkg" --sync --noconfirm ; done
#RE
pacman -Syu --noconfirm
pacman base-devel bash bison ca-certificates coreutils curl dos2unix findutils gettext git gnupg gperf imagemagick jq less lzip lzlib moreutils micro nano ncdu pacutils p7zip rsync sudo texinfo tmux unzip util-linux wget xz zip --sync --needed --noconfirm || true
#NetTools
packages="inetutils iproute2 iputils net-tools openbsd-netcat"
for pkg in $packages; do pacman "$pkg" --sync --noconfirm ; done
setcap 'cap_net_raw+ep' "$(which ping)"
#Python & Deps
packages="patchelf python python-devtools python-distro python-lxml python-netifaces python-pypatchelf python-pip python-pipx python-pkgconfig python-xxhash scons sysfsutils virt-what"
for pkg in $packages; do pacman "$pkg" --sync --needed --noconfirm ; done
#Test
python --version 2>/dev/null ; python3 --version 2>/dev/null || true
pip --version 2>/dev/null ; pip3 --version 2>/dev/null || true
pipx --version 2>/dev/null || true
EOS
#------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------#
##OS Settings
RUN <<EOS
#NameServers
echo "nameserver 1.0.0.1" >> "/etc/resolv.conf"
echo "nameserver 1.1.1.1" >> "/etc/resolv.conf"
echo "nameserver 8.8.4.4" >> "/etc/resolv.conf"
echo "nameserver 8.8.8.8" >> "/etc/resolv.conf"
#Key-Verification
#sed 's/^.*SigLevel\s*=.*$/SigLevel = Never/' -i "/etc/pacman.conf"
#Download user
sed 's/DownloadUser/#DownloadUser/g' -i "/etc/pacman.conf"
#Update
pacman -Syu --noconfirm || true
EOS
#------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------#
##Create User + Setup Perms
RUN <<EOS
#Add runner
useradd -m -s "/bin/bash" "runner"
#Set password
echo "runner:runneradmin" | chpasswd
#Add runner to sudo
usermod -aG "wheel" "runner"
usermod -aG "wheel" "root"
#Passwordless sudo for runner
echo "%wheel ALL=(ALL) NOPASSWD: ALL" | tee -a "/etc/sudoers"
compgen -u
#Fix perms
chmod 0440 "/etc/sudoers"
visudo -c || true
EOS
##Change Default shell for runner to bash
RUN <<EOS
#Check current shell
grep runner "/etc/passwd"
#Change to bash
usermod --shell "/bin/bash" "runner" 2>/dev/null
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/.bashrc" -o "/etc/bash.bashrc"
dos2unix --quiet "/etc/bash.bashrc" 2>/dev/null
ln --symbolic --force "/etc/bash.bashrc" "/home/runner/.bashrc" 2>/dev/null
ln --symbolic --force "/etc/bash.bashrc" "/root/.bashrc" 2>/dev/null
ln --symbolic --force "/etc/bash.bashrc" "/etc/bash/bashrc" 2>/dev/null
#Recheck
grep runner "/etc/passwd"
EOS
#------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------#
##Addons
RUN <<EOS
#Addons
#https://github.com/pkgforge/devscripts/blob/main/Linux/install_bins_curl.sh
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_bins_curl.sh" -o "./tools.sh"
dos2unix --quiet "./tools.sh" && chmod +x "./tools.sh"
bash "./tools.sh" 2>/dev/null || true ; rm -rf "./tools.sh"
##Appimage tools
curl -qfsSL "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$(uname -m).AppImage" -o "/usr/local/bin/appimagetool" && chmod +x "/usr/local/bin/appimagetool"
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/mkappimage" -o "/usr/local/bin/mkappimage" && chmod +x "/usr/local/bin/mkappimage"
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/mksquashfs" -o "/usr/local/bin/mksquashfs" && chmod +x "/usr/local/bin/mksquashfs"
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/sqfscat" -o "/usr/local/bin/sqfscat" && chmod +x "/usr/local/bin/sqfscat"
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/sqfstar" -o "/usr/local/bin/sqfstar" && chmod +x "/usr/local/bin/sqfstar"
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/unsquashfs" -o "/usr/local/bin/unsquashfs" && chmod +x "/usr/local/bin/unsquashfs"
true
EOS
#------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------#
##Build Tools
RUN <<EOS
#----------------------#
##Main
set +e
pacman -Syu --noconfirm || true
packages="aria2 autoconf autoconf-archive automake bazel bc binutils b3sum brotli busybox ccache clang cmake coreutils cython diffutils dos2unix findutils fontconfig gawk gcc gettext kernel-headers-musl jq libpcap libtool meson musl nasm polkit pkgconf rsync spirv-headers spirv-tools sqlite texinfo texi2html util-linux util-linux-libs wget libxslt xxhash yasm"
for pkg in $packages; do pacman "$pkg" --sync --needed --noconfirm ; done
#Re
pacman -Syu --noconfirm || true
pacman aria2 autoconf autoconf-archive automake bazel bc binutils b3sum brotli busybox ccache clang cmake coreutils cython diffutils dos2unix findutils fontconfig gawk gcc gettext kernel-headers-musl jq libpcap libtool meson musl nasm polkit pkgconf rsync spirv-headers spirv-tools sqlite texinfo texi2html util-linux util-linux-libs wget libxslt xxhash yasm --sync --needed --noconfirm || true
#----------------------#
##Dockerc
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/dockerc" -o "/usr/bin/dockerc" && chmod +x "/usr/bin/dockerc"
#----------------------#
##Linux Headers
if [ "$(uname -m)" == "aarch64" ]; then
pacman -Syu --noconfirm && pacman linux-aarch64-headers --sync --needed --noconfirm || true
elif [ "$(uname -m)" == "x86_64" ]; then
pacman -Syu --noconfirm && pacman linux-headers --sync --needed --noconfirm || true
else
echo "[+]"
fi
#----------------------#
##Install Meson & Ninja
#sudo rm "/usr/bin/meson" "/usr/bin/ninja" 2>/dev/null
pip install meson ninja --break-system-packages --upgrade --force-reinstall 2>/dev/null || true
#----------------------#
##musl
export CWD="$(realpath .)" ; cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath "."
git clone --filter "blob:none" --depth="1" "https://git.musl-libc.org/git/musl" && cd "./musl"
unset AR CC CFLAGS CXX CPPFLAGS CXXFLAGS DLLTOOL HOST_CC HOST_CXX LDFLAGS OBJCOPY RANLIB
make dest clean 2>/dev/null ; make clean 2>/dev/null
bash "./configure" || true
make --jobs="$(($(nproc)+1))" --keep-going install || true
rm -rf "$(realpath .)" ; cd "${CWD}"
ldconfig && ldconfig -p || true
#----------------------#
##staticx: https://github.com/JonathonReinhart/staticx/blob/main/.github/workflows/build-test.yml
export CWD="$(realpath .)" ; cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath .
#Switch to default: https://github.com/JonathonReinhart/staticx/pull/284
git clone --filter "blob:none" "https://github.com/JonathonReinhart/staticx" --branch "add-type-checking" && cd "./staticx"
#https://github.com/JonathonReinhart/staticx/blob/main/build.sh
pip install -r "./requirements.txt" --break-system-packages --upgrade --force || true
pacman -Syu --noconfirm
export BOOTLOADER_CC="/usr/local/musl/bin/musl-gcc"
rm -rf "./build" "./dist" "./scons_build" "./staticx/assets"
python "./setup.py" sdist bdist_wheel
find "dist/" -name "*.whl" | xargs -I {} sh -c 'newname=$(echo {} | sed "s/none-[^/]*\.whl$/none-any.whl/"); mv "{}" "$newname"'
find "dist/" -name "*.whl" | xargs pip install --break-system-packages --upgrade --force || true
staticx --version || pip install staticx --break-system-packages --force-reinstall --upgrade ; unset BOOTLOADER_CC
rm -rf "$(realpath .)" ; cd "${CWD}"
#----------------------#
##pyinstaller
pip install "git+https://github.com/pyinstaller/pyinstaller" --break-system-packages --force-reinstall --upgrade ; pyinstaller --version
#----------------------#
##golang
#Installed later to ensure correct ENV
#pacman -Syu --noconfirm && pacman go --sync --needed --noconfirm ; go version
sudo -u "runner" bash -c \
'
sudo pacman -R go --noconfirm 2>/dev/null
rm -rf "/usr/lib/go" 2>/dev/null
pushd "$(mktemp -d)" >/dev/null
echo "yes" | bash <(curl -qfsSL "https://git.io/go-installer")
popd >/dev/null
' || true
echo 'export GOROOT="/home/runner/.go"' >> "/etc/bash.bashrc"
echo 'export GOPATH="/home/runner/go"' >> "/etc/bash.bashrc"
echo 'export PATH="${PATH}:${GOROOT}/bin:${GOPATH}/bin"' >> "/etc/bash.bashrc"
#----------------------#
##patchelf
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/patchelf" -o "/usr/bin/patchelf" && chmod +x "/usr/bin/patchelf"
#----------------------#
##Rust
pacman -Syu --noconfirm && pacman rust --sync --needed --noconfirm ; cargo --version ; rustc --version || true
#----------------------#
EOS
#------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------#
##AUR Helpers
RUN <<EOS
#----------------------#
#Paru:https://github.com/Morganamilo/paru
sudo -u "runner" bash -c \
'
export CWD="$(realpath .)" ; cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath "."
git clone --filter "blob:none" --depth="1" "https://aur.archlinux.org/paru-bin.git" && cd "./paru-bin"
makepkg --install --syncdeps --cleanbuild --clean --force --noconfirm ; paru --version
rm -rf "$(realpath .)" ; cd "${CWD}"
' || true
#----------------------#
#Yay:https://github.com/Jguer/yay
sudo -u "runner" bash -c \
'
export CWD="$(realpath .)" ; cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath "."
git clone --filter "blob:none" --depth="1" "https://aur.archlinux.org/yay.git" && cd "./yay"
makepkg --install --syncdeps --cleanbuild --clean --force --noconfirm ; yay --version
rm -rf "$(realpath .)" ; cd "${CWD}"
' || true
EOS
#------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------#
#Start
RUN <<EOS
#Locale
echo "LC_ALL=en_US.UTF-8" | tee -a "/etc/environment"
echo "en_US.UTF-8 UTF-8" | tee -a "/etc/locale.gen"
echo "LANG=en_US.UTF-8" | tee -a "/etc/locale.conf"
locale-gen "en_US.UTF-8"
EOS
ENV GIT_ASKPASS="/bin/echo"
ENV GIT_TERMINAL_PROMPT="0"
ENV LANG="en_US.UTF-8"
ENV LANGUAGE="en_US:en"
ENV LC_ALL="en_US.UTF-8"
#------------------------------------------------------------------------------------#