tiny-slitaz view step1.php @ rev 27

Multi floppy support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Sep 17 08:38:04 2019 +0200 (2019-09-17)
parents 694b6eb6f4f9
children 974cf6a79cc4
line source
1 <?php
3 shell_exec("sudo ./helper --chkdist");
4 $usedvars = array( "kernel", "modules", "packages", "toconfigure",
5 "continue", "configuring", "tmp_dir" );
7 function set_tmp_dir()
8 {
9 $dir = opendir("/tmp");
10 $i = 0;
11 while (($name = readdir($dir)) !== false) {
12 if (preg_match('/^tiny_webgen/',$name) == 0) continue;
13 if (filemtime("/tmp/$name") < strtotime("-1 hour"))
14 shell_exec("sudo ./helper --remove /tmp/$name");
15 else if ($i++ > 100) {
16 echo "<h1>Too many users, retry later</h1>";
17 exit;
18 }
19 }
20 closedir($dir);
21 if (isset($_POST["tmp_dir"])) return;
22 $_POST["tmp_dir"] = tempnam('','tiny_webgen');
23 if (file_exists($_POST["tmp_dir"])) unlink($_POST["tmp_dir"]);
24 mkdir($_POST["tmp_dir"]);
25 $_POST["tmp_dir"] .= '/';
26 }
28 set_tmp_dir();
30 function post_hidden()
31 {
32 global $usedvars;
33 foreach ($usedvars as $var) {
34 if (isset($_POST[$var]) && $var != "continue" &&
35 $var != "configuring") {
36 ?>
37 <input name="<?php echo $var; ?>" value="<?php echo $_POST[$var]; ?>" type="hidden" />
38 <?php
39 }
40 }
41 }
43 function upload($var, $file = "")
44 {
45 if ($file == "") $file = $var;
46 if (isset($_FILES[$var])) {
47 $tmp_name = $_FILES[$var]['tmp_name'];
48 if (is_uploaded_file($tmp_name)) {
49 move_uploaded_file($tmp_name, $_POST["tmp_dir"].$file);
50 }
51 }
52 }
54 if (isset($_POST['mykernel']) && !isset($_POST['packages'])) {
55 $_POST['kernel'] = "custom";
56 upload("uploadkernel","kernel");
57 }
59 if (!isset($_POST['kernel'])) {
60 shell_exec("sudo ./helper --init");
61 if (isset($_POST['config'])) {
62 upload("uploadconf");
63 }
64 if (!file_exists($_POST["tmp_dir"]."uploadconf")) {
65 ?>
67 <div class="box">
68 <h3>[Step 1/5] Packages and Kernel</h3>
70 <p>The file <tt>/etc/packages.conf</tt> in the initramfs holds all information
71 to rebuild your Tiny SliTaz system. You should upload your
72 <tt>/etc/packages.conf</tt> first if you only want to upgrade your system.</p>
74 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
75 Packages configuration:
76 <input type="file" name="uploadconf" />
77 <input name="config" value="Get config" type="submit" />
78 <?php post_hidden(); ?>
79 </form>
80 <?php
81 }
82 if (isset($_POST['mypackages'])) {
83 upload("uploadpkgs");
84 shell_exec("./helper --pkgs-extract uploadpkgs ".$_POST['tmp_dir']);
85 }
86 if (!file_exists($_POST["tmp_dir"]."uploadpkgs")) {
87 ?>
89 <hr>
91 <p>You can upload a tazpkg file (.tazpkg) or a tarball of tazpkg files (.tar).
92 These packages will extend the official packages list and will be chosen when
93 the package names are found to be matching. You can find some examples in the
94 <a href="http://hg.slitaz.org/wok-tiny/file/">Tiny SliTaz repository</a>.</p>
96 <div>
97 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
98 Additional packages:
99 <input type="file" name="uploadpkgs" />
100 <input name="mypackages" value="Get packages" type="submit" />
101 <?php post_hidden(); ?>
102 </form>
103 </div>
105 <hr>
106 <?php
107 }
108 ?>
110 <p id="kernel">You can upload a custom Kernel or use an official one. Your
111 Kernel should have an embedded initramfs with busybox like <a
112 href="dist/rootfs.cpio" title="See CONFIG_INITRAMFS_SOURCE">this</a>.</p>
114 <div>
115 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
116 Custom kernel (bzImage file):
117 <input type="file" name="uploadkernel" />
118 <input name="mykernel" value="Get kernel" type="submit" />
119 <?php post_hidden(); ?>
120 </form>
121 </div>
123 <hr>
125 <div>
126 <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" name="kernels">
127 <input type="hidden" name="kernel" value="linux" />
128 <?php post_hidden(); ?>
129 <div align="center">
130 <input name="continue" value="Continue" type="submit" />
131 </div>
132 </form>
133 </div>
134 </div>
136 <?php
137 }
138 ?>