tiny-slitaz annotate step1.php @ rev 32

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