Also support uncompressed control.tar files
[tools/build.git] / createmdkdeps
1 #!/usr/bin/perl -w
2
3 ################################################################
4 #
5 # Copyright (c) 2015 SUSE Linux GmbH
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2 or 3 as
9 # published by the Free Software Foundation.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program (see the file COPYING); if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 #
21 ################################################################
22
23 # Mandriva/Mageia support
24
25 BEGIN {
26   unshift @INC, ($::ENV{"BUILD_DIR"} || "/usr/lib/build");
27 }
28
29 use strict;
30 use Build ':mdk';
31 use Build::Mdkrepo;
32 use Digest::MD5 ();
33 use File::Path;
34 use Getopt::Long;
35
36 Getopt::Long::Configure("no_ignore_case");
37
38 my $cachedir = "/var/cache/build";
39
40 GetOptions("cachedir=s"  => \$cachedir) or exit(1);
41
42 for my $url (@ARGV) {
43   die("$url: not an remote mandriva/mageia repo") unless $url =~ /^(:?ftps?|https?):\/\/([^\/]*)\/?/;
44   my $repoid = Digest::MD5::md5_hex($url);
45   my $dir = "$cachedir/$repoid";
46   $url .= '/' unless $url =~ /\/$/;
47   File::Path::mkpath($dir);
48   system("$INC[0]/download", $dir, "${url}media_info/synthesis.hdlist.cz");
49   Build::Mdkrepo::parse("$dir/synthesis.hdlist.cz", sub { Build::writedeps(\*STDOUT, $_[0], $url) }, 'addselfprovides' => 1);
50 }