From bbc3abd9987482a48381583bb9dfdaf70537e40d Mon Sep 17 00:00:00 2001 From: "Siegfried-Angel Gevatter Pujals (RainCT)" Date: Tue, 20 Nov 2007 00:21:41 +0100 Subject: [PATCH] Add dgetlp script. --- AUTHORS | 1 + debian/changelog | 5 ++- debian/copyright | 9 ++-- dgetlp | 105 +++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 3 +- 5 files changed, 118 insertions(+), 5 deletions(-) create mode 100755 dgetlp diff --git a/AUTHORS b/AUTHORS index ec46e11..5d429f9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -9,3 +9,4 @@ Kees Cook Siegfried-A. Gevatter Soren Hansen Steve Kowalik +Terence Simpson diff --git a/debian/changelog b/debian/changelog index 661e974..10b8149 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,7 +12,10 @@ ubuntu-dev-tools (0.22) UNRELEASED; urgency=low * requestsync: -Always pass -u option to rmadison now that it defaults to ubuntu - -- Laurent Bigonville Thu, 15 Nov 2007 22:33:49 +0100 + [ Siegfried-Angel Gevatter Pujals (RainCT) ] + * Add dgetlp script (for «dgetting» from Launchpad) + + -- Siegfried-Angel Gevatter Pujals (RainCT) Tue, 20 Nov 2007 00:16:55 +0100 ubuntu-dev-tools (0.21) hardy; urgency=low diff --git a/debian/copyright b/debian/copyright index b5b8006..61c9033 100644 --- a/debian/copyright +++ b/debian/copyright @@ -12,6 +12,7 @@ Upstream Author: Kees Cook Siegfried-A. Gevatter Soren Hansen + Terence Simpson Copyright: @@ -23,11 +24,12 @@ Copyright: Michael Bienia 2006-2007 Kees Cook 2006-2007 Siegfried-A. Gevatter 2007 + Terence Simpson 2007 Licenses: check-symbols, dch-repeat, mk-sbuild-lv, pbuilder-dist, pull-debian-debdiff, -submittodebian, update-maintainer, and what-patch are licensed under GPLv2: +submittodebian, update-maintainer, dgetlp and what-patch are licensed under GPLv2: This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -62,5 +64,6 @@ get-branches, suspicious-source and get-build-deps are licensed under GPLv3: On Debian systems, the complete text of the GNU General Public 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: pbuilder-dist, suspicious-source and get-build-deps. +The following of the scripts can be used, at your option, regarding any +later version of the previously specified license: pbuilder-dist, dgetlp, +suspicious-source, get-build-deps. diff --git a/dgetlp b/dgetlp new file mode 100755 index 0000000..17231f3 --- /dev/null +++ b/dgetlp @@ -0,0 +1,105 @@ +#!/bin/bash +# Copyright 2007 (C) Terence Simpson +# Modified by Siegfried-A. Gevatter +# License: GPLv2 or later +# +# This script simulates «dget»'s behaviour for files hosted at +# launchpadlibrarian.net. +# +# Detailed description: +# This script attempts to download the source package in the same +# way as dget does, but from launchpadlibrarian.net, which doesn't +# store all the files in the same directory. It (the script) assumes +# that the files are stored in sequential directories on Launchpad +# Librarian and attemps to download and then unpack them. + +GET="wget" +UNPACK="dpkg-source -x {dsc-file}" + +usage() +{ +cat << EOF +Usage: $0 [-d] + +This scripts simulates «dget»'s behaviour for files hostead at +launchpadlibrarian.net. + +If you specify the -d option then it won't do anything, but just +print the commands it would run otherwise. + +Example: + $0 http://launchpadlibrarian.net/10348157/coreutils_5.97-5.4ubuntu1.dsc +EOF +} + +if [ "$1" = "-d" ] +then + # Debug Mode + GET="echo "${GET} + UNPACK="echo "${UNPACK} + shift +fi + +if [ $# -ne 1 ] +then + usage + exit 1 +fi + +# Store download URL into a local variable to be able to modify it +URL=$1 + +if [ ${URL:0:4} == 'www.' ] +then + URL="http://"${URL:4} +fi + +if [ ${URL:0:7} != 'http://' ] +then + URL="http://"$URL +fi + +if [ ${URL:0:30} != 'http://launchpadlibrarian.net/' ] +then + echo "Error: This utility only works for files on launchpadlibrarian.net." + exit 1 +fi + +if [ ${URL##*.} != 'dsc' ] +then + echo "You have to provide the URL for the .dsc file." + exit 1 +fi + +BASE="http://launchpadlibrarian.net" #BASE="http://$(echo $URL|cut -d '/' -f 3)" +NUMBER="$(echo $URL|cut -d '/' -f 4)" +FILE="$(echo $URL|cut -d '/' -f 5)" + +UNPACK=$(echo $UNPACK | sed s/{dsc-file}/${FILE}/g) + +echo "Getting ${BASE}/${NUMBER}/${FILE}" +if ! $GET ${BASE}/${NUMBER}/${FILE} +then + echo "Failed to fetch «.dsc» file, aborting." + exit 1 +fi + +echo "Getting ${BASE}/$(($NUMBER-1))/$(echo $FILE|sed 's,\.dsc$,.diff.gz,')" +if ! $GET ${BASE}/$(($NUMBER-1))/$(echo $FILE | sed 's,\.dsc$,.diff.gz,') +then + echo "Failed to fetch «.diff.gz» file, aborting." + exit 1 +fi + +echo "Getting ${BASE}/$(($NUMBER-2))/$(echo $FILE|sed 's,\-[0-9]*.*$,.orig.tar.gz,')" +if ! $GET ${BASE}/$(($NUMBER-2))/$(echo $FILE|sed 's,\-[0-9]*.*$,.orig.tar.gz,') +then + echo "Failed to fetch «orig.tar.gz» file, aborting." + exit 1 +fi + +if ! $UNPACK +then + echo "Failed to unpack source, aborting." + exit 1 +fi diff --git a/setup.py b/setup.py index 48c2ae3..ecd01a3 100755 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ setup(name='ubuntu-dev-tools', 'hugdaylist', 'massfile', 'submittodebian', - 'get-build-deps' + 'get-build-deps', + 'dgetlp' ], )