Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 213 lines (183 sloc) 5.848 kb
973b889 Koen Kooi narcissus: start using xmlhttprequest
koenkooi authored
1 <?
2 /* Narcissus - Online image builder for the angstrom distribution
da8951b Koen Kooi narcissus: start adding support for multiple sd card images
koenkooi authored
3 * Koen Kooi (c) 2008-2010 - all rights reserved
973b889 Koen Kooi narcissus: start using xmlhttprequest
koenkooi authored
4 *
5 */
6
7
8 $base_pkg_set = " task-base angstrom-version ";
9
6a0edd2 Koen Kooi narcissus: implement package selection, switch to POST
koenkooi authored
10 if (isset($_POST["action"]) && $_POST["action"] != "") {
11 $action = $_POST["action"];
bfaceb0 Koen Kooi narcissus: working implementation, now we can move to package selection ...
koenkooi authored
12 } else {
13 print "Invalid action: $action";
14 exit;
15 }
16
6a0edd2 Koen Kooi narcissus: implement package selection, switch to POST
koenkooi authored
17 if (isset($_POST["machine"])) {
534457f Koen Kooi narcissus: use system() in a more sane way
koenkooi authored
18 $machine = escapeshellcmd(basename($_POST["machine"]));
9c0cb89 Koen Kooi narcissus: first successfull frontend <> backend communication
koenkooi authored
19 } else {
20 print "Invalid machine";
21 exit;
973b889 Koen Kooi narcissus: start using xmlhttprequest
koenkooi authored
22 }
23
6a0edd2 Koen Kooi narcissus: implement package selection, switch to POST
koenkooi authored
24 if (isset($_POST["name"]) && $_POST["name"] != "") {
534457f Koen Kooi narcissus: use system() in a more sane way
koenkooi authored
25 $name = escapeshellcmd(basename($_POST["name"]));
9c0cb89 Koen Kooi narcissus: first successfull frontend <> backend communication
koenkooi authored
26 } else {
27 $name = "unnamed";
28 }
29
6a0edd2 Koen Kooi narcissus: implement package selection, switch to POST
koenkooi authored
30 if (isset($_POST["pkgs"]) && $_POST["pkgs"] != "") {
6060d36 Koen Kooi narcissus: pass "tbz2" as default imagetype
koenkooi authored
31 $pkg = $_POST["pkgs"];
6a0edd2 Koen Kooi narcissus: implement package selection, switch to POST
koenkooi authored
32 } else {
6060d36 Koen Kooi narcissus: pass "tbz2" as default imagetype
koenkooi authored
33 $pkg = "task-boot";
6a0edd2 Koen Kooi narcissus: implement package selection, switch to POST
koenkooi authored
34 }
35
7f896cb Koen Kooi narcissus: backend supports 'releases' now, defaults to 'stable'
koenkooi authored
36 if (isset($_POST["release"]) && $_POST["release"] != "") {
6060d36 Koen Kooi narcissus: pass "tbz2" as default imagetype
koenkooi authored
37 $release = $_POST["release"];
7f896cb Koen Kooi narcissus: backend supports 'releases' now, defaults to 'stable'
koenkooi authored
38 } else {
6060d36 Koen Kooi narcissus: pass "tbz2" as default imagetype
koenkooi authored
39 $release = "stable";
40 }
41
42 if (isset($_POST["imagetype"]) && $_POST["imagetype"] != "") {
43 $imagetype = $_POST["imagetype"];
44 } else {
10bd73d Koen Kooi narcissus: switch to tar.gz to lessen CPU load on server
koenkooi authored
45 $imagetype = "tgz";
46 $imagesuffix = "tar.gz";
7f896cb Koen Kooi narcissus: backend supports 'releases' now, defaults to 'stable'
koenkooi authored
47 }
48
f1da684 Koen Kooi narcissus: have backend pass 'manifest' flag to assembly script
koenkooi authored
49 if (isset($_POST["manifest"]) && $_POST["manifest"] != "") {
50 $manifest = $_POST["manifest"];
51 } else {
52 $manifest = "no";
53 }
54
ba08227 Koen Kooi narcissus-sdk: hook SDK into GUI
koenkooi authored
55 if (isset($_POST["sdk"]) && $_POST["sdk"] != "") {
56 $sdk = $_POST["sdk"];
57 } else {
58 $sdk = "no";
59 }
60
0c6864e Koen Kooi narcissus-sdk: expose SDK host architecture to GUI, improve dialog a bit
koenkooi authored
61 if (isset($_POST["sdkarch"]) && $_POST["sdkarch"] != "") {
62 $sdkarch = $_POST["sdkarch"];
63 } else {
1e015bd Koen Kooi narcissus-sdk: display link to generated SDK in GUI
koenkooi authored
64 $sdkarch = "none";
0c6864e Koen Kooi narcissus-sdk: expose SDK host architecture to GUI, improve dialog a bit
koenkooi authored
65 }
f1da684 Koen Kooi narcissus: have backend pass 'manifest' flag to assembly script
koenkooi authored
66
3921ea7 Koen Kooi narcissus: fix security hole
koenkooi authored
67 switch($release) {
9706167 Koen Kooi narcissus: add v2012.05 and v2013.06 releases
koenkooi authored
68 case "v2012.05":
69 break;
3921ea7 Koen Kooi narcissus: fix security hole
koenkooi authored
70 case "v2012.12":
71 break;
9706167 Koen Kooi narcissus: add v2012.05 and v2013.06 releases
koenkooi authored
72 case "v2013.06":
73 break;
8547ba8 Koen Kooi narcissus: add v2013.12 release
koenkooi authored
74 case "v2013.12":
75 break;
3921ea7 Koen Kooi narcissus: fix security hole
koenkooi authored
76 default:
93e53f1 Koen Kooi narcissus: limit releases to v2012.12
koenkooi authored
77 $release = "v2012.12";
3921ea7 Koen Kooi narcissus: fix security hole
koenkooi authored
78 }
79
5a7d7d2 Koen Kooi narcissus: set the right suffix for each imagetype
koenkooi authored
80 switch($imagetype) {
10bd73d Koen Kooi narcissus: switch to tar.gz to lessen CPU load on server
koenkooi authored
81 case "tgz":
82 $imagesuffix = "tar.gz";
e9cbff5 Koen Kooi narcissus: reindent php files with XCode
koenkooi authored
83 break;
9bb005b Koen Kooi narcissus: make SD images a seperate image type
koenkooi authored
84 case "sdimg":
85 $imagesuffix = "tar.gz";
86 break;
a72402e Joel backend: Set imagesuffix to .tar.gz when imagetype is sdimg-ubi
joelagnel authored
87 case "sdimg-ubi":
88 $imagesuffix = "tar.gz";
89 break;
e9cbff5 Koen Kooi narcissus: reindent php files with XCode
koenkooi authored
90 case "ubifs":
91 $imagesuffix = "ubi";
92 break;
93 default:
94 $imagesuffix = $imagetype;
5a7d7d2 Koen Kooi narcissus: set the right suffix for each imagetype
koenkooi authored
95 }
96
bfaceb0 Koen Kooi narcissus: working implementation, now we can move to package selection ...
koenkooi authored
97 switch($action) {
e9cbff5 Koen Kooi narcissus: reindent php files with XCode
koenkooi authored
98 case "assemble_image":
99 print "assembling\n";
0c6864e Koen Kooi narcissus-sdk: expose SDK host architecture to GUI, improve dialog a bit
koenkooi authored
100 assemble_image($machine, $name, $imagetype, $manifest, $sdk, $sdkarch);
e9cbff5 Koen Kooi narcissus: reindent php files with XCode
koenkooi authored
101 break;
102 case "configure_image":
103 print "configuring\n";
104 configure_image($machine, $name, $release);
105 break;
106 case "show_image_link":
1e015bd Koen Kooi narcissus-sdk: display link to generated SDK in GUI
koenkooi authored
107 show_image_link($machine, $name, $imagesuffix, $manifest, $sdk, $sdkarch);
e9cbff5 Koen Kooi narcissus: reindent php files with XCode
koenkooi authored
108 break;
109 case "install_package":
110 print "installing $pkg\n";
111 install_package($machine, $name, $pkg);
112 break;
973b889 Koen Kooi narcissus: start using xmlhttprequest
koenkooi authored
113 }
114
1e015bd Koen Kooi narcissus-sdk: display link to generated SDK in GUI
koenkooi authored
115 function show_image_link($machine, $name, $imagesuffix, $manifest, $sdk, $sdkarch) {
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
116 $foundimage = 0;
117 $foundsdimage = 0;
1e015bd Koen Kooi narcissus-sdk: display link to generated SDK in GUI
koenkooi authored
118 $foundsdk = 0;
c998ff5 Koen Kooi narcissus: expand source gathering a bit
koenkooi authored
119 $foundsources = 0;
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
120 $printedcacheinfo = 0;
121 $printstring = "";
1e015bd Koen Kooi narcissus-sdk: display link to generated SDK in GUI
koenkooi authored
122
123 switch($sdkarch) {
124 case "intel32":
125 $sdkarchname = "i686";
126 break;
127 case "intel64":
128 $sdkarchname = "x86_64";
129 break;
130 default:
131 $sdkarchname = "i686";
132 break;
133 }
e9cbff5 Koen Kooi narcissus: reindent php files with XCode
koenkooi authored
134
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
135 $randomname = substr(md5(time()), 0, 6);
136 $deploydir = "deploy/$machine/$randomname";
6ce62a7 Koen Kooi narcissus: seperate deploy/ into deploy/ and work/
koenkooi authored
137 mkdir($deploydir,0777,TRUE);
e9cbff5 Koen Kooi narcissus: reindent php files with XCode
koenkooi authored
138
6ce62a7 Koen Kooi narcissus: seperate deploy/ into deploy/ and work/
koenkooi authored
139 $imagefiles = scandir("work/$machine");
1e015bd Koen Kooi narcissus-sdk: display link to generated SDK in GUI
koenkooi authored
140 print "<br/>";
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
141 foreach($imagefiles as $value) {
6ce62a7 Koen Kooi narcissus: seperate deploy/ into deploy/ and work/
koenkooi authored
142 $location = "work/$machine/$value";
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
143 // The !== operator must be used. Using != would not work as expected
144 // because the position of 'a' is 0. The statement (0 != false) evaluates
145 // to false.
146 if(strpos($value, "$name-image-$machine-sd") !== false) {
147 rename($location, "$deploydir/$value");
148 $imgsize = round(filesize("$deploydir/$value") / (1024 * 1024),2);
149 $printstring .= "<a href='$deploydir/$value'>$value</a> [$imgsize MiB]<br/> ";
150 $foundsdimage = 1;
c13ad1a Koen Kooi narcissus: only display message about SD card images when there are pres...
koenkooi authored
151 continue;
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
152 }
153 if(strpos($value, "$name-image-$machine.$imagesuffix") !== false) {
154 rename($location, "$deploydir/$value");
155 $imgsize = round(filesize("$deploydir/$value") / (1024 * 1024),2);
3191487 Koen Kooi narcissus: remove builds after 2 days
koenkooi authored
156 $imagestring .= "<br/><a href='$deploydir/$value'>$value</a> [$imgsize MiB]: This is the rootfs '$name' for $machine you just built. This will get automatically deleted after 2 days.<br/>";
8328deb Koen Kooi narcissus: clean up .bb and .txt files after the build
koenkooi authored
157
158 rename("work/$machine/$name-image.bb", "$deploydir/$name-image.bb");
159 rename("work/$machine/$name-image.txt", "$deploydir/$name-image.txt");
160
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
161 if($manifest == "yes") {
6ce62a7 Koen Kooi narcissus: seperate deploy/ into deploy/ and work/
koenkooi authored
162 rename("work/$machine/$name-image-manifest.html", "$deploydir/$name-image-manifest.html");
163 $imagestring .= "You can also have a look at the software <a href='$deploydir/$name-image-manifest.html' target='manifest'>manifest</a> for this rootfs<br/>";
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
164 }
e65ea09 Koen Kooi narcissus: only show manifest link when it has been requested
koenkooi authored
165 $foundimage = 1;
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
166 }
10bd73d Koen Kooi narcissus: switch to tar.gz to lessen CPU load on server
koenkooi authored
167 //Angstrom-2010.05-narcissus-hawkboard-i686-random-d4ddcec6-image-toolchain.tar.gz
1e015bd Koen Kooi narcissus-sdk: display link to generated SDK in GUI
koenkooi authored
168 if(strpos($value, "narcissus-$machine-$sdkarchname-$name-image-$sdk") !== false) {
169 rename($location, "$deploydir/$value");
170 $sdksize = round(filesize("$deploydir/$value") / (1024 * 1024),2);
171 $imagestring .= "<br/><a href='$deploydir/$value'>$value</a> [$sdksize MiB]: $sdk for the generated rootfs.<br/>";
172 $foundsdk = 1;
173 }
c998ff5 Koen Kooi narcissus: expand source gathering a bit
koenkooi authored
174 //random-ed560fe9-image-sources/
175 if(strpos($value, "$name-image-sources") !== false) {
176 rename($location, "$deploydir/sources");
177 $foundsources = 1;
178 }
1e015bd Koen Kooi narcissus-sdk: display link to generated SDK in GUI
koenkooi authored
179 }
e9cbff5 Koen Kooi narcissus: reindent php files with XCode
koenkooi authored
180
c13ad1a Koen Kooi narcissus: only display message about SD card images when there are pres...
koenkooi authored
181 if ($foundimage == 0) {
bfaceb0 Koen Kooi narcissus: working implementation, now we can move to package selection ...
koenkooi authored
182 print "Image not found, something went wrong :/";
da8951b Koen Kooi narcissus: start adding support for multiple sd card images
koenkooi authored
183 } else {
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
184 print("$imagestring");
185 }
e9cbff5 Koen Kooi narcissus: reindent php files with XCode
koenkooi authored
186
c13ad1a Koen Kooi narcissus: only display message about SD card images when there are pres...
koenkooi authored
187 if($foundsdimage == 1) {
6acd563 Koen Kooi narcissus: update SD image wording
koenkooi authored
188 print(" <br/><br/> The raw SD card image(s) below have the intended size for the SD card is encoded in the file name, e.g. 1GiB for a one gigabyte card.<br/><br/> $printstring");
26329ab Koen Kooi narcissus: reindent backend.php
koenkooi authored
189 }
e9cbff5 Koen Kooi narcissus: reindent php files with XCode
koenkooi authored
190
bfaceb0 Koen Kooi narcissus: working implementation, now we can move to package selection ...
koenkooi authored
191 }
192
7f896cb Koen Kooi narcissus: backend supports 'releases' now, defaults to 'stable'
koenkooi authored
193 function configure_image($machine, $name, $release) {
82108f9 Koen Kooi narcissus: install packages one by one to make it possible to provide a ...
koenkooi authored
194 print "Machine: $machine, name: $name\n";
7f896cb Koen Kooi narcissus: backend supports 'releases' now, defaults to 'stable'
koenkooi authored
195 passthru ("scripts/configure-image.sh $machine $name-image $release && exit");
48047a1 Koen Kooi narcissus: move stats collecting to assembly time
koenkooi authored
196 }
197
198 function install_package($machine, $name, $pkg) {
199 print "Machine: $machine, name: $name, pkg: $pkg\n";
200 passthru ("scripts/install-package.sh $machine $name-image $pkg && exit", $installretval);
201 print "<div id=\"retval\">$installretval</div>";
202 }
203
0c6864e Koen Kooi narcissus-sdk: expose SDK host architecture to GUI, improve dialog a bit
koenkooi authored
204 function assemble_image($machine, $name, $imagetype, $manifest, $sdk, $sdkarch) {
2797341 Koen Kooi narcissus: complete ext2 support in the backend
koenkooi authored
205 print "Machine: $machine, name: $name, type: $imagetype\n";
00973d4 Koen Kooi narcissus: further pseudo integration
koenkooi authored
206 passthru ("scripts/assemble-image.sh $machine $name-image $imagetype $manifest $sdk $sdkarch && exit", $installretval);
48047a1 Koen Kooi narcissus: move stats collecting to assembly time
koenkooi authored
207 print "<div id=\"retval-image\">$installretval</div>";
82108f9 Koen Kooi narcissus: install packages one by one to make it possible to provide a ...
koenkooi authored
208 }
209
bfaceb0 Koen Kooi narcissus: working implementation, now we can move to package selection ...
koenkooi authored
210
211
973b889 Koen Kooi narcissus: start using xmlhttprequest
koenkooi authored
212 ?>
Something went wrong with that request. Please try again.