修改 ubuntu debian 源
This commit is contained in:
parent
28a83e30f5
commit
5c7ccf4f4f
31
README.md
31
README.md
@ -17,17 +17,32 @@ pip config set global.index-url https://mirrors.martin98.com/repository/pypi-gro
|
||||
npm config set registry https://mirrors.martin98.com/repository/npm-group/
|
||||
```
|
||||
|
||||
##### docker 容器中
|
||||
#### dockerfile
|
||||
##### DEB822 格式
|
||||
```bash
|
||||
RUN --mount=type=cache,target=/var/cache/apt \
|
||||
--mount=type=cache,target=/var/lib/apt \
|
||||
sed -i '6,$d' /etc/apt/sources.list.d/dhttps://mirrors.mebian.sources && \
|
||||
sed -i 's|http://deb.debian.org/debian|artin98.com/repository/debian-tsinghua/|g' /etc/apt/sources.list.d/debian.sources && \
|
||||
apt update && \
|
||||
apt install -y --no-install-recommends \
|
||||
gcc \
|
||||
g++ \
|
||||
python3-dev
|
||||
APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false" \
|
||||
type=$(cat /etc/*release | grep ^ID= | cut -d= -f2) && \
|
||||
sed -i '6,$d' /etc/apt/sources.list.d/${type}.sources && \
|
||||
sed -i "s|http://deb.debian.org/debian|https://mirrors.martin98.com/repository/${type}-tsinghua/|g" /etc/apt/sources.list.d/${type}.sources && \
|
||||
apt update $APT_OPTIONS && apt install $APT_OPTIONS -y ca-certificates curl && update-ca-certificates
|
||||
```
|
||||
##### 传统格式
|
||||
```bash
|
||||
RUN --mount=type=cache,target=/var/cache/apt \
|
||||
--mount=type=cache,target=/var/lib/apt \
|
||||
APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false" \
|
||||
type=$(cat /etc/*release | grep ^ID= | cut -d= -f2) && \
|
||||
release=$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2) && \
|
||||
components=$([ "${type}" = "debian" ] && echo "main contrib non-free non-free-firmware" || ([ "${type}" = "ubuntu" ] && echo "main restricted universe multiverse")) && \
|
||||
|
||||
echo "deb https://mirrors.martin98.com/repository/${type}-tsinghua-${release}${suite#noble}/ ${suite} ${components}"
|
||||
|
||||
echo "deb https://mirrors.martin98.com/repository/${type}-tsinghua-${release}/ ${suite} ${components}"
|
||||
sed -i '6,$d' /etc/apt/sources.list.d/${type}.sources && \
|
||||
sed -i "s|http://deb.debian.org/debian|https://mirrors.martin98.com/repository/${type}-tsinghua/|g" /etc/apt/sources.list.d/${type}.sources && \
|
||||
apt update $APT_OPTIONS && apt install $APT_OPTIONS -y ca-certificates && update-ca-certificates
|
||||
```
|
||||
|
||||
#### 进入容器
|
||||
|
40
init-apt.sh
40
init-apt.sh
@ -1,22 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 配置 ubuntu 源
|
||||
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
|
||||
cat > /etc/apt/sources.list.d/ubuntu.sources <<EOF
|
||||
Types: deb
|
||||
URIs: https://mirrors.martin98.com/repository/ubuntu-tsinghua/
|
||||
Suites: noble noble-updates noble-backports
|
||||
Components: main restricted universe multiverse
|
||||
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
|
||||
type=$(cat /etc/*release | grep ^ID= | cut -d= -f2)
|
||||
release=$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2)
|
||||
components=$([ "${type}" = "debian" ] && echo "main contrib non-free non-free-firmware" || ([ "${type}" = "ubuntu" ] && echo "main restricted universe multiverse"))
|
||||
|
||||
# DEB822 格式
|
||||
# docker.martin98.com/library/ubuntu:latest
|
||||
# docker.martin98.com/library/debian:latest
|
||||
if [ -f /etc/apt/sources.list.d/${type}.sources ]; then
|
||||
cat > /etc/apt/sources.list.d/${type}.sources <<EOF
|
||||
$(for suite in ${release} ${release}-updates ${release}-backports; do
|
||||
echo "Types: deb"
|
||||
echo "URIs: https://mirrors.martin98.com/repository/${type}-tsinghua-${suite}/"
|
||||
echo "Suites: $suite"
|
||||
echo "Components: ${components}"
|
||||
echo "Signed-By: /usr/share/keyrings/${type}-archive-keyring.gpg"
|
||||
echo
|
||||
done)
|
||||
EOF
|
||||
# 配置 debian 源
|
||||
elif [ -f /etc/apt/sources.list.d/debian.sources ]; then
|
||||
cat > /etc/apt/sources.list.d/debian.sources <<EOF
|
||||
Types: deb
|
||||
URIs: https://mirrors.martin98.com/repository/debian-tsinghua/
|
||||
Suites: bookworm bookworm-updates bookworm-backports
|
||||
Components: main contrib non-free non-free-firmware
|
||||
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
||||
# 传统格式
|
||||
# docker.martin98.com/library/ubuntu:22.04
|
||||
elif [ -f /etc/apt/sources.list ]; then
|
||||
cat > /etc/apt/sources.list <<EOF
|
||||
$(for suite in ${release} ${release}-updates ${release}-backports; do
|
||||
echo "deb https://mirrors.martin98.com/repository/${type}-tsinghua-${suite}/ ${suite} ${components}"
|
||||
done)
|
||||
EOF
|
||||
else
|
||||
echo "没有找到合适的源"
|
||||
|
Loading…
x
Reference in New Issue
Block a user