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

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