1 | #!/usr/bin/perl -I /home/warly/files/cvs/mdk/soft/mkcd/pm |
---|
2 | # |
---|
3 | # |
---|
4 | |
---|
5 | use strict; |
---|
6 | use URPM; |
---|
7 | use URPM::Build; |
---|
8 | use File::Find qw(find); |
---|
9 | |
---|
10 | $ARGV[0] or print "\nUsage: |
---|
11 | build-hdlist <rpms dir 1> <rpms dir 2> ... <rpms dir n> |
---|
12 | |
---|
13 | \n\n" and exit; |
---|
14 | my $topdir = `pwd`; |
---|
15 | chop $topdir; |
---|
16 | my $tmp = $ENV{TMPDIR} || "$topdir/tmp"; |
---|
17 | |
---|
18 | my @ARCH = qw(i586 ia64 noarch ppc alpha sparc); |
---|
19 | |
---|
20 | my ($path); |
---|
21 | |
---|
22 | mkcd_build_hdlist(int @ARGV, |
---|
23 | [ 0, |
---|
24 | map { |
---|
25 | $path = $_; |
---|
26 | my @rpm; |
---|
27 | find({ wanted => sub{ push @rpm, $_ if -f && /(?!src).rpm$/ }, no_chdir => 1 }, $path); |
---|
28 | open my $A, ">$path/list"; |
---|
29 | { rpms => [ |
---|
30 | map { |
---|
31 | my $a = $_; |
---|
32 | $a =~ s/$path//; |
---|
33 | print $A "./$a\n"; |
---|
34 | "$path/$a" |
---|
35 | } @rpm ], |
---|
36 | hdlist => "$path/hdlist.cz", |
---|
37 | synthesis => "$path/synthesis.hdlist.cz" |
---|
38 | } |
---|
39 | } @ARGV ], "$tmp/.bh-build_hdlist"); |
---|
40 | |
---|
41 | exit; |
---|
42 | |
---|
43 | # stolen from mkcd |
---|
44 | sub mkcd_build_hdlist{ |
---|
45 | my ($num,$hdlist,$headers_dir,$depslist,$provides,$compss) = @_; |
---|
46 | my $urpm = new URPM; |
---|
47 | for (1 .. $num){ |
---|
48 | $hdlist->[$_]{headers} = |
---|
49 | [ $urpm->parse_rpms_build_headers( |
---|
50 | dir => $headers_dir, |
---|
51 | rpms => $hdlist->[$_]{rpms}) ]; |
---|
52 | } |
---|
53 | |
---|
54 | $urpm->unresolved_provides_clean; |
---|
55 | for (1 .. $num){ |
---|
56 | my $e = $hdlist->[$_]; |
---|
57 | my ($start, $end) = $urpm->parse_headers(dir => $headers_dir, headers => $e->{headers}, callback => $hdlist->[$_]{callback}); |
---|
58 | $urpm->compute_deps; |
---|
59 | if ($start >= $end){ |
---|
60 | print "WARNING mkcd_build_hdlist: $e->{hdlist} and $e->{synthesis} are empty\n"; |
---|
61 | next |
---|
62 | } |
---|
63 | if (length $e->{hdlist}){ |
---|
64 | print "mkcd_build_hdlist: write $e->{hdlist}\n"; |
---|
65 | $urpm->build_hdlist(start => $start, end => $end, dir => $headers_dir, hdlist => $e->{hdlist}, ratio => 9); |
---|
66 | } |
---|
67 | if (length $e->{synthesis}){ |
---|
68 | print "mkcd_build_hdlist: write $e->{synthesis}\n"; |
---|
69 | $urpm->build_synthesis(start => $start, end => $end, synthesis => $e->{synthesis}) |
---|
70 | } |
---|
71 | } |
---|
72 | $urpm->build_base_files(depslist => $depslist, provides => $provides, compss => $compss); |
---|
73 | |
---|
74 | return $urpm; |
---|
75 | } |
---|