summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-06-22 14:39:19 -0400
committerEudyptula <eitan@mosenkis.net>2009-06-22 14:39:19 -0400
commit05cf0d093afd50cb386982dbe1c7e1c9a06e665d (patch)
tree56051e486780e5bd31cf3054e3d6076d68e60cd4 /backend
parentAdded pagination to frontend log viewer; updated todo (diff)
downloadingenue-05cf0d093afd50cb386982dbe1c7e1c9a06e665d.tar.gz
ingenue-05cf0d093afd50cb386982dbe1c7e1c9a06e665d.tar.bz2
ingenue-05cf0d093afd50cb386982dbe1c7e1c9a06e665d.zip
Added basic support for adding arbitrary packages in frontend and backend, tar/gz-ing of finished images to backend
Diffstat (limited to 'backend')
-rwxr-xr-xbackend/backend.php6
-rw-r--r--backend/functions/build.php22
2 files changed, 18 insertions, 10 deletions
diff --git a/backend/backend.php b/backend/backend.php
index 6cfb28e..d6e4cb4 100755
--- a/backend/backend.php
+++ b/backend/backend.php
@@ -24,14 +24,18 @@ while (true) {
$build->start=time();
$build->write();
echo 'Starting build id='.$build->id."\n";
+ $image=null;
try {
- build($build);
+ $image=build($build);
} catch (Exception $e) {
echo 'Caught exception: '.$e->getMessage()."\n";
}
$build->finish=time();
$build->write();
echo 'Finished with build id='.$build->id."\n";
+ if (isset($image)) {
+ echo "Completed image at $image\n";
+ }
}
echo 'Sleeping...';
sleep(5);
diff --git a/backend/functions/build.php b/backend/functions/build.php
index 6ca2ff6..6ea9def 100644
--- a/backend/functions/build.php
+++ b/backend/functions/build.php
@@ -3,12 +3,8 @@ $profile='/etc/make.profile';
// This is the main function that carries out a build from start to finish
function build(&$build) {
global $pdo, $conf, $profile;
- $r=$pdo->query('SELECT * FROM `buildopts` WHERE `build`="'.$build->id.'"');
- while ($opt=$r->fetch(PDO::FETCH_ASSOC)) {
- $opt=new sql_buildopt($opt);
- $opts[$opt->name]=$opt;
- }
- $profile=new sql_profile($opts['profile']->value);
+ $opts=$build->get_buildopts();
+ $profile=new sql_profile($opts['profile']);
$headers=$profile->get_headers();
$makeconf['pkgdir']=$conf['pkgdir_root'].'/'.$profile->pkgdir;
$makeconf['chost']=$headers['chost'];
@@ -40,8 +36,16 @@ function build(&$build) {
'PORTAGE_CONFIGROOT' => $C,
'ROOT' => $I
);
- fatal(!log_command($build, 'emerge --info', null, $env)!=0);
- fatal(!log_command($build, 'emerge -pv system', null, $env)!=0);
- fatal(!log_command($build, 'emerge -v system', null, $env)!=0);
+ fatal(log_command($build, 'emerge --info', null, $env) ==0 );
+ fatal(log_command($build, 'emerge -p system', null, $env) ==0 );
+ fatal(log_command($build, 'emerge system', null, $env) ==0 );
+ if (isset($opts['install_packages'])) {
+ fatal(log_command($build, 'emerge -p '.$opts['install_packages'], null, $env) == 0);
+ foreach (explode(' ', $opts['install_packages']) as $atom) {
+ fatal(log_command($build, 'emerge '.$atom, null, $env) == 0);
+ }
+ }
+ fatal(log_command($build, "tar -p --same-owner -cxvf '$W/image.tar.gz' -C '$W' .") == 0);
+ return "$W/image.tar.gz";
}
?>