mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +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, Nathan Handler <nhandler@ubuntu.com>
|
||||
2007-2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||
2010, Stefano Rivera <stefanor@ubuntu.com>
|
||||
License: GPL-3+
|
||||
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
|
||||
|
@ -4,7 +4,7 @@
|
||||
pull\-debian\-source \- download a source package from Debian
|
||||
|
||||
.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
|
||||
\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
|
||||
Listed below are the command line options for pull\-debian\-source:
|
||||
.TP
|
||||
.B \-h, \-\-help
|
||||
Display the usage instructions and exit.
|
||||
.TP
|
||||
.B <source package>
|
||||
.I source package
|
||||
This is the source package that you would like to be downloaded from Debian.
|
||||
.TP
|
||||
.B [target release]
|
||||
.I target release
|
||||
This is the release that you would like the source package to be downloaded from.
|
||||
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
|
||||
.PP
|
||||
|
@ -56,10 +56,22 @@ The currently recognised package\-wide variables are:
|
||||
This specifies the preferred test\-builder, one of
|
||||
.BR pbuilder " (default), " sbuild ", " pbuilder\-dist .
|
||||
.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
|
||||
The launchpad instance to communicate with. e.g. \fBproduction\fR
|
||||
(default) or \fBstaging\fR.
|
||||
.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
|
||||
Whether or not to update the test\-builder before each test build.
|
||||
.RB "One of " yes " or " no " (default).
|
||||
|
@ -2,7 +2,8 @@
|
||||
# Script Name: pull-debian-source
|
||||
# Author: Nathan Handler <nhandler@ubuntu.com>
|
||||
# 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
|
||||
# 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
|
||||
@ -26,17 +27,58 @@ use AptPkg::Version;
|
||||
|
||||
die("Please install 'devscripts'\n") if(! grep -x "$_/dget", split(':',$ENV{'PATH'}));
|
||||
|
||||
my($name)=basename($0);
|
||||
my($package)=$ARGV[0] || &usage(2);
|
||||
my($help)=0;
|
||||
GetOptions('help' => \$help);
|
||||
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);
|
||||
&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';
|
||||
$release=&convertCodeName($release);
|
||||
&checkRelease($release);
|
||||
my($dsc)=&getDSC(&getMadison(&getURL($package,$release)));
|
||||
print "$dsc\n";
|
||||
exec("dget -xu $dsc");
|
||||
my($madison) = &getMadison(&getURL($package,$release));
|
||||
|
||||
foreach my $mirror (@mirrors) {
|
||||
my($dsc)=&getDSC($madison, $mirror);
|
||||
print "$dsc\n";
|
||||
system("dget -xu $dsc");
|
||||
exit(0) if ($? == 0);
|
||||
}
|
||||
exit(1);
|
||||
|
||||
sub convertCodeName {
|
||||
my($release)=shift || die("No Release Passed To convertCodeName!\n");
|
||||
chomp $release;
|
||||
@ -90,12 +132,12 @@ sub getDSC {
|
||||
if($madison=~m/^[WE]:/i) {
|
||||
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 %urls;
|
||||
my $url;
|
||||
foreach my $line (@madison) {
|
||||
$url = $baseURL;
|
||||
$url = $baseURL . '/pool/';
|
||||
my($package,$version,$release,$archs)=split(/\|/,$line,4);
|
||||
$package=~s/\s*//g;
|
||||
$version=~s/\s*//g;
|
||||
@ -133,7 +175,18 @@ sub getDSC {
|
||||
}
|
||||
sub usage {
|
||||
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);
|
||||
}
|
||||
sub invalidRelease {
|
||||
|
@ -34,7 +34,9 @@ class UDTConfig(object):
|
||||
# These are reqired to be used by at least two scripts.
|
||||
defaults = {
|
||||
'BUILDER': 'pbuilder',
|
||||
'DEBMIRROR': None,
|
||||
'LPINSTANCE': 'production',
|
||||
'MIRROR_FALLBACK': True,
|
||||
'UPDATE_BUILDER': False,
|
||||
'WORKDIR': None,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user