Merge "Support BuildFlags: nocumulaterpms" into devel
[tools/build.git] / createzyppdeps
1 #!/usr/bin/perl -w
2
3 ################################################################
4 #
5 # Copyright (c) 1995-2014 SUSE Linux Products 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 BEGIN {
24   unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
25 }
26
27 use strict;
28
29 use Build::Zypp;
30 use Getopt::Long;
31
32 Getopt::Long::Configure("no_ignore_case");
33
34 my $cachedir = "/var/cache/build";
35 my $opt_listrepos;
36
37 GetOptions(
38     "cachedir=s"  => \$cachedir,
39     "listrepos" => \$opt_listrepos,
40     ) or exit(1);
41
42 if ($opt_listrepos) {
43   die("createzyppdeps --listrepos does not take an argument\n") if @ARGV;
44   for my $r (Build::Zypp::parseallrepos()) {
45     print "$r->{'name'}\n" if $r->{'enabled'};
46   }
47   exit 0;
48 }
49 die("createzyppdeps needs exactly one argument\n") if @ARGV != 1;
50 my $url = $ARGV[0];
51
52 die("createzyppdeps argument must start with 'zypp://'\n") unless $url =~ /^zypp:\/\/([^\/]*)/;
53 my $repo = Build::Zypp::parserepo($1);
54
55 my $type = $repo->{'type'};
56 my $zyppcachedir = "/var/cache/zypp/raw/$repo->{'name'}";
57
58 if($type eq 'rpm-md') {
59   exec ("$INC[0]/createrepomddeps", '--cachedir', $cachedir, '--zypp', $zyppcachedir, $url);
60 } elsif ($type eq 'yast2') {
61   exec ("$INC[0]/createyastdeps", '--cachedir', $cachedir, '--zypp', $zyppcachedir, $url);
62 } else {
63   die "unsupported repo type: $type\n";
64 }