Make pkgbuild use packages.xml to set ips_package_name; stop it from packaging sources
authorAlex Viskovatoff <herzen@imap.cc>
Sat, 25 Jun 2011 21:27:50 +0100
changeset 1 b967c1549045
parent 0 9673581c82b4
child 2 703a514d2a12
Make pkgbuild use packages.xml to set ips_package_name; stop it from packaging sources
pkgbuild/patches/distro-redefine-tags.diff
pkgbuild/patches/no-source-packages.diff
pkgbuild/pkgbuild.spec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgbuild/patches/distro-redefine-tags.diff	Sat Jun 25 21:27:50 2011 +0100
@@ -0,0 +1,95 @@
+--- pkgbuild-1.3.103/rpm_spec.pm.in.orig	2011-05-30 03:08:52.363950094 +0100
++++ pkgbuild-1.3.103/rpm_spec.pm.in	2011-06-20 10:45:55.986089124 +0100
+@@ -35,6 +35,7 @@
+ #use strict;
+ 
+ use warnings;
++use XML::XPath;
+ use rpm_package;
+ use rpm_file;
+ use packagebase;
+@@ -64,6 +65,12 @@
+ my $all_block_names = "prep|build|install|clean|check|changelog|$all_script_names";
+ my $all_keywords = "$all_block_names|define|patch|setup|files|description|package|iclass|rclass|use|actions";
+ 
++my $distro_file_name = "${_homedir}/packages.xml";
++# Tags from the XML file relevant to pkgbuild, which we prevent the spec from redefining
++# Don't use the exists function on an array because that is deprecated; define a hash instead
++my %distro_tag_names = ("ips_package_name", 0, "group", 0, "summary", 0);
++my $xpath;
++
+ sub get_version () {
+     my $version = "1.3.103";
+     return $version;
+@@ -138,6 +145,25 @@
+     `mkdir -p /var/tmp/pkgbuild-${logname}`;
+ }
+ 
++# Get redefinitions for some tags from the XML file for that purpose, using the
++# XPath location path supplied as our argument that tells us how to find them
++sub get_distro_tags ($) {
++    return () unless (defined($xpath));
++    my @nodes = $xpath->findnodes(shift);
++    my @tags = ();
++    foreach my $node (@nodes) {
++	my $name = $node->getName;
++#	Create an association list of tag name/value pairs
++#	Our XML file uses some tags unknown to pkgbuild, so make sure the tag is relevant
++	push @tags, $name, $node->getChildNode(1)->getValue
++	    if (exists $distro_tag_names{$name});
++    }
++#   Return a reference to the list instead of the list itself, in case we will want
++#   this function to also handle Meta tags, in which case we will return two lists.
++#   (It is not possible to return more than one list in Perl other than by reference.)
++    return \@tags;
++}
++
+ # Create a new rpm_spec object.
+ # Return undef if the spec_file is not found
+ # args:
+@@ -157,7 +183,11 @@
+     if (! -r $spec_file) {
+ 	return (undef);
+     }
+-    
++
++#   If there is a distribution-specific XML file which redefines some tags, process it
++    $xpath = XML::XPath->new(filename => $distro_file_name)
++	if (-f $distro_file_name);
++
+     if (not $spec_file =~ /^\//) {
+ 	my $current_dir=`pwd`;
+ 	chomp ($current_dir);
+@@ -1285,7 +1315,17 @@
+ 		    $package_ref->set_subpkg($is_subpkg);
+ 		}
+ 	    }
+-	    $package_ref->set_tag ($tagname, $value);
++	    if ($tagname eq "name" ) {
++		# set tags defined by distro in xml file for that purpose
++		# @$distro_tags is an association list of tag names and values
++		my $distro_tags = get_distro_tags ("pkgs/pkg[string(name)=\'$value\']/child::*");
++		$package_ref->set_tag (shift @$distro_tags, shift @$distro_tags)
++		    while (@$distro_tags);
++	    }
++#	    Ignore tag specified by spec if the tag was set using get_distro_tags
++	    $package_ref->set_tag ($tagname, $value)
++		unless (defined $package_ref->get_tag ($tagname) &&
++			exists $distro_tag_names{$tagname});
+ 	    return 1;
+ 	}
+     }
+@@ -1428,6 +1468,13 @@
+     my $packagebase = new packagebase;
+     $packagebase->add_package ($new_package);
+ 
++#   Get IPS_package_name and other tags from distribution-specific XML file
++    unless ($is_subpkg) {
++	my $distro_tags = get_distro_tags ("pkgs/pkg/pkg[string(name)=\'$package_name\']/child::*");
++	$new_package->set_tag (shift @$distro_tags, shift @$distro_tags)
++	    while (@$distro_tags)
++    }
++
+     $line = $self->_get_next_line ($fhandle);
+     if (defined ($line)) {
+ 	return $self->_process_top_level ($fhandle, $line);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgbuild/patches/no-source-packages.diff	Sat Jun 25 21:27:50 2011 +0100
@@ -0,0 +1,11 @@
+--- pkgbuild-1.3.103/pkgtool.pl.orig	2011-05-29 21:19:33.576785383 +0100
++++ pkgbuild-1.3.103/pkgtool.pl	2011-05-29 21:29:05.096169345 +0100
+@@ -2732,7 +2732,7 @@
+ sub run_build ($;$) {
+     my $spec_id = shift;
+     my $build_mode = shift;
+-    $build_mode = "-ba" unless defined $build_mode;
++    $build_mode = "-bb" unless defined $build_mode;
+     my $spec = $specs_to_build[$spec_id];
+     my $spec_file = $spec->get_file_name ();
+     my $base_name = $spec->get_base_file_name ();
--- a/pkgbuild/pkgbuild.spec	Sat Jun 25 20:59:21 2011 +0100
+++ b/pkgbuild/pkgbuild.spec	Sat Jun 25 21:27:50 2011 +0100
@@ -17,27 +17,29 @@
 %define _pkg_docdir %_docdir/%srcname
 
 Name:         SFEpkgbuild
-#IPS_Package_Name: package/pkgbuild
+IPS_Package_Name: package/pkgbuild
 License:      GPL
-Group:        Development/Tools/Other
+Group:        Development/Tools
 URL:	      http://pkgbuild.sourceforge.net/
 Version:      1.3.103
-Release:      1
+Release:      2
 BuildArch:    noarch
 Vendor:	      OpenSolaris Community
-Summary:      pkgbuild - rpmbuild-like tool for building Solaris packages
-Source:      http://prdownloads.sourceforge.net/pkgbuild/pkgbuild-%{version}.tar.bz2
-#Source:       http://opensolaris-lang.googlecode.com/files/pkgbuild-%{version}pre.tar.bz2
+Summary:      rpmbuild-like tool for building Solaris packages
+Source:       http://prdownloads.sourceforge.net/pkgbuild/pkgbuild-%{version}.tar.bz2
+
 # First three patches are taken from oi-cbe
-Patch1:       pkgbuild-01-add-unknown-dependencies.patch
-Patch2:       pkgbuild-02-nopkg.patch
-Patch3:       pkgbuild-03-forcefully-copy-docs.patch
+Patch1:       pkgbuild/pkgbuild-01-add-unknown-dependencies.patch
+Patch2:       pkgbuild/pkgbuild-02-nopkg.patch
+Patch3:       pkgbuild/pkgbuild-03-forcefully-copy-docs.patch
 # Next three patches are taken from here:
 # http://solaris.bionicmutton.org/hg/kde4-specs-460/file/d57ba60c50da/setup/common/patches
-Patch4:       pkgbuild/pkgbuild-patchdir.diff
+Patch4:       pkgbuild/pkgbuild-04-patchdir.diff
 #Patch2:       pkgbuild/pkgbuild-postprocess-debug-separate.diff
 #Patch3:       pkgbuild/pkgbuild-local.diff
-Patch5:       pkgbuild/pkgbuild-xz.diff
+Patch5:       pkgbuild/pkgbuild-05-xz.diff
+Patch6:       pkgbuild/distro-redefine-tags.diff
+Patch7:       pkgbuild/no-source-packages.diff
 BuildRoot:    %{_tmppath}/%{name}-%{version}-build
 
 %if %_is_pkgbuild
@@ -81,6 +83,10 @@
 #%patch3
 # patch to make pkgbuild recognize xz compressed archives
 %patch5
+%patch6 -p1
+# stop pkgtool from building source packages
+# Originally, pkgtool called pkgbuild with -bb, not -ba. Really, an option controlling this should be added.
+%patch7 -p1
 
 %build
 ./configure --prefix=%{pkgbuild_prefix} --docdir=%_docdir/%srcname
@@ -105,6 +111,9 @@
 %{_mandir}
 
 %changelog
+* Wed Jun 22 2011 - Alex Viskovatoff <[email protected]>
+- get ips_package_name from packages.xml
+- stop pkgtool from building source packages
 * Sun Apr 10 2011 - Alex Viskovatoff <[email protected]>
 - add patches from oi-cbe, rearranging patches
 * Sat Apr  2 2011 - Alex Viskovatoff <[email protected]>