summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEitan Mosenkis <eitan@mosenkis.net>2009-06-16 10:48:55 -0400
committerEitan Mosenkis <eitan@mosenkis.net>2009-06-16 10:48:55 -0400
commite4d14fce4c099a5400d44dfdc4ae792316b417a4 (patch)
tree93b2133df99905320ae882d3efe408e93ae1d922
parentMinor tweaks to tempdir (diff)
downloadingenue-e4d14fce4c099a5400d44dfdc4ae792316b417a4.tar.gz
ingenue-e4d14fce4c099a5400d44dfdc4ae792316b417a4.tar.bz2
ingenue-e4d14fce4c099a5400d44dfdc4ae792316b417a4.zip
Started build function and moved include/functions to include/includes
-rwxr-xr-xbackend/backend.php3
-rw-r--r--backend/functions/build.php8
-rw-r--r--backend/functions/log.php2
-rw-r--r--backend/functions/tempdir.php4
-rw-r--r--shared/include/functions.php10
-rw-r--r--shared/include/includes.php12
6 files changed, 24 insertions, 15 deletions
diff --git a/backend/backend.php b/backend/backend.php
index b8c651c..d16497a 100755
--- a/backend/backend.php
+++ b/backend/backend.php
@@ -1,7 +1,7 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__).'/../shared/include/paths.php'); // USE __DIR__ once 5.3.0 is out
-require_once(SHARED.'/include/functions.php');
+require_once(SHARED.'/include/includes.php');
pcntl_signal(SIGCHLD, SIG_IGN); // Avoid zombie processes - TODO get rid of this, we generally don't want to keep going with children in the background, or if we do, we'll set a real handler there.
$opts=getopt('f');
if (isset($opts['f'])) {
@@ -10,6 +10,7 @@ if (isset($opts['f'])) {
case -1:
die("Failed to fork");
case 0:
+ echo "Forked. Commiting suicide.\n";
exit;
default:
echo "I am the child!\n";
diff --git a/backend/functions/build.php b/backend/functions/build.php
index 56beaef..5823398 100644
--- a/backend/functions/build.php
+++ b/backend/functions/build.php
@@ -1,7 +1,11 @@
<?php
// This is the main function that carries out a build from start to finish
function build() {
- define('W', tempdir(WORK, 'build-'));
- echo "BUILD!\n";
+ do {
+ $id=randstring(6);
+ define('W', WORK.'/build-'.$id);
+ } while (is_dir(W));
+ mkdir(W, 0700);
+ mkdir(W.'/etc/portage', 0700, true);
}
?>
diff --git a/backend/functions/log.php b/backend/functions/log.php
new file mode 100644
index 0000000..acb6c35
--- /dev/null
+++ b/backend/functions/log.php
@@ -0,0 +1,2 @@
+<?php
+?>
diff --git a/backend/functions/tempdir.php b/backend/functions/tempdir.php
index 4ce3b90..cbda127 100644
--- a/backend/functions/tempdir.php
+++ b/backend/functions/tempdir.php
@@ -1,10 +1,10 @@
<?php
// Adapted from code by Ron Korving (http://us3.php.net/manual/en/function.tempnam.php#61436)
-function tempdir($dir, $prefix='', $mode=0700) {
+function tempdir($dir, $prefix='', $mode=0700, $recursive=false) {
if (substr($dir, -1) != '/') $dir .= '/';
do {
$path = $dir.$prefix.randstring(6);
- } while (!mkdir($path, $mode));
+ } while (!mkdir($path, $mode, $recursive));
return $path;
}
?>
diff --git a/shared/include/functions.php b/shared/include/functions.php
deleted file mode 100644
index 3583b44..0000000
--- a/shared/include/functions.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-// Load shared functions and the ones specific to either foreground or background
-$dir=realpath($_SERVER['PHP_SELF']) == BACKEND.'/backend.php'?BACKEND:FRONTEND;
-foreach (array(SHARED, $dir) as $dir) {
- foreach (glob($dir.'/functions/*.php') as $file) {
- require_once($file);
- }
-}
-unset($dir);
-?>
diff --git a/shared/include/includes.php b/shared/include/includes.php
new file mode 100644
index 0000000..1f465fd
--- /dev/null
+++ b/shared/include/includes.php
@@ -0,0 +1,12 @@
+<?php
+// Load functions and classes from the shared directory and either foreground or background
+$dir=realpath($_SERVER['PHP_SELF']) == BACKEND.'/backend.php'?BACKEND:FRONTEND;
+foreach (array('functions', 'classes') as $type) {
+ foreach (array(SHARED, $dir) as $dir) {
+ foreach (glob("$dir/$type/*.php") as $file) {
+ require_once($file);
+ }
+ }
+}
+unset($dir);
+?>