diff options
author | Loïc Minier <lool@dooz.org> | 2010-01-30 14:02:08 +0100 |
---|---|---|
committer | Loïc Minier <lool@dooz.org> | 2010-01-30 14:02:08 +0100 |
commit | e2af36542708e5586083c7d43d08091fff814c0a (patch) | |
tree | d2ad377e85748e4f7cf7e622e12cd2baa545dbbc | |
parent | 3483d38fb43761ac8ead2c5a5caa1770249fe035 (diff) | |
download | pbuilder-e2af36542708e5586083c7d43d08091fff814c0a.tar pbuilder-e2af36542708e5586083c7d43d08091fff814c0a.tar.gz |
Add mirror-map support
-rwxr-xr-x | pbuilder-apt-config | 42 | ||||
-rwxr-xr-x | test_pbuilder-apt-config | 52 |
2 files changed, 72 insertions, 22 deletions
diff --git a/pbuilder-apt-config b/pbuilder-apt-config index bc21137..bbfe3d9 100755 --- a/pbuilder-apt-config +++ b/pbuilder-apt-config @@ -5,9 +5,6 @@ set -e self="$(basename "$0")" -# TODO -# - support setting --mirror-map (for --profile) - log() { echo "$@" >&2 } @@ -19,6 +16,7 @@ usage() { log log "Common options:" log " --with-sources, --with-sources=[yes|no|disabled]" + log " --mirror-map=<mirror-map>" log " --arch=<arch>" log " --components=<comp1>,<comp2>" } @@ -59,6 +57,25 @@ guess_dist_arch_archive() { } get_archive_url() { + local mirror_map="$1" + local archive="$2" + local url + + if [ -z "$archive" ]; then + die "Need an archive in get_archive_url()" + fi + + if [ -n "$mirror_map" ]; then + url="$(sed -n "s/^[[:space:]]*//; s/[[:space:]]*\$//; /^#/ d; /^\$/ d; s#^$archive\\([[:space:]]\+\\|\$\\)##p" "$mirror_map")" + if [ -n "$url" ]; then + echo "$url" + return + fi + fi + builtin_mirror_map "$archive" +} + +builtin_mirror_map() { local archive="$1" local people_ppa @@ -166,7 +183,7 @@ set_debootstrap_suite() { esac } -getopt_output="`getopt -o "" -l help,with-sources::,arch:,components:,archive:,mirror:,suite:,pockets:,profile: -n "$self" -s sh -- "$@"`" +getopt_output="`getopt -o "" -l help,with-sources::,arch:,components:,archive:,mirror:,mirror-map:,suite:,pockets:,profile: -n "$self" -s sh -- "$@"`" eval set -- "$getopt_output" @@ -175,6 +192,7 @@ arch="`dpkg --print-architecture`" components="main" archive="" mirror="" +mirror_map="" suite="" pockets="" archive="" @@ -216,6 +234,10 @@ while :; do mirror="$2" shift 2 ;; + --mirror-map) + mirror_map="$2" + shift 2 + ;; --suite) if [ -z "$2" ]; then die "Need a suite for --suite" @@ -261,7 +283,7 @@ if [ -n "$profile" ]; then base_dist="${profile%%/*}" base_dist="${base_dist%%-*}" base_archive="`guess_dist_arch_archive "$base_dist" "$arch"`" - base_mirror="`get_archive_url "$base_archive"`" + base_mirror="`get_archive_url "$mirror_map" "$base_archive"`" case "$base_archive" in debian|debian-archive) case "$profile" in @@ -272,7 +294,7 @@ if [ -n "$profile" ]; then ;; *-proposed-updates/volatile) archive="debian-volatile" - mirror="`get_archive_url "$archive"`" + mirror="`get_archive_url "$mirror_map" "$archive"`" volatile_dist="$base_dist/volatile" add_output_sources "$with_sources" "$base_mirror" "$base_dist" "$components" add_output_sources "$with_sources" "$mirror" "$volatile_dist" "$components" @@ -283,7 +305,7 @@ if [ -n "$profile" ]; then die "Unknown Debian Volatile based profile=$profile" fi archive="debian-volatile" - mirror="`get_archive_url "$archive"`" + mirror="`get_archive_url "$mirror_map" "$archive"`" volatile_dist=${profile%-sloppy} add_output_sources "$with_sources" "$base_mirror" "$base_dist" "$components" add_output_sources "$with_sources" "$mirror" "$volatile_dist" "$components" @@ -296,7 +318,7 @@ if [ -n "$profile" ]; then die "Unknown Backports.org based profile=$profile" fi archive="backports.org" - mirror="`get_archive_url "$archive"`" + mirror="`get_archive_url "$mirror_map" "$archive"`" add_output_sources "$with_sources" "$base_mirror" "$base_dist" "$components" add_output_sources "$with_sources" "$mirror" "$profile" "$components" ;; @@ -305,7 +327,7 @@ if [ -n "$profile" ]; then die "Unknown Debian Security based profile=$profile" fi archive="debian-security" - mirror="`get_archive_url "$archive"`" + mirror="`get_archive_url "$mirror_map" "$archive"`" add_output_sources "$with_sources" "$base_mirror" "$base_dist" "$components" add_output_sources "$with_sources" "$mirror" "$profile" "$components" ;; @@ -366,7 +388,7 @@ if [ -n "$suite" ]; then if [ -z "$archive" ]; then archive="`guess_dist_arch_archive "$suite" "$arch"`" fi - mirror="`get_archive_url "$archive"`" + mirror="`get_archive_url "$mirror_map" "$archive"`" fi add_output_sources "$with_sources" "$mirror" "$suite" "$components" for pocket in $pockets; do diff --git a/test_pbuilder-apt-config b/test_pbuilder-apt-config index 17ccf79..07de2c7 100755 --- a/test_pbuilder-apt-config +++ b/test_pbuilder-apt-config @@ -2,18 +2,42 @@ set -e +self="$(basename "$0")" + . ./testlib.sh +mirror_map="" + +cleanup() { + if [ -n "$mirror_map" ]; then + rm -f "$mirror_map" + fi +} + +mirror_map="$(mktemp -t "$self.XXXXXXXXXX")" +cat >"$mirror_map" <<EOF +archive archive-mirror +ubuntu ubuntu-mirror +ubuntu-ports ubuntu-ports-mirror +nomirror + +ppa:people ppa-people-ppa +ppa:people/otherppa ppa-people-otherppa + +# no mirror +debian-archive +EOF + run_suite_mode() { - ./pbuilder-apt-config --with-sources=no --mirror mirror --suite suite --components component apt-sources "$@" + ./pbuilder-apt-config --mirror-map="$mirror_map" --with-sources=no --mirror mirror --suite suite --components component apt-sources "$@" } debootstrap_suite() { - ./pbuilder-apt-config --with-sources=no --mirror mirror --components component debootstrap-suite "$@" + ./pbuilder-apt-config --mirror-map="$mirror_map" --with-sources=no --mirror mirror --components component debootstrap-suite "$@" } debootstrap_mirror() { - ./pbuilder-apt-config --with-sources=no --components component debootstrap-mirror "$@" + ./pbuilder-apt-config --mirror-map="$mirror_map" --with-sources=no --components component debootstrap-mirror "$@" } test_components() { @@ -56,8 +80,12 @@ test_options() { expect_output "deb mirror suite component" run_suite_mode -expect_output "deb http://archive.ubuntu.com/ubuntu/ lucid component" run_suite_mode --mirror "" --suite lucid --arch i386 -expect_output "deb http://ports.ubuntu.com/ubuntu-ports/ lucid component" run_suite_mode --mirror "" --suite lucid --arch armel +expect_output "deb archive-mirror suite component" run_suite_mode --mirror "" --archive archive +expect_fail run_suite_mode --mirror "" --archive nomirror +expect_output "deb http://archive.debian.org/debian/ bo component" run_suite_mode --mirror "" --suite bo + +expect_output "deb ubuntu-mirror lucid component" run_suite_mode --mirror "" --suite lucid --arch i386 +expect_output "deb ubuntu-ports-mirror lucid component" run_suite_mode --mirror "" --suite lucid --arch armel expect_output "deb mirror suite comp1 deb mirror suite comp1 comp2 comp3 @@ -121,14 +149,14 @@ expect_output "deb mirror suite component #deb-src mirror suite component" run_suite_mode --with-sources=disabled expect_output "deb mirror suite component" run_suite_mode --with-sources=no -expect_output "deb http://archive.ubuntu.com/ubuntu/ suite component" run_suite_mode --mirror "" --archive ubuntu -expect_output "deb http://ports.ubuntu.com/ubuntu-ports/ suite component" run_suite_mode --arch armel --mirror "" --archive ubuntu-ports -expect_fail run_suite_mode --arch armel --mirror "" --archive archive +expect_output "deb ubuntu-mirror suite component" run_suite_mode --mirror "" --archive ubuntu +expect_output "deb ubuntu-ports-mirror suite component" run_suite_mode --arch armel --mirror "" --archive ubuntu-ports +expect_fail run_suite_mode --arch armel --mirror "" --archive otherarchive expect_success run_suite_mode --mirror "" --suite lucid expect_fail run_suite_mode --mirror "" --suite suite expect_success run_suite_mode --mirror "" --suite suite --archive ubuntu -expect_output "deb http://ppa.launchpad.net/people/ppa/ubuntu/ suite component" run_suite_mode --mirror "" --suite suite --archive ppa:people -expect_output "deb http://ppa.launchpad.net/people/otherppa/ubuntu/ suite component" run_suite_mode --mirror "" --suite suite --archive ppa:people/otherppa +expect_output "deb ppa-people-ppa suite component" run_suite_mode --mirror "" --suite suite --archive ppa:people +expect_output "deb ppa-people-otherppa suite component" run_suite_mode --mirror "" --suite suite --archive ppa:people/otherppa expect_output "suite" debootstrap_suite --suite suite expect_output "sid" debootstrap_suite --suite sid @@ -137,7 +165,7 @@ expect_output "mirror" debootstrap_mirror --suite suite --mirror mirror expect_output "sid" debootstrap_suite --profile sid expect_output "sid" debootstrap_suite --profile unstable -expect_output "http://archive.ubuntu.com/ubuntu/" debootstrap_mirror --profile lucid -expect_output "http://ports.ubuntu.com/ubuntu-ports/" debootstrap_mirror --profile lucid --arch armel +expect_output "ubuntu-mirror" debootstrap_mirror --profile lucid +expect_output "ubuntu-ports-mirror" debootstrap_mirror --profile lucid --arch armel testlib_summary |