Kaynağa Gözat

allow for global options used by l_tool_locate macro parse empty Options: list from description

Michael van Elst 23 yıl önce
ebeveyn
işleme
b560b7d4f4
2 değiştirilmiş dosya ile 25 ekleme ve 19 silme
  1. 23 17
      openpkg-tool/openpkg-build.pl
  2. 2 2
      openpkg-tool/openpkg-tool.spec

+ 23 - 17
openpkg-tool/openpkg-build.pl

@@ -226,7 +226,7 @@ sub vsn ($) {
 
 sub get_config ()
 {
-    my($c,@q);
+    my($c,@q,@g);
 
     $c = `$RPM_NPRIV --eval '%{_rpmdir} %{_rpmfilename} %{_target_os} %{_target_cpu} %{_target_platform} %{_prefix}'`;
     chomp($c);
@@ -235,11 +235,16 @@ sub get_config ()
     $q[1] =~ s/%{OS}/$q[2]/;
     $q[1] =~ s/%{ARCH}/$q[3]/;
 
+
+    $c = `$RPM_NPRIV --showrc`;
+    @g = $c =~ /\%\{l_tool_locate\s+([^\s\}]+)/g;
+
     return {
         rpmdir   => $q[0],
         template => $q[1],
         platform => $q[4],
-        prefix   => $q[5]
+        prefix   => $q[5],
+        optreg   => '(?:'.join('|', map { "\Qwith_$_\E" } @g).')'
         };
 }
 
@@ -335,16 +340,16 @@ sub get_revdep ($) {
 
 sub parse_options ($) {
     my($l) = @_;
-    $l = [ split(/\n+/, $l) ] unless ref $l;
-    my(%with) = map { /--define\s*'(\S+)\s+(\S+?)'/ } @$l;
-    return unless %with;
+    $l = join("\n",@$l) if ref $l;
+    return unless $l =~ s/.*Options://;
+    my(%with) = $l =~ /--define\s*'(\S+)\s+(\S+?)'/g;
     return \%with;
 }
 
-sub override_options ($$) {
-    my($old, $new) = @_;
+sub override_options ($$$) {
+    my($old, $new, $reg) = @_;
     while (my ($k,$v) = each %$new) {
-        $old->{$k} = $v if exists $old->{$k};
+        $old->{$k} = $v if exists $old->{$k} || $k =~ /^$reg$/;
     }
 }
 
@@ -834,14 +839,14 @@ sub target_suitable ($$) {
 #
 # report options that are not used for 
 #
-sub warn_about_options ($$) {
-    my($target, $with) = @_;
+sub warn_about_options ($$$) {
+    my($target, $with, $c) = @_;
     my($iwith) = $target->{OPTIONS};
     my($k,$v);
 
     return unless defined $iwith;
     while (($k,$v) = each %$with) {
-        if (!exists $iwith->{$k}) {
+        if (!exists $iwith->{$k} && $k !~ $c->{optreg}) {
             print "# ATTENTION: $target->{name} ignores option '$k'\n";
         }
     }
@@ -936,7 +941,8 @@ sub make_dep ($$$$$) {
             return;
         }
         # use options from installed base
-        override_options($target->{OPTIONS}, $t->{OPTIONS});
+        override_options($target->{OPTIONS}, $t->{OPTIONS},
+                         $env->{config}->{optreg});
         # remember this is a rebuild for a proxy package
         $target->{PROXY} = $t->{PROXY};
         $target->{REBUILD} = 1;
@@ -1080,7 +1086,7 @@ sub build_list ($$) {
 
         die "FATAL: no known source found for '$name'\n" unless $t;
 
-        warn_about_options($t, $env->{with});
+        warn_about_options($t, $env->{with}, $env->{config});
         push(@goals, $t);
     }
     return unless @goals;
@@ -1134,8 +1140,8 @@ sub find_proxy ($$) {
     return (glob("$prefix/RPM/PKG/$bpkg"))[0];
 }
 
-sub make_defines ($$) {
-    my($old, $new) = @_;
+sub make_defines ($$$) {
+    my($old, $new, $c) = @_;
     my($with);
 
     #
@@ -1148,7 +1154,7 @@ sub make_defines ($$) {
     #
     if ($old) {
         $old = { %$old };
-        override_options($old, $new);
+        override_options($old, $new, $c->{optreg});
     } else {
         $old = $new;
     }
@@ -1189,7 +1195,7 @@ sub print_list1 ($$$@$) {
         if ($uncond || !-f $bpkg || $_->{REBUILD} ||
             !target_suitable(binary_target($_, $bpkg),$with)) {
 
-            $opt = make_defines($_->{OPTIONS}, $with);
+            $opt = make_defines($_->{OPTIONS}, $with, $c);
 
             #
             # proxy packages are rebuilt from their maste

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

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