slitaz-forge view mirror/floppies/builder/index.php @ rev 366

mirror/floppies: updates from web site, add loram for 1.0 & 2.0
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu May 09 18:16:08 2013 +0200 (2013-05-09)
parents 41bfd0397973
children a33dea8a7991
line source
1 <?php
2 if (false) { // no php support on this mirror !
3 ?>
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
7 <head>
8 <title>SliTaz Boot Floppies redirection</title>
9 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
10 <meta name="description" content="slitaz boot floppies builder redirection" />
11 <meta name="robots" content="index, nofollow" />
12 <meta name="author" content="SliTaz Contributors" />
13 <meta http-equiv="Refresh" content="0;url=http://mirror.slitaz.org/floppies/builder/index.php">
14 </head>
15 </html>
16 <?php
17 }
18 ini_set('upload_max_filesize','16M');
19 ini_set('post_max_size','16M');
20 if (isset($_GET['id']) && is_file("/tmp/".$_GET['id']."/fd")) {
22 // Download a floppy image
24 $size = $_GET['s'];
25 if ($size == 0)
26 $size = filesize("/tmp/".$_GET['id']."/fd");
27 header("Content-Type: application/octet-stream");
28 header("Content-Length: ".$size);
29 header("Content-Disposition: attachment; filename=".
30 sprintf("fd%03d.img",$_GET['n']));
31 $cmd = "cat /tmp/".$_GET['id']."/fd";
32 if ($_GET['s'] != 0) {
33 $cmd .= " /dev/zero | dd count=1 bs=".$_GET['s'];
34 if ($_GET['n'] > 1)
35 $cmd .= " skip=".($_GET['n']-1);
36 }
37 echo `$cmd 2> /dev/null`;
38 exit;
39 }
40 ?>
41 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
42 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
43 <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
44 <head>
45 <title>SliTaz Boot Floppies</title>
46 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
47 <meta name="description" content="slitaz boot floppies builder" />
48 <meta name="robots" content="index, nofollow" />
49 <meta name="author" content="SliTaz Contributors" />
50 <link rel="shortcut icon" href="../static/favicon.ico" />
51 <link rel="stylesheet" type="text/css" href="../static/slitaz.css" />
52 <style type="text/css">
54 input[type=text] {
55 width: inherit;
56 }
58 #content {
59 margin: 6px 280px 0px 0px;
60 padding: 0px 3% 20px 4%;
61 }
63 #nav {
64 right: 4%;
65 }
67 #copy {
68 text-align: center;
69 }
71 #bottom {
72 text-align: center;
73 }
75 </style>
76 </head>
77 <body bgcolor="#ffffff">
78 <!-- Header -->
79 <div id="header">
80 <a name="top"></a>
81 <div id="logo"></div>
82 <div id="network">
83 <a href="http://www.slitaz.org/">
84 <img src="../static/home.png" alt="[ home ]" /></a>
85 <a href="bootloader" title="Build your floppy sets without Internet">Shell builder</a> |
86 <a href="../floppy-grub4dos" title="Boot tools">Generic boot floppy</a>
87 </div>
88 <h1><a href="http://www.slitaz.org/">Boot floppies builder</a></h1>
89 </div>
91 <!-- Navigation menu -->
92 <div id="nav">
94 <?php
96 // Cleanup old sessions
98 $dir = opendir("/tmp");
99 while (($name = readdir($dir)) !== false) {
100 if (preg_match('/^fdbuild/',$name) == 0) continue;
101 if (filemtime("/tmp/$name") > strtotime("-1 hour")) continue;
102 system("rm -rf /tmp/$name");
103 }
104 closedir($dir);
106 function get_long($file, $offset)
107 {
108 $value = 0;
109 if ($fp = fopen($file,"r")) {
110 fseek($fp,$offset,SEEK_SET);
111 for ($i = 0; $i < 32; $i += 8) {
112 $value += ord(fgetc($fp)) << $i;
113 }
114 fclose($fp);
115 }
116 return $value;
117 }
119 function error($string, $title="Error")
120 {
121 echo <<<EOT
122 <div class="nav_box">
123 <h4>$title</h4>
124 <p>
125 $string
126 </p>
127 </div>
128 EOT;
129 }
131 $size = 0;
132 $initrd_size = 0;
133 $info_size = 0;
135 // Upload kernel
137 foreach($_FILES as $data) {
138 $msg="The file ".$data['name']." ";
139 switch ($data["error"]) {
140 case UPLOAD_ERR_INI_SIZE :
141 error($msg."exceeds upload_max_filesize.");
142 break;
143 case UPLOAD_ERR_FORM_SIZE :
144 error($msg."exceeds max_post_size.");
145 break;
146 case UPLOAD_ERR_PARTIAL :
147 error($msg."was only partially uploaded.");
148 break;
149 case UPLOAD_ERR_NO_TMP_DIR :
150 error("Missing a temporary folder.");
151 break;
152 case UPLOAD_ERR_CANT_WRITE :
153 error("Failed to write file to disk.");
154 break;
155 }
156 }
157 if (isset($_FILES["kernel"]['tmp_name']) &&
158 is_uploaded_file($_FILES["kernel"]['tmp_name'])) {
159 $tmp_dir = tempnam('','fdbuild');
160 if (file_exists($tmp_dir)) unlink($tmp_dir);
161 mkdir($tmp_dir);
162 $tmp_dir .= '/';
163 move_uploaded_file($_FILES["kernel"]['tmp_name'],
164 $tmp_dir."kernel");
165 $kernel = $tmp_dir."kernel";
166 $boot_version = get_long($kernel,0x206) & 255;
167 if (get_long($kernel,0x202) != 0x53726448) // 'HdrS' magic
168 $boot_version = 0;
169 $size = get_long($kernel,0x1F4); // syssize paragraphs
170 if ($boot_version < 4) $size &= 0xFFFF; // 16 bits before 2.4
171 $size = ($size + 0xFFF) & 0xFFFF000; // round up to 64K
172 $size <<= 4; // paragraphs -> bytes
173 $msg = "The size of the file ".$_FILES["kernel"]['name'];
174 }
176 if ($size && isset($_FILES["info"]['tmp_name']) &&
177 is_uploaded_file($_FILES["info"]['tmp_name'])) {
178 move_uploaded_file($_FILES["info"]['tmp_name'],
179 $tmp_dir."info");
180 $info_size = $_FILES["info"]['size'];
181 }
183 // Upload initrd
185 if ($size && isset($_FILES["initrd"]['tmp_name']) &&
186 is_uploaded_file($_FILES["initrd"]['tmp_name'])) {
187 move_uploaded_file($_FILES["initrd"]['tmp_name'],
188 $tmp_dir."initrd");
189 $initrd_size = $_FILES["initrd"]['size'];
190 $size += $initrd_size;
191 $msg = "The total size of the files ".$_FILES["kernel"]['name'].
192 " and ".$_FILES["initrd"]['name'];
193 }
194 if ($initrd_size && isset($_FILES["initrd2"]['tmp_name']) &&
195 is_uploaded_file($_FILES["initrd2"]['tmp_name'])) {
196 move_uploaded_file($_FILES["initrd2"]['tmp_name'],
197 $tmp_dir."initrd2");
198 $initrd2_size = $_FILES["initrd2"]['size'];
199 $size += $initrd2_size;
200 $msg = "The total size of the files ".$_FILES["kernel"]['name'].
201 ", ".$_FILES["initrd"]['name'].
202 " and ".$_FILES["initrd2"]['name'];
203 }
204 if ($size >= 15 * 1024 * 1024) {
205 error($msg." exceeds 15 MB.");
206 $size = 0;
207 }
208 if ($size == 0) {
209 if (isset($tmp_dir))
210 system("rm -f $tmp_dir");
211 }
212 else {
213 $cmd = "./bootloader ".$tmp_dir."kernel --prefix "
214 . $tmp_dir."fd --format 0 --flags ".$_POST['flags']
215 . " --video ".$_POST['video']." --mem ".$_POST['ram'];
216 if ($_POST['edit'] == "")
217 $cmd .= " --dont-edit-cmdline";
218 if ($_POST['cmdline'])
219 $cmd .= " --cmdline '".$_POST['cmdline']."'";
220 if ($info_size)
221 $cmd .= " --info ".$tmp_dir."info";
222 if (file_exists($_POST['rdev']))
223 $cmd .= " --rdev ".$_POST['rdev'];
224 if ($initrd_size)
225 $cmd .= " --initrd ".$tmp_dir."initrd";
226 if ($initrd2_size)
227 $cmd .= " --initrd ".$tmp_dir."initrd2";
228 switch ($_POST['size']) {
229 case 1763328 :
230 case 2015232 :
231 case 3526656 :
232 case 4030464 :
233 $cmd .= " --tracks 82"; break;
234 case 1784832 :
235 $cmd .= " --tracks 83"; break;
236 }
237 shell_exec($cmd);
238 $count = 1;
239 if ($_POST['size'] != 0) {
240 $count += (filesize($tmp_dir."fd") -1) / $_POST['size'];
241 $padding = $_POST['size'] -
242 (filesize($tmp_dir."fd") % $_POST['size']);
243 }
244 }
245 $sizes = array(
246 "368640" => "360 KB", "737280" => "720 KB",
247 "1228800" => "1.20 MB",
248 "1474560" => "1.44 MB", "1638400" => "1.60 MB",
249 "1720320" => "1.68 MB", "1763328" => "1.72 MB",
250 "1784832" => "1.74 MB", "1802240" => "1.76 MB",
251 "1884160" => "1.84 MB", "1966080" => "1.92 MB",
252 "2015232" => "1.96 MB", "2949120" => "2.88 MB",
253 "3440640" => "3.36 MB", "3526656" => "3.44 MB",
254 "3932160" => "3.84 MB", "4030464" => "3.92 MB",
255 "0" => "no limit"
256 );
258 function show_size($size)
259 {
260 global $sizes;
261 if ($size != 0) return " ".$sizes[$size];
262 }
263 ?>
265 <!-- End navigation menu -->
266 </div>
268 <!-- Content top. -->
269 <div id="content_top">
270 <div class="top_left"></div>
271 <div class="top_right"></div>
272 </div>
274 <!-- Content -->
275 <div id="content">
277 <h2>Floppy image set builder</h2>
279 <?php
280 if (!isset($count)) {
281 $max = rtrim(ini_get('upload_max_filesize'),"M");
282 $max_post = rtrim(ini_get('post_max_size'),"M");
283 if ($max_post < $max) $max = $max_post;
284 $msg = "the <acronym title=\"The linux kernel boot sector\">tiny boot loader</acronym> can't load more than 15 MB";
285 if ($max < 16)
286 $msg = "the web server can't upload more than $max MB";
287 ?>
288 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
289 <table>
290 <tr>
291 <td>Linux kernel:</td>
292 <td><input type="file" name="kernel" size="37" /> <i>required</i></td>
293 </tr>
294 <tr>
295 <td>Initramfs / Initrd:</td>
296 <td><input type="file" name="initrd" size="37" /> <i>optional</i></td>
297 </tr>
298 <tr>
299 <td>Extra initramfs:</td>
300 <td><input type="file" name="initrd2" size="37" /> <i>optional</i></td>
301 </tr>
302 <tr>
303 <td>Boot message:</td>
304 <td><input type="file" name="info" size="37" /> <i>optional</i></td>
305 </tr>
306 <tr>
307 <td>Default cmdline:</td>
308 <td><input type="text" name="cmdline" size="36" <?php
309 if (isset($_GET['cmdline'])) echo 'value="'.$_GET['cmdline'].'"';
310 ?>/> <input type="checkbox" name="edit" checked="checked" />edit
311 <i>optional</i></td>
312 </tr>
313 <tr>
314 <td>Root device:</td>
315 <td><input type="text" name="rdev" size="8" value="<?php
316 if (isset($_GET['rdev'])) echo $_GET['rdev'];
317 else echo "/dev/fd0";
318 ?>" />
319 &nbsp;&nbsp;Flags: <select name="flags">
320 <option value="1">R/O</option>
321 <option value="0" <?php
322 if (isset($_GET['rdev']) && $_GET['rdev'] == "0")
323 echo ' selected="selected"'
324 ?>>R/W</option>
325 </select>
326 &nbsp;&nbsp;VESA: <select name="video">
327 <?php
328 $selected=-1;
329 if (isset($_GET['video'])) $selected = $_GET['video'];
330 $options = array();
331 $options[-3] = "Ask";
332 $options[-2] = "Extended";
333 $options[-1] = "Standard";
334 for ($i = 0; $i < 16; $i++) $options[$i] = $i;
335 $options[0xF00] = "80x25";
336 $options[0xF01] = "80x50";
337 $options[0xF02] = "80x43";
338 $options[0xF03] = "80x28";
339 $options[0xF05] = "80x30";
340 $options[0xF06] = "80x34";
341 $options[0xF07] = "80x60";
342 $options[0x30A] = "132x43";
343 $options[0x309] = "132x25";
344 $options[0x338] = "320x200x8"; // 382?
345 $options[0x30D] = "320x200x15";
346 $options[0x30E] = "320x200x16";
347 $options[0x30F] = "320x200x24";
348 $options[0x320] = "320x200x32";
349 $options[0x332] = "320x240x8"; // 392?
350 $options[0x393] = "320x240x15";
351 $options[0x335] = "320x240x16";// 394?
352 $options[0x395] = "320x240x24";
353 $options[0x396] = "320x240x32";
354 $options[0x333] = "400x300x8";// 3A2?
355 $options[0x3A3] = "400x300x15";
356 $options[0x336] = "400x300x16";// 3A4?
357 $options[0x3A5] = "400x300x24";
358 $options[0x3A6] = "400x300x32";
359 $options[0x334] = "512x384x8";// 3B2?
360 $options[0x3B3] = "512x384x15";
361 $options[0x337] = "512x384x16";// 3B4?
362 $options[0x3B5] = "512x384x24";
363 $options[0x3B6] = "512x384x32";
364 $options[0x3C2] = "640x350x8";
365 $options[0x3C3] = "640x350x15";
366 $options[0x3C4] = "640x350x16";
367 $options[0x3C5] = "640x350x24";
368 $options[0x3C6] = "640x350x32";
369 $options[0x300] = "640x400x8";
370 $options[0x383] = "640x400x15";
371 $options[0x339] = "640x400x16";// 384?
372 $options[0x385] = "640x400x24";
373 $options[0x386] = "640x400x32";
374 $options[0x301] = "640x480x8";
375 $options[0x310] = "640x480x15";
376 $options[0x311] = "640x480x16";
377 $options[0x312] = "640x480x24";
378 $options[0x33A] = "640x480x32";// 321?
379 $options[879] = "800x500x8";
380 $options[880] = "800x500x15";
381 $options[881] = "800x500x16";
382 $options[882] = "800x500x24";
383 $options[883] = "800x500x32";
384 //$options[770] = "800x600x4";
385 $options[0x303] = "800x600x8";
386 $options[0x313] = "800x600x15";
387 $options[0x314] = "800x600x16";
388 $options[0x315] = "800x600x24";
389 $options[0x33B] = "800x600x32";//322?
390 $options[815] = "896x672x8";
391 $options[816] = "896x672x15";
392 $options[817] = "896x672x16";
393 $options[818] = "896x672x24";
394 $options[819] = "896x672x32";
395 $options[874] = "1024x640x8";
396 $options[875] = "1024x640x15";
397 $options[876] = "1024x640x16";
398 $options[877] = "1024x640x24";
399 $options[878] = "1024x640x32";
400 //$options[772] = "1024x768x4";
401 $options[0x305] = "1024x768x8";
402 $options[0x316] = "1024x768x15";
403 $options[0x317] = "1024x768x16";
404 $options[0x318] = "1024x768x24";
405 $options[0x33C] = "1024x768x32";//323?
406 $options[869] = "1152x720x8";
407 $options[870] = "1152x720x15";
408 $options[871] = "1152x720x16";
409 $options[872] = "1152x720x24";
410 $options[873] = "1152x720x32";
411 $options[0x307] = "1280x1024x8";
412 $options[0x319] = "1280x1024x15";
413 $options[0x31A] = "1280x1024x16";
414 $options[0x31B] = "1280x1024x24";
415 $options[0x33D] = "1280x1024x32";
416 $options[835] = "1400x1050x8";
417 $options[837] = "1400x1050x16";
418 $options[838] = "1400x1040x24";
419 $options[864] = "1440x900x8";
420 $options[864] = "1440x900x15";
421 $options[866] = "1440x900x16";
422 $options[867] = "1440x900x24";
423 $options[868] = "1440x900x32";
424 $options[0x330] = "1600x1200x8";
425 $options[0x331] = "1600x1200x16";
426 $options[893] = "1920x1200x8";
427 foreach ($options as $key => $value) {
428 echo '<option value="'.$key.'"';
429 if ($key == $selected || $value == $selected)
430 echo ' selected="selected"';
431 echo '>'.$value."</option>\n";
432 }
433 ?>
434 </select>
435 </td>
436 </tr>
437 <tr>
438 <td>Floppy size:</td>
439 <td><select name="size">
440 <?php
441 foreach ($sizes as $key => $value) {
442 switch ($key) {
443 case "368640" :
444 echo " <optgroup label=\"5&frac14; SD\">\n";
445 break;
446 case "737280" :
447 echo " </optgroup>\n";
448 echo " <optgroup label=\"3&frac12; SD\">\n";
449 break;
450 case "1228800" :
451 echo " </optgroup>\n";
452 echo " <optgroup label=\"5&frac14; HD\">\n";
453 break;
454 case "1474560" :
455 echo " </optgroup>\n";
456 echo " <optgroup label=\"3&frac12; HD\">\n";
457 break;
458 case "2949120" :
459 echo " </optgroup>\n";
460 echo " <optgroup label=\"3&frac12; ED\">\n";
461 break;
462 case "0" :
463 echo " </optgroup>\n";
464 break;
465 }
466 echo " <option value=\"$key\"";
467 if ($key == "1474560") echo " selected='selected'";
468 echo ">$value</option>\n";
469 }
470 ?>
471 </select>&nbsp;
472 RAM used&nbsp;<select name="ram">
473 <?php
474 for ($i = 16; $i >= 4; $i--)
475 echo " <option value=\"$i\">$i MB</option>\n";
476 ?>
477 </select>&nbsp;
478 <input name="build" value="Build floppy set" type="submit" />
479 </td>
480 </tr>
481 </table>
482 </form>
483 <?php
484 echo <<<EOT
485 <p>
486 Note 1: $msg of files (kernel and initramfs) in memory.
487 </p>
488 <p>
489 Note 2: the extra initramfs may be useful to add your own configuration files.
490 </p>
491 <p>
492 Note 3: the keyboard is read for ESC or ENTER on every form feed (ASCII 12) in the boot message.
493 </p>
494 EOT;
495 }
496 else {
497 ?>
498 <h4>Download image<?php if ($count >= 2) echo "s"; ?></h4>
499 <ul>
500 <?php
501 for ($i = 1; $i <= $count; $i++) {
502 echo ' <li><a href="'.$_SERVER["PHP_SELF"].
503 "?id=".basename($tmp_dir)."&amp;n=$i&amp;s=".
504 $_POST["size"].'">'.sprintf("fd%03d.img",$i).
505 show_size($_POST["size"])."</a></li>\n";
506 }
507 echo "</ul>\n".floor($padding/1024)."KB padding.\n";
508 ?>
510 <p>
511 You can write floppies with SliTaz <i>bootfloppybox</i>,
512 <a href="http://en.wikipedia.org/wiki/RaWrite">Windows rawrite</a> or simply dd:
513 </p>
514 <pre># dd if=fd001.img of=/dev/fd0
515 </pre>
517 <p>
518 Start your computer with <i>fd001.img</i>. It will show the kernel version string and
519 the kernel cmdline line. You can edit the cmdline. Most users can just press Enter.
520 </p>
522 <?php
523 if ($count >= 2) {
524 ?>
525 <p>
526 The floppy is then loaded into memory (one dot each 64k) and you will be prompted to
527 insert the next floppy, <i>fd002.img</i>. And so on.
528 </p>
530 <p>
531 The floppy set detects disk swaps and can be used without a keyboard.
532 </p>
533 <?php
534 }
535 ?>
536 <p>
537 Good luck.
538 </p>
539 <?php
540 }
541 ?>
543 <div class="nav_box">
544 <h4>How does it work ?</h4>
545 <p>
546 This tool updates the boot sector of your kernel with
547 <a href="http://hg.slitaz.org/wok/raw-file/66e38bd6a132/linux/stuff/linux-header.u">this patch</a>.
548 You may add a default cmdline and an initramfs. The cmdline can be edited at boot
549 time but the <acronym title="Check for disk swap every 5 seconds">keyboard is not mandatory</acronym>.
550 A <a href="bootloader"> standalone version</a> is available.
551 </p>
552 <p>
553 Each part (boot, setup, boot message, cmdline, kernel, initramfs) is aligned to 512 bytes.
554 The result is split to fit the floppy size.
555 The last floppy image is padded with zeros.
556 </p>
557 <p>
558 You can extract the <u>kernel</u>, <u>cmdline</u> and <u>rootfs</u> files with
559 <a href="../floppies">this tool</a> from the floppy images.
560 </p>
561 </div>
563 <!-- End of content with round corner -->
564 </div>
565 <div id="content_bottom">
566 <div class="bottom_left"></div>
567 <div class="bottom_right"></div>
568 </div>
570 <!-- Start of footer and copy notice -->
571 <div id="copy">
572 <p>
573 Copyright &copy; <?php echo date('Y'); ?> <a href="http://www.slitaz.org/">SliTaz</a> -
574 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>
575 </p>
576 <!-- End of copy -->
577 </div>
579 <!-- Bottom and logo's -->
580 <div id="bottom">
581 <p>
582 <a href="http://validator.w3.org/check?uri=referer"><img src="../static/xhtml10.png" alt="Valid XHTML 1.0" title="Code validé XHTML 1.0" style="width: 80px; height: 15px;" /></a>
583 </p>
584 <p>
585 <img src="#" id="qrcodeimg" alt="#" width="60" height="60"
586 onmouseover= "this.title = location.href"
587 onclick= "this.width = this.height = 300;" />
588 <script type="text/javascript" src="../static/qrcode.js"></script>
589 <script type="text/javascript">
590 document.getElementById('qrcodeimg').src =
591 QRCode.generatePNG(location.href, {ecclevel: 'H'});
592 </script>
593 </p>
594 </div>
596 </body>
597 </html>