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