tiny-slitaz view step1.php @ rev 18

step5.php: typo
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jul 22 09:09:36 2016 +0200 (2016-07-22)
parents ac214416e736
children faf1a7bf7d5b
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 while (($name = readdir($dir)) !== false) {
11 if (preg_match('/^tiny_webgen/',$name) == 0) continue;
12 if (filemtime("/tmp/$name") > strtotime("-1 hour")) continue;
13 shell_exec("sudo ./helper --remove /tmp/$name");
14 }
15 closedir($dir);
16 if (isset($_POST["tmp_dir"])) return;
17 $_POST["tmp_dir"] = tempnam('','tiny_webgen');
18 if (file_exists($_POST["tmp_dir"])) unlink($_POST["tmp_dir"]);
19 mkdir($_POST["tmp_dir"]);
20 $_POST["tmp_dir"] .= '/';
21 }
23 set_tmp_dir();
25 function post_hidden()
26 {
27 global $usedvars;
28 foreach ($usedvars as $var) {
29 if (isset($_POST[$var]) && $var != "continue" &&
30 $var != "configuring") {
31 ?>
32 <input name="<?php echo $var; ?>" value="<?php echo $_POST[$var]; ?>" type="hidden" />
33 <?php
34 }
35 }
36 }
38 function upload($var, $file = "")
39 {
40 if ($file == "") $file = $var;
41 if (isset($_FILES[$var])) {
42 $tmp_name = $_FILES[$var]['tmp_name'];
43 if (is_uploaded_file($tmp_name)) {
44 move_uploaded_file($tmp_name, $_POST["tmp_dir"].$file);
45 }
46 }
47 }
49 if (isset($_POST['mykernel']) && !isset($_POST['packages'])) {
50 $_POST['kernel'] = "custom";
51 upload("uploadkernel","kernel");
52 }
54 if (!isset($_POST['kernel'])) {
55 shell_exec("sudo ./helper --init");
56 if (isset($_POST['config'])) {
57 upload("uploadconf");
58 }
59 if (!file_exists($_POST["tmp_dir"]."uploadconf")) {
60 ?>
62 <div class="box">
63 <h3>[Step 1/5] Packages and Kernel</h3>
65 <p>The file <tt>/etc/packages.conf</tt> in the initramfs holds all information
66 to rebuild your Tiny SliTaz system. You should upload your
67 <tt>/etc/packages.conf</tt> first if you only want to upgrade your system.</p>
69 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
70 Packages configuration:
71 <input type="file" name="uploadconf" />
72 <input name="config" value="Get config" type="submit" />
73 <?php post_hidden(); ?>
74 </form>
75 <?php
76 }
77 if (isset($_POST['mypackages'])) {
78 upload("uploadpkgs");
79 shell_exec("./helper --pkgs-extract uploadpkgs ".$_POST['tmp_dir']);
80 }
81 if (!file_exists($_POST["tmp_dir"]."uploadpkgs")) {
82 ?>
84 <hr>
86 <p>You can upload a tazpkg file (.tazpkg) or a tarball of tazpkg files (.tar).
87 These packages will extend the official packages list and will be chosen when
88 the package names are found to be matching. You can find some examples in the
89 <a href="http://hg.slitaz.org/wok-tiny/file/">Tiny SliTaz repository</a>.</p>
91 <div>
92 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
93 Additional packages:
94 <input type="file" name="uploadpkgs" />
95 <input name="mypackages" value="Get packages" type="submit" />
96 <?php post_hidden(); ?>
97 </form>
98 </div>
100 <hr>
101 <?php
102 }
103 ?>
105 <p id="kernel">You can upload a custom Kernel or use an official one. Your
106 Kernel should have an embedded initramfs with busybox like <a
107 href="dist/rootfs.cpio" title="See CONFIG_INITRAMFS_SOURCE">this</a>.</p>
109 <div>
110 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
111 Custom kernel (bzImage file):
112 <input type="file" name="uploadkernel" />
113 <input name="mykernel" value="Get kernel" type="submit" />
114 <?php post_hidden(); ?>
115 </form>
116 </div>
118 <hr>
120 <div>
121 <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" name="kernels">
122 <input type="hidden" name="kernel" value="linux" />
124 <div align="center">
125 <input name="continue" value="Continue" type="submit" />
126 </div>
127 </form>
128 </div>
129 </div>
131 <?php
132 }
133 ?>