apt-get 抑制关于缺少回购的警告
apt-get suppress warning about missing repo
有开发和生产环境。每一个都有一个 Debian 存储库。例如 http://dev
和 http://prod
.
当机器被(物理地)转移到生产环境时,如何避免改变/etc/apt/sources.list
?
一种解决方案是同时编写:
deb http://dev/debian main
deb http://prod/debian main
在开发环境中出现无法访问http://prod/
的警告是可以的。但是如何去掉生产网络中的警告呢?
有一个简洁的镜像功能。在 /etc/apt/sources.list
:
deb mirror://localhost/mirrors.txt jessie main
与 mirrors.txt
托管在同一台机器上:
http://dev/debian
http://prod/debian
因此,它会在每个配置中找到一些存储库。
但无论如何它都会抱怨。我将使用脚本:
#!/bin/bash
# Generates a list of available repositories.
set -e
release_codename="$(lsb_release -cs)"
all_mirrors_list=/etc/locate-my-repositories/all-my-mirrors.list
active_list=/var/lib/locate-my-repositories/my.list
mirrors="$(cat "$all_mirrors_list")"
active=$(for r in $mirrors; do
if curl -s "$r"/dists/"$release_codename"/main/binary-"$(dpkg --print-architecture)"/Release | grep -q '^Component:'; then
printf '%s\n' "$r"
fi
done)
# Formats a valid /etc/apr/sources.list: makes "deb http://url jessie main"
# entry from "http://url".
function to_sources_list() {
sed "s/\(.*\)/deb \1 $release_codename main/"
}
if [ -z "$active" ]; then
# Nothing is found. Give everything to apt-get, maybe it will be more lucky.
cat "$all_mirrors_list"
else
printf '%s\n' "$active"
fi | to_sources_list > "$active_list"
有开发和生产环境。每一个都有一个 Debian 存储库。例如 http://dev
和 http://prod
.
当机器被(物理地)转移到生产环境时,如何避免改变/etc/apt/sources.list
?
一种解决方案是同时编写:
deb http://dev/debian main
deb http://prod/debian main
在开发环境中出现无法访问http://prod/
的警告是可以的。但是如何去掉生产网络中的警告呢?
有一个简洁的镜像功能。在 /etc/apt/sources.list
:
deb mirror://localhost/mirrors.txt jessie main
与 mirrors.txt
托管在同一台机器上:
http://dev/debian
http://prod/debian
因此,它会在每个配置中找到一些存储库。
但无论如何它都会抱怨。我将使用脚本:
#!/bin/bash
# Generates a list of available repositories.
set -e
release_codename="$(lsb_release -cs)"
all_mirrors_list=/etc/locate-my-repositories/all-my-mirrors.list
active_list=/var/lib/locate-my-repositories/my.list
mirrors="$(cat "$all_mirrors_list")"
active=$(for r in $mirrors; do
if curl -s "$r"/dists/"$release_codename"/main/binary-"$(dpkg --print-architecture)"/Release | grep -q '^Component:'; then
printf '%s\n' "$r"
fi
done)
# Formats a valid /etc/apr/sources.list: makes "deb http://url jessie main"
# entry from "http://url".
function to_sources_list() {
sed "s/\(.*\)/deb \1 $release_codename main/"
}
if [ -z "$active" ]; then
# Nothing is found. Give everything to apt-get, maybe it will be more lucky.
cat "$all_mirrors_list"
else
printf '%s\n' "$active"
fi | to_sources_list > "$active_list"