diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-02-13 11:14:10 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-02-20 23:07:54 +0800 |
commit | 5219414d4c75b6c1561d6f57d0814bfc865096a1 (patch) | |
tree | 5acf87e12e2a6b4d860b40e13a0aa0b604e737b6 /docker/debian-dev/bootstrap/setup-apt.bash | |
parent | c8be4e6d6e3b46c9c012fd10794fd8fe3f45dc3e (diff) | |
download | crupest-5219414d4c75b6c1561d6f57d0814bfc865096a1.tar.gz crupest-5219414d4c75b6c1561d6f57d0814bfc865096a1.tar.bz2 crupest-5219414d4c75b6c1561d6f57d0814bfc865096a1.zip |
feat(debian-dev): trim it.
Diffstat (limited to 'docker/debian-dev/bootstrap/setup-apt.bash')
-rwxr-xr-x | docker/debian-dev/bootstrap/setup-apt.bash | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/docker/debian-dev/bootstrap/setup-apt.bash b/docker/debian-dev/bootstrap/setup-apt.bash new file mode 100755 index 0000000..38cba05 --- /dev/null +++ b/docker/debian-dev/bootstrap/setup-apt.bash @@ -0,0 +1,41 @@ +#! /usr/bin/env bash +# shellcheck disable=1090,1091 + +set -e + +if [[ $EUID -ne 0 ]]; then + die "This script must be run as root." +fi + +script_dir=$(dirname "$0") + +old_one="/etc/apt/sources.list" +new_one="/etc/apt/sources.list.d/debian.sources" + +echo "Setup apt sources ..." + +echo "Backup old ones to .bak ..." +if [[ -f "$old_one" ]]; then + mv "$old_one" "$old_one.bak" +fi + +if [[ -f "$new_one" ]]; then + mv "$new_one" "$new_one.bak" +fi + +echo "Copy the new one ..." +cp "$script_dir/official.sources" "$new_one" + +if [[ -n "$CRUPEST_DEBIAN_DEV_IN_CHINA" ]]; then + echo "Replace with China mirror ..." + china_mirror="mirrors.ustc.edu.cn" + sed -i "s|deb.debian.org|${china_mirror}|" "$new_one" +fi + +echo "Try to use https ..." +apt-get update +apt-get install -y apt-transport-https ca-certificates + +sed -i 's|http://|https://|' "$new_one" + +echo "APT source setup done!" |