/[linux-patches]/genpatches-2.6-misc/web/gentoo_sources_web.pm
Gentoo

Contents of /genpatches-2.6-misc/web/gentoo_sources_web.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2271 - (show annotations) (download) (as text)
Wed Feb 6 15:08:05 2013 UTC (14 months, 1 week ago) by mpagano
File MIME type: text/x-perl
File size: 7023 byte(s)
Updates to fix web page creation
1 # Copyright 2000-2009 Gentoo Foundation; Distributed under the GPL v2
2
3 # Detect which svn server and username to use
4 # (broken with >=svn-1.7 due to an extra line added to svn info)
5 # $subversion_scheme = `svn info 2>/dev/null | head -n 2 | tail -n 1`;
6 $subversion_scheme = `svn info 2>/dev/null | grep "^URL"`;
7 $subversion_uri = $subversion_scheme;
8 chomp $subversion_uri;
9 $subversion_scheme =~ s|^URL: ([a-z][a-z0-9+-.]*)://.*|\1|s;
10
11 if ($subversion_scheme == "svn+ssh") {
12 $trimmed = substr($subversion_uri, 15);
13 if ($trimmed =~ m/^([a-zA-Z]+)@/) {
14 $subversion_midpart = "$1\@svn.gentoo.org/var/svnroot";
15 } else {
16 # couldn't detect username
17 $subversion_midpart = 'svn.gentoo.org/var/svnroot';
18 }
19 } else {
20 $subversion_midpart = 'anonsvn.gentoo.org';
21 }
22 $subversion_root = $subversion_scheme.'://'.$subversion_midpart.'/linux-patches/genpatches-2.6';
23
24 $webscript_path = &Cwd::cwd();
25 $output_path = $webscript_path.'/output';
26
27 $website_base = 'http://dev.gentoo.org/~mpagano/genpatches';
28
29 $ebuild_base = '/usr/local/gentoo-x86'; # /usr/portage
30 @kernels = ('sys-kernel/ck-sources','sys-kernel/gentoo-sources','sys-kernel/hardened-sources','sys-kernel/openvz-sources','sys-kernel/xen-sources','sys-kernel/tuxonice-sources','sys-kernel/usermode-sources','sys-kernel/vserver-sources','sys-kernel/zen-sources');
31
32 sub html_header {
33 local *FD = shift;
34 my $title = shift;
35 $title = 'genpatches infopage' if !$title;
36
37 print FD '<html>';
38 print FD '<head>';
39 print FD '<title>'.$title.'</title>';
40 print FD '<link rel="stylesheet" href="style.css" />';
41 print FD '</head>';
42 print FD '<body>';
43 print FD '<div class="menu">';
44 print FD '<span class="menu"><a href="index.htm">Home</a></span>';
45 print FD '<span class="menu"><a href="about.htm">About</a></span>';
46 print FD '<span class="menu"><a href="faq.htm">FAQ</a></span>';
47 print FD '<span class="menu"><a href="releases.htm">Releases</a></span>';
48 print FD '<span class="menu"><a href="bugs.htm">Bugs</a></span>';
49 print FD '<span class="menu"><a href="issues.htm">Issues</a></span>';
50 print FD '</div>'
51 }
52
53 sub html_footer {
54 local *FD = shift;
55 my $date = `date`;
56 my $user = `whoami`;
57
58 print FD '<hr /><div align="right">Automatically generated: '.$date.' by '.$user.'</div>';
59 print FD '</body>';
60 print FD '</html>';
61 }
62
63 # From CGI::MxScreen
64 sub html_escape {
65 my $t = shift;
66 $t =~ s/&/&amp;/g;
67 $t =~ s/\"/&quot;/g;
68 $t =~ s/>/&gt;/g;
69 $t =~ s/</&lt;/g;
70 return $t;
71 }
72
73 # Shamelessly stolen from irc2html
74 # irc2html.pl --- converts raw IRC logs to a readable HTML table-ized form.
75 # Copyright 1998, 1999, 2000, 2002, 2003, 2004 Jamie Zawinski <jwz@jwz.org>
76 sub html_urlify {
77 my $str = shift;
78 my $url_re = q{\b(s?https?|ftp|file|gopher|s?news|telnet|mailbox):} .
79 q{(//[-A-Z0-9_.]+:\d*)?} .
80 q{[-A-Z0-9_=?\#\$\@~\`%&*+|\/.,;\240]+};
81 $str =~ s@($url_re)@<A HREF="$1">$1</A>@gi;
82 return $str;
83 }
84
85 sub issues_get_questions {
86 my $file = shift;
87 my $out;
88 local *ISSUES;
89
90 open(ISSUES, '< '.$file);
91 foreach (<ISSUES>) {
92 chomp;
93 last if $_ eq '--';
94 $out .= $_ . "\n";
95 }
96 close(ISSUES);
97 return $out;
98 }
99
100 sub issues_get_answers {
101 my $file = shift;
102 my ($out, $ddcount);
103 local *ISSUES;
104 $ddcount = 0;
105
106 open(ISSUES, '< '.$file);
107 foreach (<ISSUES>) {
108 chomp;
109 if ($_ eq '--') {
110 $ddcount++;
111 next;
112 }
113 $out .= $_ . "\n" if $ddcount == 1;
114 }
115 close(ISSUES);
116 return $out;
117 }
118
119 sub issues_get_info {
120 my $file = shift;
121 my ($out, $ddcount);
122 local *ISSUES;
123 $ddcount = 0;
124
125 open(ISSUES, '< '.$file);
126 foreach (<ISSUES>) {
127 chomp;
128 if ($_ eq '--') {
129 $ddcount++;
130 next;
131 }
132 if ($ddcount == 2) {
133 if ($_ =~ /^#([0-9]+)$/) {
134 $out .= '<a href="http://bugs.gentoo.org/'.$1.'">Bug '.$1.'</a>' . "\n";
135 } elsif ($_ =~ /^[0-9]{8}/) {
136 $out .= "Date: $_\n";
137 } elsif ($_ =~ /^[0-9]\.[0-9]\.[0-9]$/) {
138 $out .= "Kernel: $_\n";
139 }
140 }
141 }
142 close(ISSUES);
143 return $out;
144 }
145
146 sub nl2br {
147 my $content = shift;
148 $content =~ s/\n/<br \/>/g;
149 return $content;
150 }
151
152 sub include_content {
153 local *FD = shift;
154 my $page = shift;
155 local *CONTENT;
156
157 open(CONTENT, '< '.$webscript_path.'/content/'.$page.'.htm');
158 print FD $_ foreach <CONTENT>;
159 close(CONTENT);
160 }
161
162 sub include_generated {
163 local *FD = shift;
164 my $page = shift;
165 local *CONTENT;
166
167 open(CONTENT, '< '.$webscript_path.'/generated/'.$page);
168 print FD $_ foreach <CONTENT>;
169 close(CONTENT);
170 }
171
172 sub include_faq {
173 local *FD = shift;
174 my $page = shift;
175 local *CONTENT;
176 my $i;
177
178 open(CONTENT, '< '.$webscript_path.'/content/faq/'.$page);
179 $i = 0;
180 foreach (<CONTENT>) {
181 if ($i++ == 0) {
182 print FD '<b>Q. '.$_.'</b><br />';
183 } else {
184 print FD $_ . '<br />';
185 }
186 }
187 close(CONTENT);
188 print FD '<br /><br />';
189 }
190
191 sub _get_patch_list {
192 my $tag = shift;
193 my $cmd = 'svn cat '.$subversion_root.'/tags/'.$tag.'/0000_README';
194 my @readme_lines = `$cmd`;
195 my @patches;
196 my $count = -1;
197
198 foreach (@readme_lines) {
199 chomp;
200
201 if (/^[Pp]atch:[ \t]+(.*)$/) {
202 $count++;
203 $patches[$count]{'patch'} = $1;
204 }
205
206 if (/^[Ff]rom:[ \t]+(.*)$/) {
207 $patches[$count]{'from'} = $1;
208 }
209
210 if (/^[Dd]esc:[ \t]+(.*)$/) {
211 $patches[$count]{'desc'} = $1;
212 }
213 }
214
215 return @patches;
216 }
217
218 sub _parse_log {
219 my $tag = shift;
220 my $lastrev = shift;
221 my (@commits, $state, $rev);
222 my $cmd = 'svn log -v -r '.$lastrev.':HEAD '.$subversion_root.'/tags/'.$tag;
223 my @loglines = `$cmd`;
224
225 foreach (@loglines) {
226 if (/^-+$/) {
227 $state = '';
228 next;
229 }
230
231 if ($state eq 'wantpaths') {
232 if (/^\s+([A-Z]) \/genpatches-2\.6\/trunk\/[\d\.]+\/([^\s]+)/) {
233 push (@{$commits[$rev]{"action$1"}}, $2) if $2 != "0000_README";
234 } elsif (/^$/) {
235 $state = 'wantlog';
236 }
237 next;
238 }
239
240 if ($state eq 'wantlog') {
241 $commits[$rev]{'logmsg'} .= "\n$_";
242 next;
243 }
244
245 if (/^r(\d+) \| (\w+) \|/) {
246 $state = 'wantpaths';
247 $rev = $1;
248 $commits[$rev]{'rev'} = $rev;
249 $commits[$rev]{'author'} = $2;
250 next;
251 }
252 }
253
254 return @commits;
255 }
256
257 sub release_is_generated {
258 my $tag = shift;
259 return -e $webscript_path.'/generated/'.$tag.'-patches.htm' &&
260 -e $webscript_path.'/generated/'.$tag.'-info.htm';
261 }
262
263 sub _get_genpatches_kernels {
264 my (%gp_kernels, $kernel);
265
266 foreach $kernel (@kernels) {
267 $kernel =~ m/^([a-z-]+)\/([a-z0-9-]+)$/;
268 my $cat = $1;
269 my $pkg = $2;
270 $cmd = 'egrep "^(K_GENPATCHES_VER|K_WANT_GENPATCHES)" '.$ebuild_base.'/'.$kernel.'/*.ebuild';
271 my @out = `$cmd`;
272
273 foreach (@out) {
274 chomp;
275 my $res = substr($_, length($ebuild_base) + length($kernel) + 2);
276 $res =~ m/^$pkg-([\d\w\.-]+)\.ebuild:(.*)$/;
277 my $ver = $1;
278 my $var = $2;
279 my $ebuild = $pkg.'-'.$ver;
280
281 #$ver =~ m/^(2\.6\.\d+)/;
282 my ($major,$minor) = split(/\./, $ver);
283 my $orig_ver = $1;
284
285 if ($var =~ /^K_WANT_GENPATCHES="(.*)"$/) {
286 $gp_kernels{$ebuild}{'pkg'} = $pkg;
287 $gp_kernels{$ebuild}{'ver'} = $ver;
288 $gp_kernels{$ebuild}{'wanted'} = $1;
289 }
290 if ($var =~ /^K_GENPATCHES_VER="(\d+)"$/) {
291 #$gp_kernels{$ebuild}{'gprev'} = $orig_ver .'-'. $1;
292 $gp_kernels{$ebuild}{'gprev'} = $major . '.' . $minor .'-'. $1;
293 }
294 }
295 }
296
297 return %gp_kernels;
298 }
299
300
301 1;

  ViewVC Help
Powered by ViewVC 1.1.20