~unit193/ubuntu-dev-tools/update-deb-mirror

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl
# Script Name: pull-revu-source
# Author: Nathan Handler <nhandler@ubuntu.com>
# Usage: pull-revu-source <source package>
# Copyright (C) 2009 Nathan Handler <nhandler@ubuntu.com>
# Based on revupull in kubuntu-dev-tools,
# written by Harald Sitter <apachelogger@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
# 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-3 file.

use warnings;
use strict;
use File::Basename;
use Getopt::Long;

my $REVU = "revu.ubuntuwire.com";

my($package) = lc($ARGV[0]) || usage(2);
my($help)=0;
GetOptions('help' => \$help);
usage(0) if($help);

eval { require LWP::Simple; };
if ($@=~ m#^Can\'t locate LWP/Simple#) {
	print(STDERR "Please install libwww-perl.\n");
	exit(1);
}
use LWP::Simple;

dget(getURL());

sub getURL {
	my($url) = "http://" . $REVU . "/dsc.py?url&package=" . $package;
	my($page)=get($url);
	die("Could Not Get $url") unless (defined $page);
	return $page;
}

sub dget {
	my($dsc) = @_;
	exec("dget -xu $dsc");
}

sub usage {
	my($exit) = @_;
	my($name)=basename($0);
	print("USAGE: $name [-h] <source package>\n");
	exit($exit);
}