aboutsummaryrefslogtreecommitdiff
path: root/store/debian-dev/setup/apt.bash
diff options
context:
space:
mode:
authorYuqian Yang <crupest@outlook.com>2025-06-29 15:07:57 +0800
committerYuqian Yang <crupest@outlook.com>2025-06-29 15:08:47 +0800
commit66a0836ba12ed12c29353ae75134654c6f2013cc (patch)
treeaeca0ebfca99f50f305f8948f512abf1760f8540 /store/debian-dev/setup/apt.bash
parent43d6c1f08a38ae4e8584e3915f0cbdbc3cfd05e9 (diff)
downloadcrupest-66a0836ba12ed12c29353ae75134654c6f2013cc.tar.gz
crupest-66a0836ba12ed12c29353ae75134654c6f2013cc.tar.bz2
crupest-66a0836ba12ed12c29353ae75134654c6f2013cc.zip
debian-dev: refactor all.
Diffstat (limited to 'store/debian-dev/setup/apt.bash')
-rwxr-xr-xstore/debian-dev/setup/apt.bash33
1 files changed, 33 insertions, 0 deletions
diff --git a/store/debian-dev/setup/apt.bash b/store/debian-dev/setup/apt.bash
new file mode 100755
index 0000000..e841351
--- /dev/null
+++ b/store/debian-dev/setup/apt.bash
@@ -0,0 +1,33 @@
+#! /usr/bin/env bash
+
+set -e -o pipefail
+
+china_mirror="mirrors.ustc.edu.cn"
+try_files=("/etc/apt/sources.list" "/etc/apt/sources.list.d/debian.sources")
+files=()
+
+for try_file in "${try_files[@]}"; do
+ if [[ -f "$try_file" ]]; then
+ files+=("$try_file")
+ fi
+done
+
+for file in "${files[@]}"; do
+ echo "copy $file to $file.bak"
+ cp "$file" "$file.bak"
+done
+
+if [[ -n "$CRUPEST_DEBIAN_DEV_CHINA" ]]; then
+ echo "use China mirrors"
+ for file in "${files[@]}"; do
+ sed -i "s|deb.debian.org|${china_mirror}|g" "$file"
+ done
+fi
+
+echo "use https"
+apt-get update
+apt-get install -y apt-transport-https ca-certificates
+
+for file in "${files[@]}"; do
+ sed -i 's|http://|https://|g' "$file"
+done