浏览代码

support per-package build options

Michael van Elst 22 年之前
父节点
当前提交
001e4a51b6
共有 3 个文件被更改,包括 46 次插入22 次删除
  1. 36 15
      openpkg-tool/openpkg-build.pl
  2. 2 2
      openpkg-tool/openpkg-tool.spec
  3. 8 5
      openpkg-tool/openpkg.pod

+ 36 - 15
openpkg-tool/openpkg-build.pl

@@ -837,15 +837,14 @@ sub simple_text_parser ($$$$$$) {
                     ? { %options }
                     : parse_options($desc);
 
+		$mywith = name_with($name, $with);
                 if ($options) {
                     my(@t) = get_targets($installed->{$name},sub { 1; });
                     $mywith = combine_options(
                         $options,
                         @t ? get_with($t[0]) : undef,
-                        $with
+                        $mywith
                     );
-                } else {
-                    $mywith = $with;
                 }
 
                 eval {
@@ -938,16 +937,15 @@ sub xml_parser ($$$$$$) {
             ? { %options }
             : parse_options($desc);
 
+	$mywith = name_with($name, $with);
         if ($options) {
             my(@t) = get_targets($installed->{$name},sub { 1; });
             $mywith = combine_options(
                 $options,
                 @t ? get_with($t[0]) : undef,
-                $with
+                $mywith
             );
-        } else {
-            $mywith = $with;
-        } 
+        }
 
         eval {
             $rec = {
@@ -1292,6 +1290,26 @@ sub target_better ($$$) {
     return;
 }
 
+#
+# filter out package relevant options
+#
+sub name_with ($$) {
+	my($name, $with) = @_;
+	my(@keys);
+
+	push(@keys, grep { !/::/ } keys %$with);
+	push(@keys, grep { /::/ } keys %$with);
+
+	return {
+		map {
+			my($k) = $_;
+			$k !~ /::/ || $k =~ s/^\Q$name\E:://
+			? ( $k => $with->{$_} )
+			: ( )
+		} @keys
+	};
+}
+
 #
 # check wether installed package matches
 # build options
@@ -1301,6 +1319,8 @@ sub target_suitable ($$) {
     my($iwith);
     my($k,$v);
 
+    $with = name_with($target->{name}, $with);
+
     $iwith = $target->{OPTIONS};
     while (($k,$v) = each %$with) {
         if (exists $iwith->{$k}) {
@@ -1332,10 +1352,11 @@ sub warn_about_options ($$$) {
     my($k,$v);
 
     return unless defined $iwith;
+    $with = name_with($target->{name}, $with);
     while (($k,$v) = each %$with) {
-        if (!exists $iwith->{$k} && $k !~ $c->{optreg}) {
-            print "# ATTENTION: $target->{name} ignores option '$k'\n";
-        }
+	unless ($k =~ /^$c->{optreg}$/ || exists $iwith->{$k}) {
+        	print "# ATTENTION: $target->{name} ignores option '$k'\n";
+	}
     }
 }
 
@@ -1870,7 +1891,7 @@ sub make_defines ($$$$$) {
 sub print_list1 ($$$@$) {
     my($list,$c,$uncond,$with,$ignore) = @_;
     my($spkg,$bpkg,$ppkg);
-    my($opt);
+    my($mywith, $opt);
     my($cmd1, $cmd2, $mark);
 
     $mark = '::::';
@@ -1878,6 +1899,7 @@ sub print_list1 ($$$@$) {
     foreach (@$list) {
         $spkg = $_->{href};
         $bpkg = target2rpm($_, $c);
+	$mywith = name_with($_->{name},$with);
 
         #
         # rebuild binary package IF
@@ -1890,9 +1912,9 @@ sub print_list1 ($$$@$) {
         #
         $cmd1 = undef;
         if ($uncond || $_->{REBUILD} || !-f $bpkg ||
-            !target_suitable(binary_target($_, $bpkg),$with)) {
+            !target_suitable(binary_target($_, $bpkg),$mywith)) {
 
-            $opt = make_defines($_->{OPTIONS}, $with,
+            $opt = make_defines($_->{OPTIONS}, $mywith,
                                 $_->{DEFOPTS}, $c,
                                 $_->{GOAL});
 
@@ -2115,8 +2137,7 @@ $env = {
     sourceonly => ($opt_u ||
                    $opt_U ||
                    $opt_z ||
-                   $opt_Z ||
-                   scalar(%with) > 0 )
+                   $opt_Z)
 };
 
 if ($opt_L) {

+ 2 - 2
openpkg-tool/openpkg-tool.spec

@@ -32,8 +32,8 @@ Packager:     The OpenPKG Project
 Distribution: OpenPKG [PLUS]
 Group:        Bootstrapping
 License:      GPL
-Version:      20030403
-Release:      20030403
+Version:      20030424
+Release:      20030424
 
 #   list of sources
 Source0:      openpkg.sh

+ 8 - 5
openpkg-tool/openpkg.pod

@@ -75,7 +75,7 @@ B<build>
 =head1 DESCRIPTION
 
 B<openpkg> is a frontend utility for maintaining an B<OpenPKG> instance.
-It currenty provides indexing of RPM files (B<openpkg index>) and
+It currently provides indexing of RPM files (B<openpkg index>) and
 automated recursive from-scratch installation and updating of existing
 RPM packages (B<openpkg build>).
 
@@ -312,13 +312,16 @@ are matched.
 
 =item B<-D>I<var>=I<val>
 
-Specify configuration options for all selected packages. This can be
-either B<-D>C<with_>I<xxx>C<=>I<yyy> or just B<-D>C<with_>I<xxx>, the
-latter is equivalent to a B<-D>C<with_>I<xxx>C<=>C<yes>. The parameters
+Specify configuration options for selected packages. This can be
+either B<-D>I<with_xxx>=I<yyy> or just B<-D>I<with_xxx>, the
+latter is equivalent to a B<-D>I<with_xxx>=I<yes>. The parameters
 are matched against selected packages that are already installed. If
-they do indicate a change the package is rebuild. There can be multiple
+they do indicate a change, the package is rebuild. There can be multiple
 B<-D> options.
 
+If the option name is prefixed with a package name followed by two colons
+then it applies only to the specified package. E.g. B<-D>I<gcc::with_binutils>.
+
 =item B<-E> I<name>
 
 Ignore a package with the specified I<name>. This can be used to avoid