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 openpkg-web Date: 31-Dec-2002 16:12:40 Branch: HEAD Handle: 2002123115123801 Modified files: openpkg-src/openpkg-tool openpkg-build.pl openpkg-index.pl openpkg-tool.spec openpkg-web news.txt Log: added Options to Index, various compatibility hacks Summary: Revision Changes Path 1.21 +57 -4 openpkg-src/openpkg-tool/openpkg-build.pl 1.6 +116 -19 openpkg-src/openpkg-tool/openpkg-index.pl 1.15 +2 -2 openpkg-src/openpkg-tool/openpkg-tool.spec 1.2479 +1 -0 openpkg-web/news.txt ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-src/openpkg-tool/openpkg-build.pl ============================================================================ $ cvs diff -u -r1.20 -r1.21 openpkg-build.pl --- openpkg-src/openpkg-tool/openpkg-build.pl 30 Dec 2002 22:21:39 -0000 1.20 +++ openpkg-src/openpkg-tool/openpkg-build.pl 31 Dec 2002 15:12:39 -0000 1.21 @@ -153,6 +153,25 @@ return \@out; } +sub make_hash ($$$) { + my($bags,$tag,$with) = @_; + my($bag,$li); + my(%out,$el); + + foreach $bag (@$bags) { + next unless conditional($bag->{'cond'}, $with); + foreach $li (@{$bag->{'rdf:bag'}}) { + foreach (@{$li->{'rdf:li'}}) { + next unless exists $_->{$tag}; + $el = $_->{$tag}->[0]; + $out{$el->{'ID'}} = $el->{'content'}; + } + } + } + + return \%out; +} + ########################################################################## my($RPM,$RPM_PRIV,$RPM_NPRIV,$CURL,$PROG); @@ -353,6 +372,9 @@ return \%rev; } +# +# parse option from rpm output +# sub parse_options ($) { my($l) = @_; $l = join("\n", @$l) if ref $l; @@ -363,6 +385,11 @@ return $with; } +# +# copy options from new to old +# where option already exists in old or option key +# matches regular expression +# sub override_options ($$$) { my($old, $new, $reg) = @_; @@ -464,6 +491,7 @@ my($href,$release,$desc); my(@prereq,@bprereq); my(@provides,@conflicts); + my(%options); my($platform,$prefix); my($rec); my($tag,$cond,$body); @@ -495,7 +523,16 @@ next unless defined $href; - ($tag,$cond,$body) = /<(\/?[\w:]+)\s*(?:cond="([^"]+)")?>([^<]*)/; + ($tag,$cond,$body) = / + < + ([\w:]+) + \s* + (?:cond="([^"]+)")? + > + (.*?) + <\/\1> + $ + /mx; $useit = conditional($cond,$with); @@ -505,6 +542,10 @@ $section = undef; } elsif ($section eq 'description') { $desc .= $_; + } elsif ($tag eq 'Options') { + $section = 'options' if $useit; + } elsif ($tag eq '/Options') { + $section = undef; } elsif ($tag eq 'PreReq') { $section = 'prereq' if $useit; } elsif ($tag eq '/PreReq') { @@ -532,7 +573,11 @@ } elsif ($tag eq 'Prefixes') { $prefix = $body; } elsif ($tag eq 'rdf:li') { - if ($section eq 'prereq') { + if ($section eq 'options') { + if ($body =~ /<.*?ID="([^"]+)".*?>\s*([^<]+?)\s*</) { + $options{$1} = $2; + } + } elsif ($section eq 'prereq') { push(@prereq, $body); } elsif ($section eq 'bprereq') { push(@bprereq, $body); @@ -577,7 +622,11 @@ platform => $platform, prefix => $prefix }; - $rec->{OPTIONS} = parse_options($rec->{desc}); + + $rec->{OPTIONS} = + %options + ? \%options + : parse_options($rec->{desc}); foreach (@provides) { push(@{$map{$_->{name}}->{vs($_)}}, $rec); @@ -640,7 +689,11 @@ conflicts => with_list($_->{'Conflicts'}, $with), desc => xel($_->{'Description'}) }; - $rec->{OPTIONS} = parse_options($rec->{desc}); + + $rec->{OPTIONS} = + exists $_->{'Options'} + ? make_hash($_->{'Options'}, 'Option', $with) + : parse_options($rec->{desc}); foreach (@provides) { push(@{$map{$_->{name}}->{vs($_)}}, $rec); @@ . patch -p0 <<'@@ .' Index: openpkg-src/openpkg-tool/openpkg-index.pl ============================================================================ $ cvs diff -u -r1.5 -r1.6 openpkg-index.pl --- openpkg-src/openpkg-tool/openpkg-index.pl 30 Dec 2002 22:21:39 -0000 1.5 +++ openpkg-src/openpkg-tool/openpkg-index.pl 31 Dec 2002 15:12:39 -0000 1.6 @@ -53,10 +53,10 @@ my($i); $s =~ s/\n+$//sg; - $s =~ s/\s+$//mg; + $s =~ s/[^\S\n]+$//mg; $i = undef; - while ($s =~ /^(\s+)/mg) { + while ($s =~ /^([^\S\n]+)/mg) { $i = $1 if !defined $i || length($1) < length($i); } @@ -126,15 +126,46 @@ # # deduce external variables from description # -sub find_options ($$) { - my($spec, $descr) = @_; +# before openpkg-20021230 +# +sub find_options ($) { + my($descr) = @_; my $evar = {}; - $descr =~ s/--define\s*'(\S+)\s*\%\{\1\}'/$evar->{$1} = '%{'.$1.'}', ''/sge; # before openpkg-20021230 - $spec =~ s/^%option\s+(\S+)\s+\S+/$evar->{$1} = '%{'.$1.'}', ''/mge; # after openpkg-20021230 + $descr =~ s/--define\s*'(\S+)\s*\%\{\1\}'/$evar->{$1} = '%{'.$1.'}', ''/sge; return $evar; } # +# clean up %options macro from description +# +sub clean_options ($$) { + my($descr,$evar) = @_; + my($p); + + $descr =~ s/\s*\%options.*\n//; + $descr =~ s/\n*$/\n/s; + + if (%$evar) { + + $p = 0; + foreach (keys %$evar) { + $p = length($_) if length($_) > $p; + } + + $descr .= "\n" . join '', map { + sprintf( + " %%option %s %s\n", + $_.' 'x($p-length($_)), + $evar->{$_} + ) + } sort keys %$evar; + + } + + return $descr; +} + +# # translate default section from spec-file # into a hash # %if/%ifdef/%define... are translated to #if/#ifdef/#define @@ -148,8 +179,8 @@ # repeated attributes are coalesced into a list # sub package2data ($$) { - my($s,$evar) = @_; - my(%var); + my($s,$ovar) = @_; + my(%evar,%var); my(@term, $term); my(%attr); my($l, $v, $cond, $d, $p); @@ -165,13 +196,24 @@ $s =~ s/^#\{\!\?([^:]*):\s*(.*?)\s*\}\s*$/#ifndef $1\n$2\n#endif/mg; # + # map option macro + # + $s =~ s/^#option\s+(\S+)\s*(.*?)\s*$/#ifndef $1\n#define $1 $2\n#endif/mg; + + # + # use option variables for interpolation + # + %evar = %$ovar; + + # # guess more external parameters by scanning for "default" sections. # $re = '^\#ifndef\s+[\w\_]+\s*\n((?:\#define\s+[\w\_]+\s.*\n)+)\#endif\n'; @defs = $s =~ /$re/gm; foreach (@defs) { while (/^\#define\s+([\w\_]+)\s(.*?)\s*$/mg) { - $evar->{$1} = '%{'.$1.'}'; + $ovar->{$1} = $2; + $evar{$1} = '%{'.$1.'}'; } } $s =~ s/$re//gm; @@ -182,10 +224,11 @@ $re = '%{(with\_[\w\_]+)}'; @defs = $s =~ /$re/gm; foreach (@defs) { - $evar->{$1} = '%{'.$1.'}'; + next if exists $ovar->{$1}; + $ovar->{$1} = '%{'.$1.'}'; + $evar{$1} = '%{'.$1.'}'; } - # # extract all conditional sections # @@ -210,8 +253,8 @@ warn "WARNING: unknown token '$5':\n< $l\n> $v\n"; } elsif (defined $2) { $term .= " $2 "; - } elsif (exists $evar->{$3}) { - $term .= ($4 eq 'no' ? '! ' : '').vsub($evar,'%{'.$3.'}'); + } elsif (exists $evar{$3}) { + $term .= ($4 eq 'no' ? '! ' : '').vsub(\%evar,'%{'.$3.'}'); } else { warn "WARNING: unknown conditional '$2':\n< $l\n> $v\n"; } @@ -252,11 +295,11 @@ # define internal variables # -> store for subsequent substitution # - if (exists $evar->{$1}) { + if (exists $evar{$1}) { if ($2 eq 'yes') { - $evar->{$1} = "( \%\{$1\} || ( $cond ) )"; + $evar{$1} = "( \%\{$1\} || ( $cond ) )"; } elsif ($2 eq 'no') { - $evar->{$1} = "( %\{$1\} && ! ( $cond ) )"; + $evar{$1} = "( %\{$1\} && ! ( $cond ) )"; } else { warn "WARNING: logic too complex for '$1':\n< $l\n> $v\n"; } @@ -306,10 +349,18 @@ } } - $o = find_options($spec, $map{'description'}); - $a = package2data($map{'*'}, $o); if (exists $map{'description'}) { - $a->{'Description'} = { '' => [ $map{'description'} ] }; + $o = find_options($map{'description'}); + + $a = package2data($map{'*'}, $o ); + + $a->{'Options'} = { '' => $o }; + + $a->{'Description'} = { '' => [ + clean_options($map{'description'}, $o) + ] }; + } else { + $a = package2data($map{'*'}, {}); } return $a; @@ -399,6 +450,8 @@ # $i denotes the depth of indentation, inner tags are indented # 2 or 4 more character positions. # +# each element of the bag is listed +# sub xml_bag ($$$;$) { my($i,$a,$k,$tag) = @_; my($out,$cond,$upn); @@ -408,6 +461,7 @@ $i = ' ' x $i; foreach $cond (sort keys %{$a->{$k}}) { + next unless @{$a->{$k}->{$cond}}; $upn = e(upn($cond)); $out .= $i. ($cond ne '' ? "<$tag cond=\"$upn\">\n" : "<$tag>\n"). @@ -423,6 +477,48 @@ } # +# send out @{$a->{$k}} as a rdf:bag +# $k is the name of the outer tag unless overriden by $tag +# $i denotes the depth of indentation, inner tags are indented +# 2 or 4 more character positions. +# +# each element of the bag is a name value pair +# +sub xml_vals ($$$$$) { + my($i,$a,$k,$tags,$tag) = @_; + my($out,$cond,$upn,$map); + return "" unless exists $a->{$k}; + $out = ''; + $i = ' ' x $i; + + foreach $cond (sort keys %{$a->{$k}}) { + $map = $a->{$k}->{$cond}; + next unless %$map; + $upn = e(upn($cond)); + $out .= $i. + ($cond ne '' ? "<$tags cond=\"$upn\">\n" : "<$tags>\n"). + "$i <rdf:bag>\n". + join('', + map { + "$i <rdf:li>". + ( ( $map->{$_} =~ /^\%\{/ ) + ? "<$tag ID=\"".e($_)."\"/>" + : "<$tag ID=\"".e($_)."\">". + e($map->{$_}). + "</$tag>" + ). + "</rdf:li>\n" + } + keys %$map + ). + "$i </rdf:bag>\n". + "$i</$tags>\n"; + } + + return $out; +} + +# # send out reference to another RDF # sub xml_reference ($$$) { @@ -526,6 +622,7 @@ xml_tag(6, $a, 'SigMD5'), xml_tag(6, $a, 'SigPGP'), xml_tag(6, $a, 'SigGPG'), + xml_vals(6, $a, 'Options', 'Options', 'Option'), xml_bag(6, $a, 'BuildPreReq'), xml_bag(6, $a, 'PreReq'), xml_bag(6, $a, 'Provides'), @@ . patch -p0 <<'@@ .' Index: openpkg-src/openpkg-tool/openpkg-tool.spec ============================================================================ $ cvs diff -u -r1.14 -r1.15 openpkg-tool.spec --- openpkg-src/openpkg-tool/openpkg-tool.spec 30 Dec 2002 22:05:36 -0000 1.14 +++ openpkg-src/openpkg-tool/openpkg-tool.spec 31 Dec 2002 15:12:39 -0000 1.15 @@ -32,8 +32,8 @@ Distribution: OpenPKG [EVAL] Group: Bootstrapping License: GPL -Version: 20021230 -Release: 20021230 +Version: 20021231 +Release: 20021231 # list of sources Source0: openpkg.sh @@ . patch -p0 <<'@@ .' Index: openpkg-web/news.txt ============================================================================ $ cvs diff -u -r1.2478 -r1.2479 news.txt --- openpkg-web/news.txt 31 Dec 2002 11:24:23 -0000 1.2478 +++ openpkg-web/news.txt 31 Dec 2002 15:12:38 -0000 1.2479 @@ -1,3 +1,4 @@ +31-Dez-2002: Upgraded package: P<openpkg-tool-20021231-20021231> 31-Dec-2002: Upgraded package: P<sasl-2.1.10-20021231> 31-Dec-2002: Upgraded package: P<rdesktop-1.1.0.19.9.0-20021231> 31-Dec-2002: Upgraded package: P<curl-7.10.2-20021231> @@ . ______________________________________________________________________ The OpenPKG Project www.openpkg.org CVS Repository Commit List [EMAIL PROTECTED]