OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Michael van Elst Root: /e/openpkg/cvs Email: [EMAIL PROTECTED] Module: openpkg-src Date: 04-Feb-2003 13:02:50 Branch: HEAD Handle: 2003020412025000 Modified files: openpkg-src/openpkg-tool openpkg-build.pl Log: code cleanup, no more guessing about default options Summary: Revision Changes Path 1.50 +17 -38 openpkg-src/openpkg-tool/openpkg-build.pl ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-src/openpkg-tool/openpkg-build.pl ============================================================================ $ cvs diff -u -r1.49 -r1.50 openpkg-build.pl --- openpkg-src/openpkg-tool/openpkg-build.pl 4 Feb 2003 11:26:56 -0000 1.49 +++ openpkg-src/openpkg-tool/openpkg-build.pl 4 Feb 2003 12:02:50 -0000 1.50 @@ -529,7 +529,7 @@ sub parse_options ($) { my($l) = @_; $l = join("\n", @$l) if ref $l; - return if ($l !~ m/(--define|\%option\s+)/s); + return {} if ($l !~ m/(--define|\%option\s+)/s); my $with = {}; $l =~ s/--define\s*'(\S+)\s+(\S+?)'/$with->{$1} = $2, ''/sge; # before openpkg-20021230 $l =~ s/\%option\s+(\S+)\s+(\S+)/$with->{$1} = $2, ''/sge; # after openpkg-20021230 @@ -541,20 +541,14 @@ # where option already exists in old or option key # matches regular expression # -# return true if anything was actually changed or augmented -# sub override_options ($$$) { my($old, $new, $reg) = @_; - my($rc); foreach my $k (keys %$new) { if ((exists $old->{$k} && $old->{$k} ne $new->{$k}) || $k =~ /^$reg$/) { $old->{$k} = $new->{$k}; - $rc = 1; } } - - return $rc; } # @@ -869,7 +863,8 @@ desc => $desc, platform => $platform, prefix => $prefix, - OPTIONS => $options + OPTIONS => $options, + DEFOPTS => { %$options } }; foreach (@provides) { @@ -964,7 +959,8 @@ source => xwith($_->{'Source'}, $mywith), nosource => xwith($_->{'NoSource'}, $mywith), desc => $desc, - OPTIONS => $options + OPTIONS => $options, + DEFOPTS => { %$options } }; foreach (@provides) { @@ -1775,46 +1771,29 @@ # suitable for rpm # sub make_defines ($$$$) { - my($old, $new, $c, $rebuild) = @_; + my($old, $new, $def, $c) = @_; my($with); + $old = {} unless $old; + $def = {} unless $def; + # # override old parameters with new parameters # drop new parameters that do not exist in old set # - # if there is no old set at all (which happens if there - # is no template and no installed package), just use the - # new parameters and assume these are useful. - # - if ($old) { - $old = { %$old }; - if (!override_options($old, $new, $c->{optreg})) { - # - # nothing was changed against previous options - # - # if $rebuild is true this is an already installed - # target and 'previous options' may be different - # from the package defaults - # - # but if $rebuild is false this is a package from - # repository, it must be package defaults and we - # can drop the --defines from the script - # - if (!$rebuild) { - return ''; - } - } - } else { - $old = $new; - } + $old = { %$old }; + override_options($old, $new, $c->{optreg}); # # convert parameters to --define command line options # skip parameter templates from index + # skip parameters that are identical to defaults # $with = join(' ',map { "--define '$_ $old->{$_}'" } - sort grep { $old->{$_} =~ /\S/ && - $old->{$_} !~ /^%/ + sort grep { + $old->{$_} =~ /\S/ && + $old->{$_} !~ /^%/ && + $old->{$_} ne $def->{$_} } keys %$old); $with = ' '.$with if $with ne ''; @@ -1854,7 +1833,7 @@ if ($uncond || !-f $bpkg || !target_suitable(binary_target($_, $bpkg),$with)) { - $opt = make_defines($_->{OPTIONS}, $with, $c, $_->{REBUILD}); + $opt = make_defines($_->{OPTIONS}, $with, $_->{DEFOPTS}, $c); # # proxy packages are rebuilt from their maste @@ . ______________________________________________________________________ The OpenPKG Project www.openpkg.org CVS Repository Commit List [EMAIL PROTECTED]