Update to firefox-78.10.0 in svn
[beyond_linux_from_scratch.git] / scripts / blfs-chapter37.php
blob278477298937b4fc3658397e29b8744a19094895
1 #! /usr/bin/php
2 <?php
4 include 'blfs-include.php';
6 $CHAPTER = '37';
7 $CHAPTERS = 'Chapters 37-38';
8 $START_PACKAGE = 'libxfce4util';
9 $STOP_PACKAGE = 'lxterminal';
11 $renames = array();
12 $renames[ 'libfm' ] = 'libfm-extra';
13 $renames[ 'libfm1' ] = 'libfm';
15 $ignores = array();
16 //$renames[ 'libfm1' ] = '';
18 $regex = array();
19 //$regex[ 'libfm' ] = "/^.*Download libfm-([\d\.]+).tar.*$/";
21 //$current="obconf-qt";
23 $url_fix = array (
25 array( 'pkg' => 'gpicview',
26 'match' => '^.*$',
27 'replace' =>
28 "https://sourceforge.net/projects/lxde/files/GPicView%20%28image%20Viewer%29/0.2.x"),
30 array( 'pkg' => 'xfce4-pulseaudio-plugin',
31 'match' => '^.*$',
32 'replace' => "https://gitlab.xfce.org/panel-plugins/xfce4-pulseaudio-plugin/-/tags/"),
34 array( 'pkg' => 'lxappearance',
35 'match' => '^.*$',
36 'replace' => "https://sourceforge.net/projects/lxde/files/LXAppearance"),
38 array( 'pkg' => 'lxappearance-obconf',
39 'match' => '^.*$',
40 'replace' => "https://sourceforge.net/projects/lxde/files/LXAppearance%20Obconf/"),
42 array( 'pkg' => 'lxde-common',
43 'match' => '^.*$',
44 'replace' => "https://sourceforge.net/projects/lxde/files/lxde-common%20%28default%20config%29"),
46 array( 'pkg' => 'lxinput',
47 'match' => '^.*$',
48 'replace' => "https://sourceforge.net/projects/lxde/files/LXInput%20%28Kbd%20and%20amp_%20mouse%20config%29"),
50 array( 'pkg' => 'lxrandr',
51 'match' => '^.*$',
52 'replace' => "https://sourceforge.net/projects/lxde/files/LXRandR%20%28monitor%20config%20tool%29"),
54 array( 'pkg' => 'lxtask',
55 'match' => '^.*$',
56 'replace' =>
57 "https://sourceforge.net/projects/lxde/files/LXTask%20%28task%20manager%29"),
59 array( 'pkg' => 'lxterminal',
60 'match' => '^.*$',
61 'replace' =>
62 "https://sourceforge.net/projects/lxde/files/LXTerminal%20%28terminal%20emulator%29"),
64 array( 'pkg' => 'lxsession',
65 'match' => '^.*$',
66 'replace' =>
67 "https://sourceforge.net/projects/lxde/files/LXSession%20%28session%20manager%29"),
69 array( 'pkg' => 'lxmenu-data',
70 'match' => '^.*$',
71 'replace' =>
72 "https://sourceforge.net/projects/lxde/files/lxmenu-data%20%28desktop%20menu%29"),
74 array( 'pkg' => 'libfm',
75 'match' => '^.*$',
76 'replace' => "https://sourceforge.net/projects/pcmanfm/files" ),
78 array( 'pkg' => 'libfm1',
79 'match' => '^.*$',
80 'replace' => "https://sourceforge.net/projects/pcmanfm/files" ),
82 array( 'pkg' => 'menu-cache',
83 'match' => '^.*$',
84 'replace' => "https://sourceforge.net/projects/lxde/files/menu-cache" ),
86 array( 'pkg' => 'lxpanel',
87 'match' => '^.*$',
88 'replace' =>
89 "https://sourceforge.net/projects/lxde/files/LXPanel%20%28desktop%20panel%29" ),
91 array( 'pkg' => 'pcmanfm',
92 'match' => '^.*$',
93 'replace' => "https://sourceforge.net/projects/pcmanfm/files/PCManFM%20%2B%20Libfm%20%28tarball%20release%29/PCManFM" ),
95 array( 'pkg' => 'qtermwidget',
96 'match' => '^.*$',
97 'replace' => "https://github.com/lxde/qtermwidget/releases" ),
99 array( 'pkg' => 'qterminal',
100 'match' => '^.*$',
101 'replace' => "https://github.com/lxde/qterminal/releases" ),
103 array( 'pkg' => 'QupZilla',
104 'match' => '^.*$',
105 'replace' => "https://github.com/QupZilla/qupzilla/releases" ),
107 array( 'pkg' => 'xfce4-xkb-plugin',
108 'match' => '^.*$',
109 'replace' => "http://archive.xfce.org/src/panel-plugins/xfce4-xkb-plugin/0.7" ),
113 function get_packages( $package, $dirpath )
115 global $regex;
116 global $book_index;
117 global $url_fix;
118 global $current;
120 if ( isset( $current ) && $book_index != "$current" ) return 0;
122 // Fix up directory path
123 foreach ( $url_fix as $u )
125 $replace = $u[ 'replace' ];
126 $match = $u[ 'match' ];
128 if ( isset( $u[ 'pkg' ] ) )
130 if ( $package == $u[ 'pkg' ] )
132 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
133 break;
136 else
138 if ( preg_match( "/$match/", $dirpath ) )
140 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
141 break;
146 // Check for ftp
147 if ( preg_match( "/^ftp/", $dirpath ) )
149 // All ftp enties for this chapter
150 $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
151 $position = strrpos( $dirpath, "/" );
152 $dirpath = substr ( $dirpath, 0, $position ); // Up 1
153 $dirs = http_get_file( "$dirpath/" );
155 if ( $book_index == "libwnck" ||
156 $book_index == "gtksourceview" )
157 $dir = find_even_max( $dirs, "/ 2\./", "/^.* (2[\d\.]+)$/" );
159 else if ( $book_index == "vte" )
160 $dir = "0.28";
162 else if ( $book_index == "libunique" )
163 $dir = "1.1";
165 else
166 $dir = find_even_max( $dirs, "/^\d/", "/^([\d\.]+).*$/" );
168 $dirpath .= "/$dir/";
170 // Get listing
171 $lines = http_get_file( "$dirpath/" );
173 else if ( $book_index == "menu-cache" )
175 $dirs = http_get_file( "$dirpath/" );
176 $dir = find_max ( $dirs, "/^\s*\d/", "/^\s*(\d\.[\d\.x]+)\s+.*$/" );
177 $dirpath .= "/$dir";
178 $lines = http_get_file( "$dirpath/" );
179 $ver = find_max( $lines, "/menu-cache/", "/^.*menu-cache-([\d\.]+).tar.*/" );
180 return $ver;
182 else if ( $book_index == "libfm1" )
184 $lines = http_get_file( "$dirpath/" );
185 $ver = find_max( $lines, "/libfm/", "/^.*libfm-([\d\.]+).tar.*/" );
186 return $ver;
188 else if ( $book_index == "pcmanfm" )
190 $lines = http_get_file( "$dirpath/" );
191 $ver = find_max( $lines, "/pcmanfm/", "/^.*pcmanfm-([\d\.]+).tar.*/" );
192 return $ver;
194 else if ( $book_index == "lxappearance" )
196 $lines = http_get_file( "$dirpath/" );
197 $ver = find_max( $lines, "/lxappearance/", "/^.*lxappearance-([\d\.]+).tar.*$/" );
198 return $ver;
200 else if ( $book_index == "lxappearance-obconf" )
202 $lines = http_get_file( "$dirpath/" );
203 $ver = find_max( $lines, "/lxappearance/", "/^.*lxappearance-obconf-([\d\.]+).tar.*$/" );
204 return $ver;
206 else if ( $book_index == "lxpanel" )
208 $dirs = http_get_file( "$dirpath/" );
209 $dir = find_max ( $dirs, "/LXPanel/", "/^.*(LXPanel\s+[\d\.x]+)\s+\d.*$/" );
210 $dir = preg_replace( "/ /", '%20', $dir );
211 $dirpath .= "/$dir";
212 $lines = http_get_file( "$dirpath/" );
213 $ver = find_max( $lines, "/lxpanel/", "/^.*lxpanel-([\d\.]+).tar.*$/" );
214 return $ver;
216 else if ( $book_index == "lxinput" )
218 $dirs = http_get_file( "$dirpath/" );
219 $dir = find_max ( $dirs, "/LXInput/", "/^.*(LXInput\s*[\d\.x]+) .*$/" );
220 $dir = preg_replace( "/ /", '%20', $dir );
221 $dirpath .= "/$dir";
222 $lines = http_get_file( "$dirpath/" );
223 $ver = find_max( $lines, "/lxinput/", "/^.*lxinput-([\d\.]+).tar.*$/" );
224 return $ver;
226 else if ( $book_index == "lxrandr" )
228 $dirs = http_get_file( "$dirpath/" );
229 $dir = find_max ( $dirs, "/LXRandR/", "/^.*(LXRandR\s+[\d\.x]+).*$/" );
230 $dir = preg_replace( "/ /", '%20', $dir );
231 $dirpath .= "/$dir";
232 $lines = http_get_file( "$dirpath/" );
233 $ver = find_max( $lines, "/lxrandr/", "/^.*lxrandr-([\d\.]+).tar.*$/" );
234 return $ver;
236 else if ( $book_index == "lxtask" )
238 $dirs = http_get_file( "$dirpath/" );
239 $dir = find_max ( $dirs, "/LXTask/", "/^\s*(LXTask\s+[\d\.x]+)\s+.*$/" );
240 $dir = preg_replace( "/ /", '%20', $dir );
241 $dirpath .= "/$dir";
242 $lines = http_get_file( "$dirpath/" );
243 $ver = find_max( $lines, "/lxtask/", "/^.*lxtask-([\d\.]+).tar.*$/" );
244 return $ver;
246 else if ( $book_index == "lxterminal" )
248 $dirs = http_get_file( "$dirpath/" );
249 $dir = find_max ( $dirs, "/LXTerminal/", "/^\s*(LXTerminal\s+[\d\.x]+)\s+.*$/" );
250 $dir = preg_replace( "/ /", '%20', $dir );
251 $dirpath .= "/$dir";
252 $lines = http_get_file( "$dirpath/" );
253 $ver = find_max( $lines, "/lxterminal/", "/^.*lxterminal-([\d\.]+).tar.*$/" );
254 return $ver;
256 else if ( $book_index == "lxsession" )
258 $dirs = http_get_file( "$dirpath/" );
259 $dir = find_max ( $dirs, "/LXSession/", "/^.*(LXSession\s+[\d\.x]+)\s+.*$/" );
260 $dir = preg_replace( "/ /", '%20', $dir );
261 $dirpath .= "/$dir";
262 $lines = http_get_file( "$dirpath/" );
263 $ver = find_max( $lines, "/lxsession/", "/^.*lxsession-([\d\.]+).tar.*$/" );
264 return $ver;
266 if ( $book_index == "lxde-common" )
268 $dirs = http_get_file( "$dirpath/" );
269 $dir = find_max( $dirs, "/common/", "/^.*common ([\d\.]+\d).*$/" );
270 $dirpath .= "/lxde-common%20$dir";
271 $lines = http_get_file( "$dirpath/" );
272 $ver = find_max( $lines, "/common/", "/^.*common-([\d\.]+).tar.*$/" );
273 return $ver;
276 else if ( $book_index == "gpicview" )
278 //$dirs = http_get_file( "$dirpath/" );
279 //$dir = find_max ( $dirs, "/^\s*\d/", "/^\s*(\d\.[\d\.x]+) .*$/" );
280 //$dir = preg_replace( "/ /", '%20', $dir );
281 //$dirpath .= "/$dir";
282 $lines = http_get_file( "$dirpath/" );
283 $ver = find_max( $lines, "/gpicview/", "/^.*gpicview-([\d\.]+).tar.*$/" );
284 return $ver;
286 else if ( $book_index == "qtermwidget" )
288 $lines = http_get_file( "$dirpath/" );
289 $ver = find_max( $lines, "/qtermwidget/", "/^\s+qtermwidget-([\d\.]+).tar.*$/" );
290 return $ver;
292 else if ( $book_index == "qterminal" )
294 $lines = http_get_file( "$dirpath/" );
295 $ver = find_max( $lines, "/qterminal/", "/^\s+qterminal-([\d\.]+).tar.*$/" );
296 return $ver;
298 else if ( $book_index == "QupZilla" )
300 $lines = http_get_file( "$dirpath/" );
301 $ver = find_max( $lines, "/QupZilla/", "/^\s+QupZilla-([\d\.]+).tar.*$/" );
302 return $ver;
304 else if ( $book_index == "xfce4-pulseaudio-plugin" )
306 $lines = http_get_file( "$dirpath" );
307 $ver = find_max( $lines, "/xfce4-pulseaudio-plugin/",
308 "/^.*xfce4-pulseaudio-plugin-([\d\.]+).*$/" );
309 return $ver;
311 else if ( $book_index != "lxmenu-data" &&
312 $book_index != "libfm" &&
313 $book_index != "libfm1" &&
314 $book_index != "vte" &&
315 $book_index != "libwnck" &&
316 $book_index != "xfce4-xkb-plugin" ) // http
318 // Most http enties for this chapter
319 $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
320 $position = strrpos( $dirpath, "/" );
321 $dirpath = substr ( $dirpath, 0, $position ); // Up 1
322 $dirs = http_get_file( "$dirpath/" );
324 if ( ( preg_match( "/xf/", $package ) ||
325 preg_match( "/exo/", $package )
326 ) &&
327 $book_index != "xfburn"
329 $dir = find_even_max( $dirs, "/^\d/", "/^([\d\.]+)\/.*$/" );
330 else
331 $dir = find_max ( $dirs, "/^\d/", "/^([\d\.]+)\/.*$/" );
333 $dirpath .= "/$dir";
334 $lines = http_get_file( "$dirpath/" );
336 if ( ! is_array( $lines ) ) return $lines;
337 } // End fetch
339 // Others
340 else
342 $lines = http_get_file( "$dirpath/" );
345 if ( isset( $regex[ $package ] ) )
347 // Custom search for latest package name
348 foreach ( $lines as $l )
350 if ( preg_match( '/^\h*$/', $l ) ) continue;
351 $ver = preg_replace( $regex[ $package ], "$1", $l );
353 if ( $ver == $l ) continue;
355 return $ver; // Return first match of regex
358 return 0; // This is an error
361 if ( $book_index == "lxpanel" )
363 $ver = find_max( $lines, "/LXPanel/", "/^.*LXPanel ([\d\.]+\d).*$/" );
364 return $ver;
367 if ( $book_index == "lxde-icon-theme" )
368 return find_max( $lines, "/$package/", "/^.*$package-([\d\.]*\d).*$/" );
370 if ( $book_index == "xfce4-terminal" ||
371 $book_index == "tumbler" )
372 return find_max( $lines, "/$package/", "/^.*$package-([\d\.]*\d).*$/", TRUE );
374 // Most packages are in the form $package-n.n.n
375 // Occasionally there are dashes (e.g. 201-1)
376 return find_max( $lines, "/$package/", "/^.*$package-([\d\.]*\d)\.tar.*$/" );
379 function get_pattern( $line )
381 // Set up specific patter matches for extracting book versions
382 $match = array(
383 array( 'pkg' => '.*xfce',
384 'regex' => "/^.*xfce.*-(\d[\d\.]+).*$/" ),
386 array( 'pkg' => 'xfwm',
387 'regex' => "/^.*xfwm4-(\d[\d\.]+).*$/" ),
390 foreach( $match as $m )
392 $pkg = $m[ 'pkg' ];
393 if ( preg_match( "/$pkg/", $line ) )
394 return $m[ 'regex' ];
397 return "/\D*(\d.*\d)\D*$/";
400 get_current(); // Get what is in the book
402 // Get latest version for each package
403 foreach ( $book as $pkg => $data )
405 $book_index = $pkg;
407 $base = $data[ 'basename' ];
408 $url = $data[ 'url' ];
409 $bver = $data[ 'version' ];
411 echo "book index: $book_index $bver $url\n";
413 $v = get_packages( $book_index, $url );
414 $vers[ $book_index ] = $v;
417 html(); // Write html output