mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
Configurable mirror support for pull-debian-source
This commit is contained in:
parent
c28ddf5698
commit
d5c7de285e
1
debian/copyright
vendored
1
debian/copyright
vendored
@ -166,6 +166,7 @@ Copyright: 2007, Albin Tonnerre (Lutin) <lut1n.tne@gmail.com>
|
|||||||
2009-2010, Michael Bienia <geser@ubuntu.com>
|
2009-2010, Michael Bienia <geser@ubuntu.com>
|
||||||
2009, Nathan Handler <nhandler@ubuntu.com>
|
2009, Nathan Handler <nhandler@ubuntu.com>
|
||||||
2007-2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
2007-2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||||
|
2010, Stefano Rivera <stefanor@ubuntu.com>
|
||||||
License: GPL-3+
|
License: GPL-3+
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
pull\-debian\-source \- download a source package from Debian
|
pull\-debian\-source \- download a source package from Debian
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B pull\-debian\-source \fR[\fB\-h\fR]\fB <\fBsource package\fR> [\fItarget release\fR]
|
.B pull\-debian\-source \fR[\fIoptions\fR] <\fIsource package\fR> [\fItarget release\fR]
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBpull\-debian\-source\fR downloads and extracts the latest version of
|
\fBpull\-debian\-source\fR downloads and extracts the latest version of
|
||||||
@ -15,15 +15,51 @@ version in that release will be downloaded instead.
|
|||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
Listed below are the command line options for pull\-debian\-source:
|
Listed below are the command line options for pull\-debian\-source:
|
||||||
.TP
|
.TP
|
||||||
.B \-h, \-\-help
|
.I source package
|
||||||
Display the usage instructions and exit.
|
|
||||||
.TP
|
|
||||||
.B <source package>
|
|
||||||
This is the source package that you would like to be downloaded from Debian.
|
This is the source package that you would like to be downloaded from Debian.
|
||||||
.TP
|
.TP
|
||||||
.B [target release]
|
.I target release
|
||||||
This is the release that you would like the source package to be downloaded from.
|
This is the release that you would like the source package to be downloaded from.
|
||||||
This value defaults to 'unstable'.
|
This value defaults to 'unstable'.
|
||||||
|
.TP
|
||||||
|
.BR \-h ", " \-\-help
|
||||||
|
Display the usage instructions and exit.
|
||||||
|
.TP
|
||||||
|
.B \-m \fIDEBMIRROR\fR, \fB\-\-mirror\fR=\fIDEBMIRROR\fR
|
||||||
|
Use the specified mirror.
|
||||||
|
Should be in the form \fBhttp://ftp.debian.org/debian\fR.
|
||||||
|
If the package isn't found on this mirror, \fBpull\-debian\-source\fR
|
||||||
|
will fall back to the default mirror.
|
||||||
|
.TP
|
||||||
|
.BR \-n ", " \-\-no\-fallback
|
||||||
|
If specified, \fBpull\-debian\-source\fR won't fall back to the default
|
||||||
|
mirror, should it encounter an error.
|
||||||
|
.TP
|
||||||
|
.B \-\-no\-conf
|
||||||
|
Do not read any configuration files, or configuration from environment
|
||||||
|
variables.
|
||||||
|
|
||||||
|
.SH ENVIRONMENT
|
||||||
|
All of the \fBCONFIGURATION VARIABLES\fR below are also supported as
|
||||||
|
environment variables.
|
||||||
|
Variables in the environment take precedence to those in configuration
|
||||||
|
files.
|
||||||
|
|
||||||
|
.SH CONFIGURATION VARIABLES
|
||||||
|
The following variables can be set in the environment or in
|
||||||
|
.BR ubuntu\-dev\-tools (5)
|
||||||
|
configuration files.
|
||||||
|
In each case, the script\-specific variable takes precedence over the
|
||||||
|
package\-wide variable.
|
||||||
|
.TP
|
||||||
|
.BR PULL_DEBIAN_SOURCE_DEBMIRROR ", " UBUNTUTOOLS_DEBMIRROR
|
||||||
|
The default value for \fB\-\-mirror\fR.
|
||||||
|
.TP
|
||||||
|
.BR PULL_DEBIAN_SOURCE_MIRROR_FALLBACK ", " UBUNTUTOOLS_MIRROR_FALLBACK
|
||||||
|
The default value for \fB\-\-no\-fallback\fR.
|
||||||
|
|
||||||
|
.SH SEE ALSO
|
||||||
|
.BR ubuntu\-dev\-tools (5)
|
||||||
|
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
.PP
|
.PP
|
||||||
|
@ -56,10 +56,22 @@ The currently recognised package\-wide variables are:
|
|||||||
This specifies the preferred test\-builder, one of
|
This specifies the preferred test\-builder, one of
|
||||||
.BR pbuilder " (default), " sbuild ", " pbuilder\-dist .
|
.BR pbuilder " (default), " sbuild ", " pbuilder\-dist .
|
||||||
.TP
|
.TP
|
||||||
|
.B UBUNTUTOOLS_DEBMIRROR
|
||||||
|
The preferred Debian archive mirror.
|
||||||
|
Should be of the form \fBhttp://ftp.debian.org/debian\fR.
|
||||||
|
If not specified, the master will be used.
|
||||||
|
.TP
|
||||||
.B UBUNTUTOOLS_LPINSTANCE
|
.B UBUNTUTOOLS_LPINSTANCE
|
||||||
The launchpad instance to communicate with. e.g. \fBproduction\fR
|
The launchpad instance to communicate with. e.g. \fBproduction\fR
|
||||||
(default) or \fBstaging\fR.
|
(default) or \fBstaging\fR.
|
||||||
.TP
|
.TP
|
||||||
|
.B UBUNTUTOOLS_MIRROR_FALLBACK
|
||||||
|
Whether or not to fall\-back to the master archive mirror.
|
||||||
|
This is usually the desired behaviour, as mirrors can lag the masters.
|
||||||
|
If on a private network with only a local mirror, you may want to set
|
||||||
|
this to \fBno\fR.
|
||||||
|
.RB "One of " yes " (default) or " no .
|
||||||
|
.TP
|
||||||
.B UBUNTUTOOLS_UPDATE_BUILDER
|
.B UBUNTUTOOLS_UPDATE_BUILDER
|
||||||
Whether or not to update the test\-builder before each test build.
|
Whether or not to update the test\-builder before each test build.
|
||||||
.RB "One of " yes " or " no " (default).
|
.RB "One of " yes " or " no " (default).
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
# Script Name: pull-debian-source
|
# Script Name: pull-debian-source
|
||||||
# Author: Nathan Handler <nhandler@ubuntu.com>
|
# Author: Nathan Handler <nhandler@ubuntu.com>
|
||||||
# Usage: pull-debian-source <source package> [release]
|
# Usage: pull-debian-source <source package> [release]
|
||||||
# Copyright (C) 2008, 2009 Nathan Handler <nhandler@ubuntu.com>
|
# Copyright (C) 2008-2009 Nathan Handler <nhandler@ubuntu.com>,
|
||||||
|
# 2010 Stefano Rivera <stefanor@ubuntu.com>
|
||||||
# License: GNU General Public License
|
# License: GNU General Public License
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -27,16 +28,57 @@ use AptPkg::Version;
|
|||||||
die("Please install 'devscripts'\n") if(! grep -x "$_/dget", split(':',$ENV{'PATH'}));
|
die("Please install 'devscripts'\n") if(! grep -x "$_/dget", split(':',$ENV{'PATH'}));
|
||||||
|
|
||||||
my($name) = basename($0);
|
my($name) = basename($0);
|
||||||
|
my($help, $mirror, $no_fallback, $no_conf);
|
||||||
|
GetOptions('h|help' => \$help,
|
||||||
|
'm|mirror=s' => \$mirror,
|
||||||
|
'n|no-fallback' => \$no_fallback,
|
||||||
|
'no-conf' => \$no_conf,
|
||||||
|
);
|
||||||
my($package) = $ARGV[0] || &usage(2);
|
my($package) = $ARGV[0] || &usage(2);
|
||||||
my($help)=0;
|
|
||||||
GetOptions('help' => \$help);
|
|
||||||
&usage(0) if($help);
|
&usage(0) if($help);
|
||||||
|
|
||||||
|
if (! $no_conf) {
|
||||||
|
my($shell_cmd);
|
||||||
|
$shell_cmd .= "[ -f /etc/devscripts.conf ] && . /etc/devscripts.conf\n";
|
||||||
|
$shell_cmd .= "[ -f ~/.devscripts ] && . ~/.devscripts\n";
|
||||||
|
foreach my $var qw(PULL_DEBIAN_SOURCE_DEBMIRROR UBUNTUTOOLS_DEBMIRROR
|
||||||
|
PULL_DEBIAN_SOURCE_MIRROR_FALLBACK
|
||||||
|
UBUNTUTOOLS_MIRROR_FALLBACK) {
|
||||||
|
$shell_cmd .= "echo $var=\$$var\n";
|
||||||
|
}
|
||||||
|
my $shell_out = `/bin/bash -c '$shell_cmd'`;
|
||||||
|
my %config_values;
|
||||||
|
foreach my $line (split /\n/, $shell_out) {
|
||||||
|
my($k, $v) = split /=/, $line;
|
||||||
|
$config_values{$k} = $v;
|
||||||
|
}
|
||||||
|
$mirror = $config_values{'PULL_DEBIAN_SOURCE_DEBMIRROR'}
|
||||||
|
|| $config_values{'UBUNTUTOOLS_DEBMIRROR'}
|
||||||
|
if (! $mirror);
|
||||||
|
if (! $no_fallback) {
|
||||||
|
my($v) = $config_values{'PULL_DEBIAN_SOURCE_MIRROR_FALLBACK'}
|
||||||
|
|| $config_values{'UBUNTUTOOLS_MIRROR_FALLBACK'};
|
||||||
|
$no_fallback = 1 if $v eq "no";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
my($default_mirror) = 'http://ftp.debian.org/debian';
|
||||||
|
my(@mirrors);
|
||||||
|
push @mirrors, $mirror if $mirror;
|
||||||
|
push @mirrors, $default_mirror if $mirror ne $default_mirror and !$no_fallback;
|
||||||
|
|
||||||
my($release)=$ARGV[1] || 'unstable';
|
my($release)=$ARGV[1] || 'unstable';
|
||||||
$release=&convertCodeName($release);
|
$release=&convertCodeName($release);
|
||||||
&checkRelease($release);
|
&checkRelease($release);
|
||||||
my($dsc)=&getDSC(&getMadison(&getURL($package,$release)));
|
my($madison) = &getMadison(&getURL($package,$release));
|
||||||
|
|
||||||
|
foreach my $mirror (@mirrors) {
|
||||||
|
my($dsc)=&getDSC($madison, $mirror);
|
||||||
print "$dsc\n";
|
print "$dsc\n";
|
||||||
exec("dget -xu $dsc");
|
system("dget -xu $dsc");
|
||||||
|
exit(0) if ($? == 0);
|
||||||
|
}
|
||||||
|
exit(1);
|
||||||
|
|
||||||
sub convertCodeName {
|
sub convertCodeName {
|
||||||
my($release)=shift || die("No Release Passed To convertCodeName!\n");
|
my($release)=shift || die("No Release Passed To convertCodeName!\n");
|
||||||
chomp $release;
|
chomp $release;
|
||||||
@ -90,12 +132,12 @@ sub getDSC {
|
|||||||
if($madison=~m/^[WE]:/i) {
|
if($madison=~m/^[WE]:/i) {
|
||||||
die("$madison");
|
die("$madison");
|
||||||
}
|
}
|
||||||
my($baseURL)='http://ftp.debian.org/debian/pool/';
|
my($baseURL)=shift || die ("No baseURL Passed to getDSC: $!\n");
|
||||||
my(@madison)=split(/\n/,$madison);
|
my(@madison)=split(/\n/,$madison);
|
||||||
my %urls;
|
my %urls;
|
||||||
my $url;
|
my $url;
|
||||||
foreach my $line (@madison) {
|
foreach my $line (@madison) {
|
||||||
$url = $baseURL;
|
$url = $baseURL . '/pool/';
|
||||||
my($package,$version,$release,$archs)=split(/\|/,$line,4);
|
my($package,$version,$release,$archs)=split(/\|/,$line,4);
|
||||||
$package=~s/\s*//g;
|
$package=~s/\s*//g;
|
||||||
$version=~s/\s*//g;
|
$version=~s/\s*//g;
|
||||||
@ -133,7 +175,18 @@ sub getDSC {
|
|||||||
}
|
}
|
||||||
sub usage {
|
sub usage {
|
||||||
my($exit)=shift;
|
my($exit)=shift;
|
||||||
print("USAGE: $name [-h] <source package> [target release]\n");
|
print <<"EOF";
|
||||||
|
USAGE: $name [options] <source package> [target release]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show this help message and exit
|
||||||
|
-m DEBMIRROR, --mirror=DEBMIRROR
|
||||||
|
Preferred Debian mirror
|
||||||
|
(default: http://ftp.debian.org/debian/)
|
||||||
|
-n, --no-fallback If a custom mirror is provided and an error occurs
|
||||||
|
while downloading, don't fall back to the default.
|
||||||
|
--no-conf Don't read config files or environment variables
|
||||||
|
EOF
|
||||||
exit($exit);
|
exit($exit);
|
||||||
}
|
}
|
||||||
sub invalidRelease {
|
sub invalidRelease {
|
||||||
|
@ -34,7 +34,9 @@ class UDTConfig(object):
|
|||||||
# These are reqired to be used by at least two scripts.
|
# These are reqired to be used by at least two scripts.
|
||||||
defaults = {
|
defaults = {
|
||||||
'BUILDER': 'pbuilder',
|
'BUILDER': 'pbuilder',
|
||||||
|
'DEBMIRROR': None,
|
||||||
'LPINSTANCE': 'production',
|
'LPINSTANCE': 'production',
|
||||||
|
'MIRROR_FALLBACK': True,
|
||||||
'UPDATE_BUILDER': False,
|
'UPDATE_BUILDER': False,
|
||||||
'WORKDIR': None,
|
'WORKDIR': None,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user