tiny-slitaz view step1.php @ rev 5

refresh
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Oct 07 23:37:02 2015 +0200 (2015-10-07)
parents d203aafad141
children ac214416e736
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 <p>
63 The file <u>/etc/packages.conf</u> in the initramfs holds all information
64 to rebuild your Tiny SliTaz system. You should upload your
65 <u>/etc/packages.conf</u> first if you want to upgrade your system only.
66 </p>
68 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
69 Packages configuration:
70 <input type="file" name="uploadconf" />
71 <input name="config" value="Get config" type="submit" />
72 <?php post_hidden(); ?>
73 </form>
74 <?php
75 }
76 if (isset($_POST['mypackages'])) {
77 upload("uploadpkgs");
78 shell_exec("./helper --pkgs-extract uploadpkgs ".$_POST['tmp_dir']);
79 }
80 if (!file_exists($_POST["tmp_dir"]."uploadpkgs")) {
81 ?>
83 <p>
84 You can upload a tazpkg file (.tazpkg) or a tarball of tazpkg files (.tar).
85 These packages will extend the official packages list and will be chosen when
86 the package names are found to be matching. You can find some examples in the
87 <a href="http://hg.slitaz.org/wok-tiny/file/">Tiny SliTaz repository</a>.
88 </p>
89 <div>
90 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
91 Additional packages:
92 <input type="file" name="uploadpkgs" />
93 <input name="mypackages" value="Get packages" type="submit" />
94 <?php post_hidden(); ?>
95 </form>
96 </div>
97 <p>
98 <?php
99 }
100 ?>
101 </p>
103 <a name="kernel"></a>
104 <h2>Linux kernel</h2>
106 <p>
107 You can upload a custom kernel or use an official one.
108 Your kernel should have an embedded initramfs with busybox like
109 <a href="dist/rootfs.cpio" title="See CONFIG_INITRAMFS_SOURCE">this one</a>.
110 </p>
112 <div>
113 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
114 Custom kernel (bzImage file):
115 <input type="file" name="uploadkernel" />
116 <input name="mykernel" value="Get kernel" type="submit" />
117 <?php post_hidden(); ?>
118 </form>
119 </div>
121 <div>
122 <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" name="kernels">
123 <input type="hidden" name="kernel" value="linux" />
124 <p>
125 </p>
127 <div align="center">
128 <input name="continue" value="Continue" type="submit" />
129 </div>
130 </form>
131 </div>
132 <?php
133 }
134 ?>