summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-06-19 14:23:12 -0400
committerEudyptula <eitan@mosenkis.net>2009-06-19 14:23:12 -0400
commit5494492326fe0f7ea6127cfeaa1858e3c03a7da0 (patch)
treef7ce84b76ef22067270a75bb63bb2d3f5d88ee87 /backend
parentUpdated todo (diff)
downloadingenue-5494492326fe0f7ea6127cfeaa1858e3c03a7da0.tar.gz
ingenue-5494492326fe0f7ea6127cfeaa1858e3c03a7da0.tar.bz2
ingenue-5494492326fe0f7ea6127cfeaa1858e3c03a7da0.zip
Transitioned to support multiple profiles, chosen in the frontend, to use data in Packages file header, began restructuring of frontend build creator
Diffstat (limited to 'backend')
-rw-r--r--backend/functions/build.php58
-rw-r--r--backend/functions/get_profile_headers.php17
2 files changed, 48 insertions, 27 deletions
diff --git a/backend/functions/build.php b/backend/functions/build.php
index 9859020..3346218 100644
--- a/backend/functions/build.php
+++ b/backend/functions/build.php
@@ -1,39 +1,43 @@
<?php
-// Sample variables (will be in config file or user input)
-$conf['pkgdir']='/home/eitan/soc/tinderbox/default-linux-amd64';
-// $conf['cflags']='-march=nocona -O2 -pipe'; // Not needed in a binary install
-// $conf['cxxflags']='$CFLAGS'; // Not needed in a binary install
-$conf['chost']='x86_64-pc-linux-gnu';
-$conf['port_logdir']='$W/log';
-$conf['emerge_log_dir']=$conf['port_logdir'];
-$conf['emerge_default_opts']='-t -K --color=n --root-deps=rdeps';
-$conf['portage_tmpdir']='$W/tmp';
$profile='/etc/make.profile';
// This is the main function that carries out a build from start to finish
function build(&$build) {
- global $conf, $profile;
+ 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);
+ $headers=get_profile_headers($profile);
+ $makeconf['pkgdir']=$conf['pkgdir_root'].'/'.$profile->pkgdir;
+ $makeconf['chost']=$headers['chost'];
$build->status='build/started';
$build->write();
- define('W', WORK.'/build-'.$build->id);
- fatal(log_status('Creating work directory '.W, mkdir(W, 0700)));
- fatal(log_status('Creating '.W.'/image', mkdir(W.'/image', 0700)));
- define('I', W.'/image');
- fatal(log_status('Creating '.W.'/config_root', mkdir(W.'/config_root', 0700)));
- define('C', W.'/config_root');
- fatal(log_status('Creating '.C.'/etc', mkdir(C.'/etc', 0700)));
- fatal(log_status('Creating '.C.'/etc/portage', mkdir(C.'/etc/portage', 0700)));
- fatal(log_status('Creating '.W.'/log', mkdir(W.'/log', 0700)));
- fatal(log_status('Creating '.W.'/tmp', mkdir(W.'/tmp', 0700)));
- $makeconf='W="'.W.'"'."\n";
- foreach ($conf as $name => $val) {
- $makeconf.=strtoupper($name).'="'.$val.'"'."\n";
+ $W=WORK.'/build-'.$build->id;
+ fatal(log_status('Creating work directory '.$W, mkdir($W, 0700)));
+ $I=$W.'/image';
+ fatal(log_status('Creating '.$I, mkdir($I, 0700)));
+ $C=$W.'/config_root';
+ fatal(log_status('Creating '.$C, mkdir($C, 0700)));
+ fatal(log_status("Making symlink $C/etc -> $C", symlink('.', "$C/etc")));
+ fatal(log_status('Creating '.$W.'/log', mkdir($W.'/log', 0700)));
+ $makeconf['port_logdir']=$W.'/log';
+ $makeconf['emerge_log_dir']=$conf['port_logdir'];
+ fatal(log_status('Creating '.$W.'/tmp', mkdir($W.'/tmp', 0700)));
+ $makeconf['portage_tmpdir']=$W.'/tmp';
+ $makeconf['emerge_default_opts']=$conf['emerge_default_opts'];
+ $contents='';
+ foreach ($makeconf as $name => $val) { // TODO maybe shell_escape $val
+ $contents.=strtoupper($name).'="'.$val.'"'."\n";
}
- fatal(log_status('Writing '.C.'/make.conf:'."\n".indent($makeconf), file_put_contents(C.'/etc/make.conf', $makeconf)));
unset($makeconf);
- fatal(log_status('Making make.profile symlink to '.$profile, symlink($profile, C.'/etc/make.profile')));
+ fatal(log_status('Writing '.$C.'/make.conf:'."\n".indent($contents), file_put_contents($C.'/etc/make.conf', $contents)));
+ unset($contents);
+ fatal(log_status('Making make.profile symlink to '.$conf['portdir'].'/profiles/'.$headers['profile'], symlink($conf['portdir'].'/profiles/'.$headers['profile'], $C.'/etc/make.profile')));
$env=array(
- 'PORTAGE_CONFIGROOT' => C,
- 'ROOT' => I
+ 'PORTAGE_CONFIGROOT' => $C,
+ 'ROOT' => $I
);
fatal(!log_command($build, 'emerge --info', null, $env)!=0);
fatal(!log_command($build, 'emerge -pv system', null, $env)!=0);
diff --git a/backend/functions/get_profile_headers.php b/backend/functions/get_profile_headers.php
new file mode 100644
index 0000000..0a63f61
--- /dev/null
+++ b/backend/functions/get_profile_headers.php
@@ -0,0 +1,17 @@
+<?php
+function get_profile_headers($profile) {
+ global $conf;
+ $file=fopen($conf['pkgdir_root'].'/'.$profile->pkgdir.'/Packages', 'r');
+ $headers=array();
+ while (true) {
+ $line=rtrim(fgets($file));
+ if (strlen($line) == 0) {
+ break;
+ } elseif (preg_match('/^([a-zA-Z0-9_-]+): (.*)$/', $line, $match)) {
+ $headers[strtolower($match[1])]=$match[2];
+ }
+ }
+ fclose($file);
+ return $headers;
+}
+?>