aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
Diffstat (limited to 'docker')
-rw-r--r--docker/arch-code-server/Dockerfile4
-rwxr-xr-xdocker/arch-code-server/archlinux-setup-user.bash7
-rwxr-xr-xdocker/arch-code-server/china-magic-for-pkgbuild.py21
3 files changed, 30 insertions, 2 deletions
diff --git a/docker/arch-code-server/Dockerfile b/docker/arch-code-server/Dockerfile
index 2c9bf7f..6471fac 100644
--- a/docker/arch-code-server/Dockerfile
+++ b/docker/arch-code-server/Dockerfile
@@ -7,9 +7,9 @@ ARG CRUPEST_GID=1000
ARG CRUPEST_PACKAGES=""
ARG CRUPEST_AUR_PACKAGES=""
ARG USE_CHINA_MIRROR="false"
-ARG CHINA_MIRROR_URL="https://mirrors.tuna.tsinghua.edu.cn/archlinux/\$repo/os/\$arch"
+ARG CHINA_MIRROR_URL="https://mirrors.ustc.edu.cn/archlinux/\$repo/os/\$arch"
-ADD ./archlinux-setup.bash ./archlinux-setup-user.bash ./restore-pacman-conf.py /tmp/
+ADD ./archlinux-setup.bash ./archlinux-setup-user.bash ./china-magic-for-pkgbuild.py ./restore-pacman-conf.py /tmp/
ENV CRUPEST_IN_DOCKER="true"
WORKDIR /tmp
diff --git a/docker/arch-code-server/archlinux-setup-user.bash b/docker/arch-code-server/archlinux-setup-user.bash
index 3a72bb3..6b30b28 100755
--- a/docker/arch-code-server/archlinux-setup-user.bash
+++ b/docker/arch-code-server/archlinux-setup-user.bash
@@ -19,6 +19,13 @@ for aur_package in code-server ${CRUPEST_AUR_PACKAGES} ; do
echo "Installing ${aur_package} from AUR..."
git clone "https://aur.archlinux.org/${aur_package}.git" --depth 1
pushd "${aur_package}"
+
+ # do some magic thing for China
+ if [ "${USE_CHINA_MIRROR}" = "true" ]; then
+ mv PKGBUILD PKGBUILD.old
+ /tmp/china-magic-for-pkgbuild.py < PKGBUILD.old > PKGBUILD
+ fi
+
makepkg -sr --noconfirm
makepkg --packagelist | sudo pacman -U --noconfirm -
popd
diff --git a/docker/arch-code-server/china-magic-for-pkgbuild.py b/docker/arch-code-server/china-magic-for-pkgbuild.py
new file mode 100755
index 0000000..43a4d89
--- /dev/null
+++ b/docker/arch-code-server/china-magic-for-pkgbuild.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+# In China? Good for you!
+
+import sys
+import re
+
+# read STDIN until EOF
+content = sys.stdin.read()
+
+url = re.search(r"url=(.+)", content).group(1)
+if url.startswith('"') and url.endswith('"'):
+ url = url[1:-1]
+
+if url.startswith("https://github.com"): # yah, it's github!
+ content = re.sub(r"\$\{\s*url\s*\}|\$url", url, content)
+ content = content.replace("https://raw.githubusercontent.com", "https://gh.api.99988866.xyz/https://raw.githubusercontent.com")
+ content = re.sub(r'https://github\.com/(.+)/(.+)/releases/download', lambda match: f'https://gh.api.99988866.xyz/{match.group(0)}', content)
+
+# now print the result
+print(content)