summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-06-24 18:33:43 -0400
committerEudyptula <eitan@mosenkis.net>2009-06-24 18:33:43 -0400
commit914460bfd5cb42be7c7df043475e54e79029a727 (patch)
tree3f1a5549c183834ccd10bb8f77f1e552a419b36f /backend
parentMerged minor updates from SQL into sql_row_obj-based classes (diff)
downloadingenue-914460bfd5cb42be7c7df043475e54e79029a727.tar.gz
ingenue-914460bfd5cb42be7c7df043475e54e79029a727.tar.bz2
ingenue-914460bfd5cb42be7c7df043475e54e79029a727.zip
Cleaned up various unused bits of code; moved finished images to their own directory; moved ANSI text processing from logviewer into its own class; added unique ID to profiles table
Diffstat (limited to 'backend')
-rw-r--r--backend/functions/build.php13
-rw-r--r--backend/functions/log.php22
2 files changed, 15 insertions, 20 deletions
diff --git a/backend/functions/build.php b/backend/functions/build.php
index 8f1bda8..815f45c 100644
--- a/backend/functions/build.php
+++ b/backend/functions/build.php
@@ -1,5 +1,4 @@
<?php
-$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;
@@ -37,27 +36,21 @@ function build(&$build) {
'PATH' => $_ENV['PATH']
);
sql_task::execute_task('emerge --info', $build, true, null, $env);
-// fatal(log_command($build, 'emerge --info', null, $env) == 0);
sql_task::execute_task('emerge -p system', $build, true, null, $env);
-// fatal(log_command($build, 'emerge -p system', null, $env) == 0);
sql_task::execute_task('emerge system', $build, true, null, $env);
-// fatal(log_command($build, 'emerge system', null, $env) == 0);
if (isset($opts['install_packages'])) {
$pkgs=array();
foreach (explode(' ', $opts['install_packages']) as $atom) {
$pkgs[]=escapeshellarg($atom);
}
sql_task::execute_task('emerge -p '.implode(' ', $pkgs), $build, true, null, $env);
-// fatal(log_command($build, 'emerge -p '.implode(' ', $pkgs), null, $env) == 0);
foreach ($pkgs as $atom) {
sql_task::execute_task('emerge '.$atom, $build, true, null, $env);
-// fatal(log_command($build, 'emerge '.$atom, null, $env) == 0);
}
}
sql_task::execute_task("tar -p --same-owner -czvf '$W/image.tar.gz' -C '$W/image' .", $build, true, null, $env);
-// fatal(log_command($build, "tar -p --same-owner -czvf '$W/image.tar.gz' -C '$W/image' .") == 0);
- chmod($W, 0755);
- chmod("$W/image.tar.gz", 0644);
- return "$W/image.tar.gz";
+ rename($W.'/image.tar.gz', COMPLETED.'/build-'.$build->id.'.tar.gz');
+ sql_task::execute_task('rm -rf "'.$W.'"', $build, true, null, $env);
+ return COMPLETED.'/build-'.$build->id.'.tar.gz';
}
?>
diff --git a/backend/functions/log.php b/backend/functions/log.php
index 1a40a43..16476a6 100644
--- a/backend/functions/log.php
+++ b/backend/functions/log.php
@@ -8,15 +8,17 @@ function log_status($msg, $result) {
return $result;
}
function color($msg, $color) {
- $r="\033[0m";
- switch(strtolower($color)) {
- case 'red':
- return "\033[31m$msg$r";
- case 'green':
- return "\033[32m$msg$r";
- }
-}
-function indent($msg, $tabs=1) {
- return str_repeat("\t", $tabs).str_replace("\n", "\n".str_repeat("\t", $tabs), trim($msg));
+ $i=30;
+ $colors=array(
+ 'black' => $i++,
+ 'red' => $i++,
+ 'green' => $i++,
+ 'yellow' => $i++,
+ 'blue' => $i++,
+ 'magenta' => $i++,
+ 'cyan' => $i++,
+ 'white' => $i++
+ );
+ return "\033[".$colors[$color]."m$msg\033[0m";
}
?>