|
1 --- pkgbuild-1.3.103/rpm_spec.pm.in.orig 2011-05-30 03:08:52.363950094 +0100 |
|
2 +++ pkgbuild-1.3.103/rpm_spec.pm.in 2011-06-20 10:45:55.986089124 +0100 |
|
3 @@ -35,6 +35,7 @@ |
|
4 #use strict; |
|
5 |
|
6 use warnings; |
|
7 +use XML::XPath; |
|
8 use rpm_package; |
|
9 use rpm_file; |
|
10 use packagebase; |
|
11 @@ -64,6 +65,12 @@ |
|
12 my $all_block_names = "prep|build|install|clean|check|changelog|$all_script_names"; |
|
13 my $all_keywords = "$all_block_names|define|patch|setup|files|description|package|iclass|rclass|use|actions"; |
|
14 |
|
15 +my $distro_file_name = "${_homedir}/packages.xml"; |
|
16 +# Tags from the XML file relevant to pkgbuild, which we prevent the spec from redefining |
|
17 +# Don't use the exists function on an array because that is deprecated; define a hash instead |
|
18 +my %distro_tag_names = ("ips_package_name", 0, "group", 0, "summary", 0); |
|
19 +my $xpath; |
|
20 + |
|
21 sub get_version () { |
|
22 my $version = "1.3.103"; |
|
23 return $version; |
|
24 @@ -138,6 +145,25 @@ |
|
25 `mkdir -p /var/tmp/pkgbuild-${logname}`; |
|
26 } |
|
27 |
|
28 +# Get redefinitions for some tags from the XML file for that purpose, using the |
|
29 +# XPath location path supplied as our argument that tells us how to find them |
|
30 +sub get_distro_tags ($) { |
|
31 + return () unless (defined($xpath)); |
|
32 + my @nodes = $xpath->findnodes(shift); |
|
33 + my @tags = (); |
|
34 + foreach my $node (@nodes) { |
|
35 + my $name = $node->getName; |
|
36 +# Create an association list of tag name/value pairs |
|
37 +# Our XML file uses some tags unknown to pkgbuild, so make sure the tag is relevant |
|
38 + push @tags, $name, $node->getChildNode(1)->getValue |
|
39 + if (exists $distro_tag_names{$name}); |
|
40 + } |
|
41 +# Return a reference to the list instead of the list itself, in case we will want |
|
42 +# this function to also handle Meta tags, in which case we will return two lists. |
|
43 +# (It is not possible to return more than one list in Perl other than by reference.) |
|
44 + return \@tags; |
|
45 +} |
|
46 + |
|
47 # Create a new rpm_spec object. |
|
48 # Return undef if the spec_file is not found |
|
49 # args: |
|
50 @@ -157,7 +183,11 @@ |
|
51 if (! -r $spec_file) { |
|
52 return (undef); |
|
53 } |
|
54 - |
|
55 + |
|
56 +# If there is a distribution-specific XML file which redefines some tags, process it |
|
57 + $xpath = XML::XPath->new(filename => $distro_file_name) |
|
58 + if (-f $distro_file_name); |
|
59 + |
|
60 if (not $spec_file =~ /^\//) { |
|
61 my $current_dir=`pwd`; |
|
62 chomp ($current_dir); |
|
63 @@ -1285,7 +1315,17 @@ |
|
64 $package_ref->set_subpkg($is_subpkg); |
|
65 } |
|
66 } |
|
67 - $package_ref->set_tag ($tagname, $value); |
|
68 + if ($tagname eq "name" ) { |
|
69 + # set tags defined by distro in xml file for that purpose |
|
70 + # @$distro_tags is an association list of tag names and values |
|
71 + my $distro_tags = get_distro_tags ("pkgs/pkg[string(name)=\'$value\']/child::*"); |
|
72 + $package_ref->set_tag (shift @$distro_tags, shift @$distro_tags) |
|
73 + while (@$distro_tags); |
|
74 + } |
|
75 +# Ignore tag specified by spec if the tag was set using get_distro_tags |
|
76 + $package_ref->set_tag ($tagname, $value) |
|
77 + unless (defined $package_ref->get_tag ($tagname) && |
|
78 + exists $distro_tag_names{$tagname}); |
|
79 return 1; |
|
80 } |
|
81 } |
|
82 @@ -1428,6 +1468,13 @@ |
|
83 my $packagebase = new packagebase; |
|
84 $packagebase->add_package ($new_package); |
|
85 |
|
86 +# Get IPS_package_name and other tags from distribution-specific XML file |
|
87 + unless ($is_subpkg) { |
|
88 + my $distro_tags = get_distro_tags ("pkgs/pkg/pkg[string(name)=\'$package_name\']/child::*"); |
|
89 + $new_package->set_tag (shift @$distro_tags, shift @$distro_tags) |
|
90 + while (@$distro_tags) |
|
91 + } |
|
92 + |
|
93 $line = $self->_get_next_line ($fhandle); |
|
94 if (defined ($line)) { |
|
95 return $self->_process_top_level ($fhandle, $line); |