From 39bf024a2f39697c2f38070c52c041dcbfcdfdd8 Mon Sep 17 00:00:00 2001 From: Nathan Handler Date: Sat, 20 Dec 2008 16:36:35 -0600 Subject: [PATCH] * Add pull-debian-source script - debian/control: Add perl-modules and libwww-perl as Depends - debian/copyright: + Add myself to the Upstream Authors and Copyright sections + Add pull-debian-source to the License section - Add doc/pull-debian-source.1 --- debian/changelog | 11 +++++ debian/control | 2 +- debian/copyright | 6 ++- doc/pull-debian-source.1 | 33 +++++++++++++ pull-debian-source | 102 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 doc/pull-debian-source.1 create mode 100755 pull-debian-source diff --git a/debian/changelog b/debian/changelog index 9850014..8ec3c2e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +ubuntu-dev-tools (0.50) UNRELEASED; urgency=low + + * Add pull-debian-source script + - debian/control: Add perl-modules and libwww-perl as Depends + - debian/copyright: + + Add myself to the Upstream Authors and Copyright sections + + Add pull-debian-source to the License section + - Add doc/pull-debian-source.1 + + -- Nathan Handler Sat, 20 Dec 2008 16:32:27 -0600 + ubuntu-dev-tools (0.49) jaunty; urgency=low [ Sarah Hobbs ] diff --git a/debian/control b/debian/control index c607fa2..ece0dbd 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,7 @@ Architecture: all Section: devel Depends: ${python:Depends}, binutils, devscripts, sudo, python-debian, python-launchpad-bugs (>= 0.2.25), dctrl-tools, lsb-release, diffstat, - dpkg-dev, ${misc:Depends} + dpkg-dev, ${misc:Depends}, perl-modules, libwww-perl Recommends: bzr, pbuilder | sbuild, reportbug (>= 3.39ubuntu1), ca-certificates, genisoimage Conflicts: devscripts (<< 2.10.7ubuntu5) diff --git a/debian/copyright b/debian/copyright index 2c84739..bdcef58 100644 --- a/debian/copyright +++ b/debian/copyright @@ -21,6 +21,7 @@ Upstream Authors: Soren Hansen Steve Kowalik Terence Simpson + Nathan Handler Copyright: @@ -37,6 +38,7 @@ Copyright: (C) 2007, Terence Simpson (C) 2008, Iain Lane (C) 2008, Jonathan Patrick Davies + (C) 2008, Nathan handler Licenses: @@ -57,7 +59,7 @@ On Debian and Ubuntu systems, the complete text of the GNU General Public License v2 can be found in `/usr/share/common-licenses/GPL-2'. dch-repeat, get-branches, get-build-deps, massfile, mk-sbuild-lv, ppaput, -pull-debian-debdiff, pull-lp-source, suspicious-source and what-patch are +pull-debian-debdiff, pull-debian-source, pull-lp-source, suspicious-source and what-patch are licensed under the GNU General Public License, version 3: This program is free software: you can redistribute it and/or modify @@ -74,5 +76,5 @@ License v3 can be found in `/usr/share/common-licenses/GPL-3'. The following of the scripts can be used, at your option, regarding any later version of the previously specified license: 404main, dch-repeat, dgetlp, -get-build-deps, mk-sbuild-lv, pull-debian-debdiff, pull-lp-source, +get-build-deps, mk-sbuild-lv, pull-debian-debdiff, pull-debian-source, pull-lp-source, reverse-build-depends, suspicious-source, what-patch. diff --git a/doc/pull-debian-source.1 b/doc/pull-debian-source.1 new file mode 100644 index 0000000..11e48ae --- /dev/null +++ b/doc/pull-debian-source.1 @@ -0,0 +1,33 @@ +.TH PULL\-DEBIAN\-SOURCE "1" "20 December 2008" "ubuntu-dev-tools" + +.SH NAME +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] + +.SH DESCRIPTION +\fBpull\-debian\-source\fR downloads and extracts the latest version of +<\fBsource package\fR> from Debian. +If the optional parameter [\fItarget release\fR] is specified, the latest +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 +This is the source package that you would like to be downloaded from Debian. +.TP +.B [target release] +This is the release that you would like the source package to be downloaded from. +This value defaults to 'unstable'. + +.SH AUTHOR +.PP +\fBpull\-debian\-source\fR and this manual page were written by Nathan Handler +. The manual page was based on Iain Lane's manual page for +pull-lp-source. +Both are released under the GNU General Public License, version 3 or later. diff --git a/pull-debian-source b/pull-debian-source new file mode 100755 index 0000000..b5d8dc2 --- /dev/null +++ b/pull-debian-source @@ -0,0 +1,102 @@ +#!/usr/bin/perl +# Script Name: pull-debian-source +# Author: Nathan Handler +# Usage: pull-debian-source [release] +# Copyright (C) 2008 Nathan Handler +# 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# On Debian GNU/Linux systems, the complete text of the GNU General +# Public License can be found in the /usr/share/common-licenses/GPL file. + +use warnings; +use strict; +use LWP::Simple; +use File::Basename; + +my($package)=$ARGV[0] || &usage(); +&usage() if(($package=~m/\-\-help/i) || ($package=~m/\-h/i)); +my($release)=$ARGV[1] || 'unstable'; +&checkRelease($release); +my($dsc)=&getDSC(&getMadison(&getURL($package,$release))); +print "$dsc\n"; +exec("dget $dsc"); +sub checkRelease { + my($release)=shift || die("No Release Passed To checkRelease!\n"); + chomp $release; + my %releases=( + 'etch' => 1, + 'stable' => 1, + 'lenny' => 1, + 'testing' => 1, + 'sid' => 1, + 'unstable' => 1, + 'experimental' => 1 + ); + &invalidRelease(\%releases) unless $releases{$release} +} +sub getURL{ + my($package)=shift || die("No Package Passed To getURL: $!\n"); + my($release)=shift || die("No Release Passed to getURL: $!\n"); + chomp $package; + chomp $release; + $package=lc($package); + $package=~s/\+/%2b/g; + $release=lc($release); + my($baseURL)='http://qa.debian.org/madison.php?text=on'; + my($url)=$baseURL . '&package=' . $package . '&s=' . $release; + return $url; +} +sub getMadison { + my($url)=shift || die("No URL Passed to getMadison: $!\n"); + chomp $url; + my($madison)=get($url); + die("Could Not Get $url") unless (defined $madison && $madison!~m/^\s*$/); + return $madison; +} +sub getDSC { + my($madison)=shift || die("No madison Passed to getDSC: $!\n"); + if($madison=~m/^[WE]:/i) { + die("$madison"); + } + my($baseURL)='http://ftp.debian.org/debian/pool/main/'; + my(@madison)=split(/\n/,$madison); + foreach my $line (@madison) { + my($package,$version,$release,$archs)=split(/\|/,$line,4); + $package=~s/\s*//g; + $version=~s/\s*//g; + $release=~s/\s*//g; + $archs=~s/\s*//g; + if($archs=~m/source/) { + print "Package: $package\nVersion: $version\nRelease: $release\nArchitectures: $archs\n"; + my($firstLetter)=substr($package,0,1); + my($url)=$baseURL . $firstLetter . '/' . $package . '/' . $package . '_' . $version . '.dsc'; + return $url; + } + } + die("Unable To Find Source Package On Madison\n"); +} +sub usage { + my($name)=basename($0); + die("USAGE: $name [-h] [target release]\n"); +} +sub invalidRelease { + my($releases)=shift || die("Invalid Release!"); + my(%releases)=%$releases; + my($validReleases); + while ( my ($key, $value) = each(%releases) ) { + if($value) { + $validReleases .= $key . ", "; + } + } + $validReleases=~s/,\s*$//; + die("Invalid Release!\nValid Releases: $validReleases\n"); +}