/[d-i]/trunk/manual/build/preseed.pl
ViewVC logotype

Diff of /trunk/manual/build/preseed.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 58174 by fjp, Wed Apr 8 04:43:13 2009 UTC revision 58175 by fjp, Wed Apr 8 05:41:50 2009 UTC
# Line 43  END Line 43  END
43          exit 0;          exit 0;
44  }  }
45    
46  die "Must specify release for which to generate example." if ! $opt_r;  die "Must specify release for which to generate example.\n" if ! $opt_r;
47    
48  my $xmlfile = shift;  my $xmlfile = shift;
49  die "Must specify XML file to parse!" if ! $xmlfile;  die "Must specify XML file to parse!\n" if ! $xmlfile;
50  die "Specified XML file \"$xmlfile\" not found." if ! -f $xmlfile;  die "Specified XML file \"$xmlfile\" not found.\n" if ! -f $xmlfile;
51    
52  my $arch = $opt_a ? "$opt_a" : "i386";  my $arch = $opt_a ? "$opt_a" : "i386";
53  my $release = $opt_r;  my $release = $opt_r;
# Line 62  $p = HTML::Parser->new( Line 62  $p = HTML::Parser->new(
62  # Start parsing the specified file  # Start parsing the specified file
63  $p->parse_file($xmlfile);  $p->parse_file($xmlfile);
64    
65    # Replace entities in examples
66    # FIXME: should maybe be extracted from entity definition
67    sub replace_entities {
68            my ($text) = @_;
69    
70            $text =~ s/&archive-mirror;/http.us.debian.org/;
71            $text =~ s/&releasename;/$release/;
72    
73            # Any unrecognized entities?
74            if ( $text =~ /&[^ ]+;/ ) {
75                    my ($ent) = $text =~ m/.*(&[^ ]+;).*/;
76                    die "Error: unrecognized entity '$ent'\n"
77            }
78    
79            return $text;
80    }
81    
82  # Execute when start tag is encountered  # Execute when start tag is encountered
83  sub start_rtn {  sub start_rtn {
84          my ($tagname, $text, $attr) = @_;          my ($tagname, $text, $attr) = @_;
# Line 116  sub text_rtn { Line 133  sub text_rtn {
133                  # Clean leading and trailing whitespace for titles                  # Clean leading and trailing whitespace for titles
134                  $text =~ s/^[[:space:]]*//;                  $text =~ s/^[[:space:]]*//;
135                  $text =~ s/[[:space:]]*$//;                  $text =~ s/[[:space:]]*$//;
136    
137                    $text = replace_entities($text);
138                  $tagstatus{$titletag}{'title'} = $text;                  $tagstatus{$titletag}{'title'} = $text;
139                  $settitle = 0;                  $settitle = 0;
140          }          }
# Line 136  sub text_rtn { Line 155  sub text_rtn {
155                          $text =~ s/^[[:space:]]*//;                          $text =~ s/^[[:space:]]*//;
156                  }                  }
157    
158                  # Replace entities in examples                  $text = replace_entities($text);
                 # FIXME: should maybe be extracted from entity definition  
                 $text =~ s/&archive-mirror;/http.us.debian.org/;  
   
159                  print "$text";                  print "$text";
160    
161                  $example{'first'} = 0;                  $example{'first'} = 0;
# Line 158  sub end_rtn { Line 174  sub end_rtn {
174                  my $ts = $tagstatus{$tagname}{'count'};                  my $ts = $tagstatus{$tagname}{'count'};
175                  $tagstatus{$tagname}{'count'} -= 1;                  $tagstatus{$tagname}{'count'} -= 1;
176                  print STDERR "$tagname  $tagstatus{$tagname}{'count'}\n" if $opt_d;                  print STDERR "$tagname  $tagstatus{$tagname}{'count'}\n" if $opt_d;
177                  die "Invalid XML file: negative count for tag <$tagname>!" if $tagstatus{$tagname}{'count'} < 0;                  die "Invalid XML file: negative count for tag <$tagname>!\n" if $tagstatus{$tagname}{'count'} < 0;
178    
179                  if ( exists $ignore{'tag'} ) {                  if ( exists $ignore{'tag'} ) {
180                          if ( $ignore{'tag'} eq $tagname && $ignore{'depth'} == $ts ) {                          if ( $ignore{'tag'} eq $tagname && $ignore{'depth'} == $ts ) {

Legend:
Removed from v.58174  
changed lines
  Added in v.58175

  ViewVC Help
Powered by ViewVC 1.1.5