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