Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

narcissus: first successfull frontend <> backend communication

  • Loading branch information...
commit 9c0cb8913d198b9ce5c513b61892402e588b419f 1 parent 2a331c2
Koen Kooi koenkooi authored
27 backend.php
View
@@ -13,20 +13,33 @@
$base_pkg_set = " task-base angstrom-version ";
-function pkg_selection() {
- print "foo!";
+if (isset($_GET["machine"])) {
+ $machine = $_GET["machine"];
+} else {
+ print "Invalid machine";
+ exit;
}
-function assemble_image($pkgs) {
- system ("scripts/assemble-image.sh beagleboard test-image");
+if (isset($_GET["name"]) && $_GET["name"] != "") {
+ $name = $_GET["name"];
+} else {
+ $name = "unnamed";
+}
+
+function assemble_image($machine, $name, $pkgs) {
+ system ("scripts/assemble-image.sh $machine $name-image");
}
-print "Online image builder for angstrom\n<br> configured for beagleboard and test-image\n<br>";
+print "Online image builder for angstrom\n<br> configured for $machine and $name-image\n<br>";
print "<pre>";
-assemble_image($base_pkg_set);
+assemble_image($machine, $name, $base_pkg_set);
print "<pre>";
-print "<p><a href='deploy/beagleboard/beagleboard-test-image.tar.bz2'>your image!</a>";
+if (file_exists("deploy/$machine/$machine-$name-image.tar.bz2")) {
+ print "<p><a href='deploy/$machine/$machine-$name-image.tar.bz2'>your image!</a>";
+} else {
+ print "Image not found, something went wrong :/";
+}
?>
BIN  conf/omap3evm/angstrom-feed-configs_1.0-r7.1_omap3evm.ipk
View
Binary file not shown
BIN  conf/qemux86/angstrom-feed-configs_1.0-r7.1_qemux86.ipk
View
Binary file not shown
7 conf/qemux86/arch.conf
View
@@ -0,0 +1,7 @@
+arch all 1
+arch any 6
+arch noarch 11
+arch i386 16
+arch i486 21
+arch i586 26
+arch qemux86 56
25 index.php
View
@@ -8,28 +8,29 @@
/* Narcissus - Online image builder for the angstrom distribution
* Koen Kooi (c) 2008 - all rights reserved
*/
-?>
-<form action="post">
- <p>
- Machine:
-<select name="machine">
-<?
+function machine_dropdown() {
if ($handle = opendir ('./conf/'))
{
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir ($handle)))
{
- if ($file != "." && $file != "..")
- {
- print ("<option value='$file'>$file</option>");
- }
+ if ($file != "." && $file != "..")
+ {
+ print ("<option value='$file'>$file</option>");
+ }
}
closedir ($handle);
}
+}
+
?>
+<form name="entry_form" onsubmit="javascript:assembleImage();return false">
+ Machine:
+
+<select name="machine">
+<? machine_dropdown(); ?>
</select >
- </p>
Image name:
@@ -37,5 +38,7 @@
</form>
+<div id="image_progress"></div>
+
</body>
</html>
47 internal_request.js
View
@@ -12,3 +12,50 @@ function createRequestObject(){
}
return request_o; //return the object
}
+
+/* The variable http will hold our new XMLHttpRequest object. */
+var http = createRequestObject();
+
+/* Function called to get the product categories list */
+function assembleImage(){
+ document.getElementById('image_progress').innerHTML = "";
+ /* Create the request. The first argument to the open function is the method (POST/GET),
+ and the second argument is the url...
+ document contains references to all items on the page
+ We can reference document.entry_form.machine.value and we will
+ be referencing the dropdown list. The selectedIndex property will give us the
+ index of the selected item.
+ */
+ http.open('get', 'backend.php?action=assemble_image&machine=' + document.entry_form.machine.value + '&name=' + document.entry_form.name.value);
+
+ /* Define a function to call once a response has been received. This will be our handleProductCategories function that we define below. */
+ http.onreadystatechange = imageProgress;
+ /* Send the data. We use something other than null when we are sending using the POST method. */
+ http.send(null);
+}
+
+/* Function called to handle the list that was returned from the internal_request.php file.. */
+function imageProgress(){
+ /* Make sure that the transaction has finished. The XMLHttpRequest object
+ has a property called readyState with several states:
+ 0: Uninitialized
+ 1: Loading
+ 2: Loaded
+ 3: Interactive
+ 4: Finished */
+ if(http.readyState == 4){ //Finished loading the response
+ /* We have got the response from the server-side script,
+ let's see just what it was. using the responseText property of
+ the XMLHttpRequest object. */
+ var response = http.responseText;
+ /* And now we want to change the image_progress <div> content.
+ we do this using an ability to get/change the content of a page element
+ that we can find: innerHTML. */
+ document.getElementById('image_progress').innerHTML = response;
+ }
+}
+
+
+
+
+
3  scripts/assemble-image.sh
View
@@ -15,7 +15,8 @@ if [ -e conf/${MACHINE}/arch.conf ] ; then
mkdir -p ${TARGET_DIR}/usr/lib/opkg
cp conf/${MACHINE}/arch.conf ${OPKG_CONFDIR_TARGET}
else
- echo "Machine config not found"
+ echo "Machine config not found for machine ${MACHINE}:"
+ ls conf/${MACHINE}/
exit 0
fi
Please sign in to comment.
Something went wrong with that request. Please try again.