summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-06-30 17:34:30 -0400
committerEudyptula <eitan@mosenkis.net>2009-06-30 17:34:30 -0400
commita45898a7f4d4ed4b4ac7fc95c7d711888a21e85a (patch)
tree54f4db12a5f3c3d507f3c7a10f834306597e532e
parentFix small mistakes in build function (diff)
downloadingenue-a45898a7f4d4ed4b4ac7fc95c7d711888a21e85a.tar.gz
ingenue-a45898a7f4d4ed4b4ac7fc95c7d711888a21e85a.tar.bz2
ingenue-a45898a7f4d4ed4b4ac7fc95c7d711888a21e85a.zip
Many fixes to CD building and some to command execution/logging
-rw-r--r--backend/functions/build.php29
-rw-r--r--backend/functions/signals.php4
-rw-r--r--depend2
-rw-r--r--shared/classes/task.php22
-rw-r--r--shared/config.php3
-rw-r--r--todo5
6 files changed, 39 insertions, 26 deletions
diff --git a/backend/functions/build.php b/backend/functions/build.php
index 1c4f457..a5e2058 100644
--- a/backend/functions/build.php
+++ b/backend/functions/build.php
@@ -58,28 +58,29 @@ function build(&$build) {
} elseif ($imgtype == 'tgz') {
sql_task::execute_command('Compress finished image to tar/gz', "tar -p --same-owner -czvf '$W/image.tar.gz' -C '$W/image' .", $build, true, null, $env);
rename($W.'/image.tar.gz', COMPLETED.'/build-'.$build->id.'.tar.gz') || throw_exception('rename failed');
- } elseif ($imgtype == 'livecd') {
- sql_task::execute_command('Compress finished image to squashfs', "mksquashfs '$W/image' '$W/image.squashfs' -info ", $build, true, null, $env);
- } elseif ($imgtype !== 'installcd') {
- throw_exception('invalid image type: '.$imgtype);
- }
- if ($imgtype == 'livecd' || $imgtype == 'installcd') {
- $minimaliso='/home/eitan/soc/install-amd64-minimal-20090625.iso';
+ } elseif ($imgtype == 'livecd' || $imgtype == 'installcd') {
+ if (strpos($headers['chost'], 'x86_64') === false)
+ $minimaliso='/home/eitan/soc/install-x86-minimal-20090623.iso';
+ else
+ $minimaliso='/home/eitan/soc/install-amd64-minimal-20090625.iso';
sql_task::execute_command('Mount minimal CD image', "mount -o loop -t iso9660 '$minimaliso' '$W/tmp'", $build, true, null, $env);
sql_task::execute_command('Copy CD image to writable temp directory', "cp -va '$W/tmp' '$W/cd'", $build, true, null, $env);
sql_task::execute_command('Unmount CD image', "umount '$W/tmp'", $build, true, null, $env);
+ sql_task::execute_command('Copy kernel and initrd from CD to image', "cp -va '$W/cd/isolinux/gentoo' '$W/cd/isolinux/gentoo.igz' '$W/image/boot/'", $build, true, null, $env);
+ file_put_contents("$W/unsquashfs-files", "/lib64/modules\n\lib\modules\n");
+ sql_task::execute_command('Copy kernel modules from SquashFS to image', "unsquashfs -i -d '$W/image' -e '$W/unsquashfs-files' '$W/cd/image.squashfs'", $build, true, null, $env);
if ($imgtype == 'livecd') {
- rename($W.'/image.squashfs', $W.'/cd/image.squashfs') || throw_exception('rename failed');
- } else {
- sql_task::execute_command('Copy kernel modules to image', "cp -va '$W/cd/lib/modules' '$W/image/lib/'", $build, true, null, $env);
- sql_task::execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$W/image.tar.bz2' -C '$W/image' .", $build, true, null, $env);
- rename($W.'/image.tar.bz2', $W.'/cd/image.tar.bz2') || throw_exception('rename failed');
- }
- // TODO port the rest of /usr/lib/catalyst/targets/support/create-iso.sh
+ rename("$W/cd/image.squashfs", "$W/image.squashfs.old") || debug('Failed to move old SquashFS');
+ sql_task::execute_command('Compress finished image to squashfs', "mksquashfs '$W/image' '$W/cd/image.squashfs' -noappend -info", $build, true, null, $env);
+ } else // Install CD
+ sql_task::execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$W/cd/image.tar.bz2' -C '$W/image' .", $build, true, null, $env);
+ // TODO port the rest of /usr/lib/catalyst/targets/support/create-iso.sh to support other bootloaders
// ISOLINUX bootloader
// mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path}
sql_task::execute_command('Create ISO image', "mkisofs -J -R -l -V 'Ingenue Build $build->id' -o '$W/image.iso' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table '$W/cd'", $build, true, null, $env);
rename("$W/image.iso", COMPLETED.'/build-'.$build->id.'.iso') || throw_exception('rename failed');
+ } else {
+ throw_exception('invalid image type: '.$imgtype);
}
if (!$conf['debug']) {
sql_task::execute_command('Delete work directory', 'rm -rf "'.$W.'"', $build, true, null, $env);
diff --git a/backend/functions/signals.php b/backend/functions/signals.php
index bb3d44d..effea2f 100644
--- a/backend/functions/signals.php
+++ b/backend/functions/signals.php
@@ -8,14 +8,14 @@ function handle_signal($sig=null) {
$task->finish=time();
$task->exit=-$sig;
$task->write();
- debug('task '.$task->id.' given exit status '.-$sig);
+ debug("build $build->id task $task->order given exit status -$sig");
} else {
debug('$task not set');
}
$build->finish=time();
$build->status='finished/failed: got signal '.$sig;
$build->write();
- debug('build '.$build->id.' given status '.$build->status);
+ debug("build $build->id given status $build->status");
}
debug("\nGot signal $sig - exiting");
exit;
diff --git a/depend b/depend
index 2857fae..0913499 100644
--- a/depend
+++ b/depend
@@ -1,4 +1,4 @@
->=dev-lang/php-5.2.2 USE=pdo hash pcntl pcre cli pdo mysqli apache2
+>=dev-lang/php-5.2.2 USE=pdo hash pcntl pcre cli pdo mysqli apache2 curl
sys-apps/fakeroot ?
sys-apps/portage # In case you use paludis
www-servers/apache APACHE2_MODULES=rewrite?
diff --git a/shared/classes/task.php b/shared/classes/task.php
index 2fb7c68..796864f 100644
--- a/shared/classes/task.php
+++ b/shared/classes/task.php
@@ -50,16 +50,19 @@ class sql_task extends sql_row_obj {
if (isset($this->start)) {
if (isset($this->finish)) {
$html.='<span class="status ';
- if ($this->exit == 0) {
+ if ($this->exit === '0') {
$html.='successful">[successful';
} else {
$html.='failed">[';
- if ($this->exit > 0)
- $html.='exit status '.$this->exit;
- elseif ($this->exit == -128)
- $html.='got unknown signal';
- else
- $html.='got signal '.-$this->exit;
+ if (isset($this->exit)) {
+ if ($this->exit > 0)
+ $html.='exit status '.$this->exit;
+ elseif ($this->exit == -128)
+ $html.='got unknown signal';
+ else
+ $html.='got signal '.-$this->exit;
+ } else
+ $html.='failed to execute';
}
$html.=']</span> <span class="time">Finished in <span class="time">'.display_time($this->finish-$this->start).'</span></span>';
} else {
@@ -89,6 +92,11 @@ class sql_task extends sql_row_obj {
$this->start=time();
$this->write();
$p=proc_open($this->command, $descriptorspec, $pipes, $path, $env);
+ if ($p === false) {
+ $this->finish=time();
+ $this->write();
+ throw_exception('Failed to execute command: '.$this->command);
+ }
foreach ($pipes as $pipe) {
stream_set_blocking($pipe, 0);
}
diff --git a/shared/config.php b/shared/config.php
index fb61824..53ab10a 100644
--- a/shared/config.php
+++ b/shared/config.php
@@ -16,4 +16,7 @@ $conf['pkgdir_root']='/home/eitan/soc/tinderbox'; // The directory to recursivel
$conf['emerge_default_opts']='-t -v -K --color=y --root-deps=rdeps'; // DON'T CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING
$conf['portdir']='/usr/portage'; // The directory conatining the portage tree to use (/usr/portage unless you have a reason to think otherwise)
$conf['logview_max']=1000; // The maximum number of log entries shown on one page (1000 is a good start)
+$conf['split_setip']=true; // Whether the frontend and backend are running on different hosts
+$conf['frontend_location']='http://soc'; // The base address of the frontend installation (for use by the backend)
+$conf['backend_name']='red'; // A name or other way of identifying this backend as opposed to other backends working for the same frontend TODO use gethostname() by default in 5.3.0
?>
diff --git a/todo b/todo
index b196796..35989d1 100644
--- a/todo
+++ b/todo
@@ -17,10 +17,11 @@ Add configurable groups of suggested packages to frontend, backend
Add a statistics page
Add cleanup functions to the frontend and backend
Separate variables we got from the URL from the rest, stop using $request, instead keep super globals and strip slashes on them
-Replace STDOUT, STDERR, echo in backend with variable - either STDOUT, STDERR, or file
-Go back and figure out what should be log_msg and what should be debug, etc.
+Get rid of backend use of echo, debug, etc. and do all logging in the db
Support ~arch installation or remove it from listings
Completely plan out how frontend modules should function - each step needs to report if it finished successfully (required values)
Change over wizard to work on configurations, not actual builds
See if I can figure any way to use classes instead of funny named functions (namespaces in 5.3.0 perhaps) - also needs to have a depend of some sort so we can make a quick-config page that doesn't show things that we don't have enough info for yet (use AJAX to show them when we're ready)
Allow backend to define bail-out functions to call when it dies (things like unmounting the ISO it was copying)
+Add STDERR (maybe STDOUT) only option to log viewer
+Stop directly accessing PKGDIR from the frontend - put whatever info we need in the database and write a script for updating it from the backend