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
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
-rwxr-xr-xbackend/backend.php6
-rw-r--r--backend/functions/build.php22
-rw-r--r--frontend/pages/wizard.php2
-rw-r--r--frontend/wizard/step1.php6
-rw-r--r--frontend/wizard/step2.php38
-rw-r--r--shared/classes/build.php5
-rw-r--r--shared/classes/profile.php6
-rw-r--r--shared/config.php2
8 files changed, 67 insertions, 20 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";
}
?>
diff --git a/frontend/pages/wizard.php b/frontend/pages/wizard.php
index 9f2af1d..bf3ca32 100644
--- a/frontend/pages/wizard.php
+++ b/frontend/pages/wizard.php
@@ -26,6 +26,7 @@ function init_wizard() {
$proc='wizard_process_step'.$step;
if (function_exists($proc)) {
if ($proc() === true) {
+ debug('wizard', "Step $step returned <i>true</i> - config finished!");
$build->status='build/ready';
$build->ctime=time();
$build->write();
@@ -82,6 +83,7 @@ function body_wizard() {
} else {
$build=&$S['wizard.build'];
$step=&$S['wizard.step'];
+ echo '<h3>'.$S['title'].'</h3>';
echo '<form action="'.url('create/'.$build->id).'" method="post">';
require_once(FRONTEND."/wizard/step$step.php");
$proc='wizard_body_step'.$step;
diff --git a/frontend/wizard/step1.php b/frontend/wizard/step1.php
index ab3fea5..cb8d2bf 100644
--- a/frontend/wizard/step1.php
+++ b/frontend/wizard/step1.php
@@ -1,12 +1,11 @@
<?php
function wizard_init_step1() {
- return array('title' => 'Create - Step 1');
+ return array('title' => 'Step 1 - Choose Profile');
}
function wizard_body_step1() {
global $S;
$build=&$S['wizard.build'];
- $opts=$build->get_buildopts();
- echo '<h3>Step 1</h3>';
+ //$opts=$build->get_buildopts(); // TODO use this to set selected="selected" on the current profile
echo 'Profile: <select name="pkgdir">';
$r=$S['pdo']->query('SELECT * FROM `profiles` WHERE `flags` NOT LIKE "%d%"'); // d for disabled
while ($profile=$r->fetch(PDO::FETCH_ASSOC)) {
@@ -21,6 +20,5 @@ function wizard_process_step1() {
$profile=new sql_profile($request['pkgdir']);
$profileopt=new sql_buildopt($S['wizard.build']->id, 'profile', $profile->pkgdir);
$profileopt->write();
- return true;
}
?>
diff --git a/frontend/wizard/step2.php b/frontend/wizard/step2.php
new file mode 100644
index 0000000..5ce0c46
--- /dev/null
+++ b/frontend/wizard/step2.php
@@ -0,0 +1,38 @@
+<?php
+function wizard_init_step2() {
+ return array('title' => 'Step 2 - Choose Extra Packages');
+}
+function wizard_body_step2() {
+ global $S;
+ $build=&$S['wizard.build'];
+ $opts=$build->get_buildopts();
+ $profile=new sql_profile($opts['profile']);
+ $categories=$profile->get_packages();
+ echo '<ul>';
+ foreach ($categories as $cat => $packages) {
+ echo '<li><b>'.htmlentities($cat).'</b><ul>';
+ foreach ($packages as $name => $vers) {
+ echo '<li>'.htmlentities($name).'<ul>';
+ foreach ($vers as $ver => $attrs) {
+ $safename=htmlentities("$cat/$name-$ver");
+ echo '<li'.($attrs['masked']?' style="color: red"':'').'><input id="pkg-'.$safename.'" type="checkbox" name="extra_packages[='.$safename.']" /><label class="pointer" for="pkg-'.$safename.'">'.htmlentities($ver).' - '.htmlentities($attrs['description']).'</label></li>';
+ }
+ echo '</ul></li>';
+ }
+ echo '</ul></li>';
+ }
+}
+function wizard_process_step2() {
+ global $S, $request;
+ $packages=array();
+ if (isset($request['extra_packages'])) {
+ foreach ($request['extra_packages'] as $name => $null) {
+ $packages[]=$name;
+ }
+ }
+ $packages=implode(' ', $packages);
+ $opt=new sql_buildopt($S['wizard.build']->id, 'install_packages', $packages);
+ $opt->write();
+ return true;
+}
+?>
diff --git a/shared/classes/build.php b/shared/classes/build.php
index 8907693..a2c2a0f 100644
--- a/shared/classes/build.php
+++ b/shared/classes/build.php
@@ -60,14 +60,15 @@ class sql_build extends sql_row_obj {
return $this->id;
}
// Fetches all available buildopts pertaining to this build in a nice array
- function get_buildopts() {
+ function &get_buildopts() {
global $S;
$r=$S['pdo']->query('SELECT * FROM `buildopts` WHERE `build`="'.$this->id.'"');
$opts=array();
while ($opt=$r->fetch(PDO::FETCH_ASSOC)) {
$opt=new sql_buildopt($opt);
- $opts=&$opt;
+ $opts[$opt->name]=$opt->value; // TODO maybe we should return the actual objects
}
+ return $opts;
}
}
?>
diff --git a/shared/classes/profile.php b/shared/classes/profile.php
index 055ad97..4f89f4f 100644
--- a/shared/classes/profile.php
+++ b/shared/classes/profile.php
@@ -24,11 +24,11 @@ class sql_profile extends sql_row_obj {
)
);
- private function &open_Packages() {
+ private function open_Packages() {
global $conf;
return fopen($conf['pkgdir_root'].'/'.$this->pkgdir.'/Packages', 'r');
}
- public function &get_headers($return_filehandle=false) {
+ public function get_headers($return_filehandle=false) {
$file=$this->open_Packages();
$headers=array();
while (!feof($file)) {
@@ -63,7 +63,7 @@ class sql_profile extends sql_row_obj {
}
list($name, $val)=array_merge(explode(': ', $line, 2), array(null));
if ($name == 'CPV') {
- if (preg_match('#^([^/]+)/(.+?)-([^-]+)(-r[0-9]+)?$#', $val, $match)) {
+ if (preg_match('#^([^/]+)/(.+?)-([^-]+)((?:-r[0-9]+)?)$#', $val, $match)) {
list(, $cat, $name, $ver, $r)=$match;
$ver.=$r;
} else {
diff --git a/shared/config.php b/shared/config.php
index 3b62b3f..3e7affd 100644
--- a/shared/config.php
+++ b/shared/config.php
@@ -12,7 +12,7 @@ $conf['timezone']=10800; // Time difference in seconds between UTC and the defau
$conf['mod_rewrite']=true; // Use mod_rewrite for pretty URLs
$conf['check_email_dns']=true; // Use DNS to check the domain of submitted emails for validity
$conf['pkgdir_root']='/home/eitan/soc/tinderbox'; // The directory to recursively search for pkgdirs in
-$conf['emerge_default_opts']='-t -K --color=n --root-deps=rdeps'; // DON'T CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING
+$conf['emerge_default_opts']='-t -v -K --color=n --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;
?>