summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rwxr-xr-xbackend/backend.php93
-rw-r--r--backend/bundlers/cd-common.php6
-rw-r--r--backend/bundlers/cd-head.php8
-rw-r--r--backend/bundlers/cd.inc12
-rw-r--r--backend/bundlers/ext2.php12
-rw-r--r--backend/bundlers/ext2/bundle.php6
-rw-r--r--backend/bundlers/ext2/cp.php6
-rw-r--r--backend/bundlers/ext2/mkfs.php4
-rw-r--r--backend/bundlers/ext2/tar.php3
-rw-r--r--backend/bundlers/installcd.php8
-rw-r--r--backend/bundlers/installcd/assemble.php4
-rw-r--r--backend/bundlers/installcd/bundle.php6
l---------backend/bundlers/installcd/cd-common.php1
l---------backend/bundlers/installcd/cd-head.php1
-rw-r--r--backend/bundlers/jffs2.php6
-rw-r--r--backend/bundlers/jffs2/bundle.php4
-rw-r--r--backend/bundlers/jffs2/mkfs.php3
-rw-r--r--backend/bundlers/livecd.php9
-rw-r--r--backend/bundlers/livecd/assemble.php4
-rw-r--r--backend/bundlers/livecd/bundle.php7
l---------backend/bundlers/livecd/cd-common.php1
l---------backend/bundlers/livecd/cd-head.php1
-rw-r--r--backend/bundlers/livecd/livecd-tools.php3
-rw-r--r--backend/bundlers/tbz2.php6
-rw-r--r--backend/bundlers/tbz2/bundle.php4
-rw-r--r--backend/bundlers/tbz2/tar.php3
-rw-r--r--backend/bundlers/tgz.php6
-rw-r--r--backend/bundlers/tgz/bundle.php4
-rw-r--r--backend/bundlers/tgz/tar.php3
-rw-r--r--backend/functions/api.php1
-rw-r--r--backend/functions/signals.php4
-rw-r--r--backend/include/includes.php4
-rw-r--r--backend/modules/gentoo_portage/base-system.php2
-rw-r--r--backend/modules/gentoo_portage/build.php8
-rw-r--r--backend/modules/gentoo_portage/hostname.php2
-rw-r--r--backend/modules/gentoo_portage/init.d.php2
-rw-r--r--backend/modules/gentoo_portage/portage.php10
-rw-r--r--backend/modules/gentoo_portage/setup.php10
-rw-r--r--backend/modules/gentoo_portage/timezone.php6
39 files changed, 130 insertions, 153 deletions
diff --git a/backend/backend.php b/backend/backend.php
index 2874b1a..161b7b2 100755
--- a/backend/backend.php
+++ b/backend/backend.php
@@ -50,7 +50,7 @@ require_once(SHARED.'/include/dbinit.php');
while (true) {
// TODO check first for builds that need to be resumed (and figure out how to resume things)
while (true) {
- $r=query('SELECT * FROM `builds` WHERE `backend`="'.$S['conf']['backend_id'].'" AND `status` IN ("queued","cancel","uploading","upload_failed","building","got_signal") ORDER BY `ctime` ASC LIMIT 1');
+ $r=query('SELECT * FROM `builds` WHERE `backend`="'.$S['conf']['backend_id'].'" AND `status` IN ("queued","cancel","uploading","building","bundling") AND `failed`!="true" ORDER BY `ctime` ASC LIMIT 1');
if ($r->rowCount())
break;
else {
@@ -60,76 +60,37 @@ while (true) {
}
}
$build=new sql_build($r->fetch(PDO::FETCH_ASSOC));
- if (!isset($build->start)) {
- $build->start=time();
- $build->write();
- }
debug('Starting build id='.$build->id);
$file=null;
$owner=$build->get_owner();
- $workdir=WORK."/build-$build->id";
- if (($image=$build->build($workdir)) !== false) {
- try {
- $bundler=$build->get_opt('bundler');
- $bundle_proc="bundle_$bundler";
- if (!function_exists($bundle_proc))
- throw_exception("No bundler function defined for bundler $bundler");
- $opts=$build->get_opts();
- $file=$bundle_proc($image, $workdir, $opts);
- end_internal_task(0); // Just in case
- } catch (Exception $e) {
- log_msg('Caught exception: '.$e->getMessage());
- end_internal_task(1);
- $build->status='failed';
- $build->write();
- xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $S['conf']['title'].' build failed', 'Your build has failed in bundling stage. You can find more information at <a href="'.url("build/$build->id").'">'.url("build/$build->id").'</a>');
- }
- $build->finish=time();
- debug('Finished with build id='.$build->id);
- if (isset($file)) {
- debug("Completed build successfully");
- if ($S['conf']['split_setup']) {
- $build->status='uploading';
- $build->write();
- $key=randstring(30);
- $build->set_opt('uploadkey', $key);
- $c=curl_init(url('backend/upload_image'));
- curl_setopt($c, CURLOPT_POST, 1);
- curl_setopt($c, CURLOPT_POSTFIELDS, array(
- 'build' => $build->id,
- 'key' => $key,
- 'file' => "@$file"
- ));
- curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
- $result=curl_exec($c);
- if ($S['conf']['debug'] && is_string($result)) {
- debug($result);
- }
- if ($result === false || strpos($result, 'Upload successful') === false) {
- $build->status='upload_failed';
- $build->write();
- } else {
- debug("Transferred $file... unlinking it");
- unlink($file);
- $build->status='complete';
- $build->write();
- shell_exec('rm -rf '.escapeshellarg($workdir));
- }
- } else {
- $build->status='complete';
- $base=basename($file);
- $ext=substr($base, strpos($base, '.'));
- rename($file, COMPLETED.'/build-'.$build->id.$ext);
- $build->write();
- shell_exec('rm -rf '.escapeshellarg($workdir));
- }
- xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $S['conf']['title'].' build finished', 'Your build has completed successfully. You can find more information and download the completed image at <a href="'.url("build/$build->id").'">'.url("build/$build->id").'</a>');
- }
- } else {
- $build->status='failed';
+ $workdir=WORK."/$build->id";
+ if ($build->status == 'cancel') {
+ shell_exec('rm -rf '.escapeshellarg($workdir));
+ $build->status='canceled';
$build->write();
- xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $S['conf']['title'].' build failed', 'Your build has failed. You can find more information at <a href="'.url("build/$build->id").'">'.url("build/$build->id").'</a>');
+ continue;
+ }
+ if (isset($build->finish))
+ $build->finish=null;
+ elseif (!isset($build->start))
+ $build->start=time();
+ $build->write();
+ $success=$imagedir=$build->build($workdir);
+ if ($success && !$build->is_canceled()) {
+ $success=$file=$build->bundle($imagedir, $workdir);
+ if ($success && !$build->is_canceled()) {
+ $success=$build->upload($file);
+ }
+ }
+ if ($success) {
+ debug("Completed build successfully");
+ execute_non_vital_command('Delete work directory', 'rm -rf '.escapeshellarg($workdir));
+ $build->status='complete';
}
+ $build->finish=time();
+ $build->write();
+ debug('Finished with build id='.$build->id);
+ xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $S['conf']['title'].' build finished', 'Your build has '.($success?'completed successfully':'failed').'. You can find more information and download the completed image at <a href="'.url("build/$build->id").'">'.url("build/$build->id").'</a>');
unset($build);
}
?>
diff --git a/backend/bundlers/cd-common.php b/backend/bundlers/cd-common.php
new file mode 100644
index 0000000..0a7f3fb
--- /dev/null
+++ b/backend/bundlers/cd-common.php
@@ -0,0 +1,6 @@
+<?php
+makedir("$imagedir/boot");
+execute_command('Extract kernel, initrd, and squashfs from CD image ', LIB."/bkisofs-cli '$minimaliso' extract /isolinux/gentoo '$imagedir/boot/kernel' extract /isolinux/gentoo.igz '$imagedir/boot/initrd' extract /image.squashfs '$workdir/'");
+//file_put_contents("$workdir/unsquashfs-files", "/lib64/modules\n/lib/modules\n");
+execute_command('Extract kernel modules from SquashFS to image', "unsquashfs -i -d '$workdir/modules' '$workdir/image.squashfs' /lib/modules /lib64/modules; cp -avT '$workdir/modules' '$imagedir'; rm -rf '$workdir/modules'");
+?>
diff --git a/backend/bundlers/cd-head.php b/backend/bundlers/cd-head.php
new file mode 100644
index 0000000..2e96bba
--- /dev/null
+++ b/backend/bundlers/cd-head.php
@@ -0,0 +1,8 @@
+<?php
+$profile=new sql_gentoo_profile($opts['profile']);
+$headers=$profile->get_headers();
+if (strpos($headers['chost'], 'x86_64') === false)
+ $minimaliso=CACHE.'/cd/install-x86-minimal-20090623.iso';
+else
+ $minimaliso=CACHE.'/cd/install-amd64-minimal-20090625.iso';
+?>
diff --git a/backend/bundlers/cd.inc b/backend/bundlers/cd.inc
deleted file mode 100644
index 6fb5aac..0000000
--- a/backend/bundlers/cd.inc
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-$profile=new sql_gentoo_profile($opts['profile']);
-$headers=$profile->get_headers();
-if (strpos($headers['chost'], 'x86_64') === false)
- $minimaliso=CACHE.'/cd/install-x86-minimal-20090623.iso';
-else
- $minimaliso=CACHE.'/cd/install-amd64-minimal-20090625.iso';
-makedir("$I/boot");
-execute_command('Extract kernel, initrd, and squashfs from CD image ', LIB."/bkisofs-cli '$minimaliso' extract /isolinux/gentoo '$I/boot/kernel' extract /isolinux/gentoo.igz '$I/boot/initrd' extract /image.squashfs '$W/'");
-//file_put_contents("$W/unsquashfs-files", "/lib64/modules\n/lib/modules\n");
-execute_command('Extract kernel modules from SquashFS to image', "unsquashfs -i -d '$W/modules' '$W/image.squashfs' /lib/modules /lib64/modules; cp -avT '$W/modules' '$I'; rm -rf '$W/modules'");
-?>
diff --git a/backend/bundlers/ext2.php b/backend/bundlers/ext2.php
deleted file mode 100644
index 239b5bb..0000000
--- a/backend/bundlers/ext2.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-function bundle_ext2($I, $W) {
- execute_command('Make blank file for ext2 image', "dd if=/dev/zero of='$W/image.ext2' bs=1024 count=1048576");
- execute_command('Make ext2 filesystem', "mke2fs -t ext2 -F '$W/image.ext2'");
- makedir('ext2');
- execute_command('Mount ext2 image', "mount -o loop -t ext2 '$W/image.ext2' '$W/ext2'");
- execute_command('Copy files to ext2', "cp -va '$I/*' '$W/ext2/'");
- execute_command('Unmount ext2 image', "umount '$W/ext2'");
- execute_command('Compress ext2 image', "gzip '$W/image.ext2'");
- return "$W/image.ext2.gz";
-}
-?>
diff --git a/backend/bundlers/ext2/bundle.php b/backend/bundlers/ext2/bundle.php
new file mode 100644
index 0000000..2418453
--- /dev/null
+++ b/backend/bundlers/ext2/bundle.php
@@ -0,0 +1,6 @@
+<?php
+add_step('mkfs');
+add_step('cp');
+add_step('tar');
+return "$workdir/image.ext2.gz";
+?>
diff --git a/backend/bundlers/ext2/cp.php b/backend/bundlers/ext2/cp.php
new file mode 100644
index 0000000..befbd91
--- /dev/null
+++ b/backend/bundlers/ext2/cp.php
@@ -0,0 +1,6 @@
+<?php
+makedir('ext2');
+execute_command('Mount ext2 image', "mount -o loop -t ext2 '$workdir/image.ext2' '$workdir/ext2'");
+execute_command('Copy files to ext2', "cp -va '$imagedir/*' '$workdir/ext2/'");
+execute_command('Unmount ext2 image', "umount '$workdir/ext2'");
+?>
diff --git a/backend/bundlers/ext2/mkfs.php b/backend/bundlers/ext2/mkfs.php
new file mode 100644
index 0000000..925c93f
--- /dev/null
+++ b/backend/bundlers/ext2/mkfs.php
@@ -0,0 +1,4 @@
+<?php
+execute_command('Make blank file for ext2 image', "dd if=/dev/zero of='$workdir/image.ext2' bs=1024 count=1048576");
+execute_command('Make ext2 filesystem', "mke2fs -t ext2 -F '$workdir/image.ext2'");
+?>
diff --git a/backend/bundlers/ext2/tar.php b/backend/bundlers/ext2/tar.php
new file mode 100644
index 0000000..5e51e1d
--- /dev/null
+++ b/backend/bundlers/ext2/tar.php
@@ -0,0 +1,3 @@
+<?php
+execute_command('Compress ext2 image', "gzip '$workdir/image.ext2'");
+?>
diff --git a/backend/bundlers/installcd.php b/backend/bundlers/installcd.php
deleted file mode 100644
index 63ffb5a..0000000
--- a/backend/bundlers/installcd.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-function bundle_installcd($I, $W, &$opts) {
- require(dirname(__FILE__).'/cd.inc');
- execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$W/image.tar.bz2' -C '$I' .");
- execute_command('Create ISO image', LIB."/bkisofs-cli '$minimaliso' add / '$W/image.tar.bz2' write '$W/image.iso'");
- return "$W/image.iso";
-}
-?>
diff --git a/backend/bundlers/installcd/assemble.php b/backend/bundlers/installcd/assemble.php
new file mode 100644
index 0000000..c4cedc0
--- /dev/null
+++ b/backend/bundlers/installcd/assemble.php
@@ -0,0 +1,4 @@
+<?php
+execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$workdir/image.tar.bz2' -C '$imagedir' .");
+execute_command('Create ISO image', LIB."/bkisofs-cli '$minimaliso' add / '$workdir/image.tar.bz2' write '$workdir/image.iso'");
+?>
diff --git a/backend/bundlers/installcd/bundle.php b/backend/bundlers/installcd/bundle.php
new file mode 100644
index 0000000..384490e
--- /dev/null
+++ b/backend/bundlers/installcd/bundle.php
@@ -0,0 +1,6 @@
+<?php
+require(dirname(__FILE__).'/cd-head.php');
+add_step('cd-common');
+add_step('assemble');
+return "$workdir/image.iso";
+?>
diff --git a/backend/bundlers/installcd/cd-common.php b/backend/bundlers/installcd/cd-common.php
new file mode 120000
index 0000000..70f9287
--- /dev/null
+++ b/backend/bundlers/installcd/cd-common.php
@@ -0,0 +1 @@
+../cd-common.php \ No newline at end of file
diff --git a/backend/bundlers/installcd/cd-head.php b/backend/bundlers/installcd/cd-head.php
new file mode 120000
index 0000000..8a38a03
--- /dev/null
+++ b/backend/bundlers/installcd/cd-head.php
@@ -0,0 +1 @@
+../cd-head.php \ No newline at end of file
diff --git a/backend/bundlers/jffs2.php b/backend/bundlers/jffs2.php
deleted file mode 100644
index c8e5de2..0000000
--- a/backend/bundlers/jffs2.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-function bundle_jffs2($I, $W) {
- execute_command('Create JFFS2 image', "mkfs.jffs2 -x lzo -n -e 0x20000 -l -p -r '$I' -o '$W/image.jffs2'");
- return "$W/image.jffs2";
-}
-?>
diff --git a/backend/bundlers/jffs2/bundle.php b/backend/bundlers/jffs2/bundle.php
new file mode 100644
index 0000000..de198a6
--- /dev/null
+++ b/backend/bundlers/jffs2/bundle.php
@@ -0,0 +1,4 @@
+<?php
+add_step('mkfs');
+return "$workdir/image.jffs2";
+?>
diff --git a/backend/bundlers/jffs2/mkfs.php b/backend/bundlers/jffs2/mkfs.php
new file mode 100644
index 0000000..bf9e702
--- /dev/null
+++ b/backend/bundlers/jffs2/mkfs.php
@@ -0,0 +1,3 @@
+<?php
+execute_command('Create JFFS2 image', "mkfs.jffs2 -x lzo -n -e 0x20000 -l -p -r '$imagedir' -o '$workdir/image.jffs2'");
+?>
diff --git a/backend/bundlers/livecd.php b/backend/bundlers/livecd.php
deleted file mode 100644
index 740c72b..0000000
--- a/backend/bundlers/livecd.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-function bundle_livecd($I, $W, &$opts) {
- emerge('app-misc/livecd-toold', 'Install LiveCD utilities');
- require(dirname(__FILE__).'/cd.inc');
- execute_command('Compress finished image to squashfs', "mksquashfs '$I' '$W/image.squashfs' -noappend -info");
- execute_command('Create ISO image', LIB."/bkisofs-cli '$minimaliso' replace /image.squashfs '$W/image.squashfs' write '$W/image.iso'");
- return "$W/image.iso";
-}
-?>
diff --git a/backend/bundlers/livecd/assemble.php b/backend/bundlers/livecd/assemble.php
new file mode 100644
index 0000000..0371103
--- /dev/null
+++ b/backend/bundlers/livecd/assemble.php
@@ -0,0 +1,4 @@
+<?php
+execute_command('Compress finished image to squashfs', "mksquashfs '$imagedir' '$workdir/image.squashfs' -noappend -info");
+execute_command('Create ISO image', LIB."/bkisofs-cli '$minimaliso' replace /image.squashfs '$workdir/image.squashfs' write '$workdir/image.iso'");
+?>
diff --git a/backend/bundlers/livecd/bundle.php b/backend/bundlers/livecd/bundle.php
new file mode 100644
index 0000000..465404b
--- /dev/null
+++ b/backend/bundlers/livecd/bundle.php
@@ -0,0 +1,7 @@
+<?php
+require(dirname(__FILE__).'/cd-head.php');
+add_step('livecd-tools');
+add_step('cd-common');
+add_step('assemble');
+return "$workdir/image.iso";
+?>
diff --git a/backend/bundlers/livecd/cd-common.php b/backend/bundlers/livecd/cd-common.php
new file mode 120000
index 0000000..70f9287
--- /dev/null
+++ b/backend/bundlers/livecd/cd-common.php
@@ -0,0 +1 @@
+../cd-common.php \ No newline at end of file
diff --git a/backend/bundlers/livecd/cd-head.php b/backend/bundlers/livecd/cd-head.php
new file mode 120000
index 0000000..8a38a03
--- /dev/null
+++ b/backend/bundlers/livecd/cd-head.php
@@ -0,0 +1 @@
+../cd-head.php \ No newline at end of file
diff --git a/backend/bundlers/livecd/livecd-tools.php b/backend/bundlers/livecd/livecd-tools.php
new file mode 100644
index 0000000..13132a3
--- /dev/null
+++ b/backend/bundlers/livecd/livecd-tools.php
@@ -0,0 +1,3 @@
+<?php
+emerge('app-misc/livecd-tools', 'Install LiveCD utilities');
+?>
diff --git a/backend/bundlers/tbz2.php b/backend/bundlers/tbz2.php
deleted file mode 100644
index ee69825..0000000
--- a/backend/bundlers/tbz2.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-function bundle_tbz2($I, $W) {
- execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$W/image.tar.bz2' -C '$I' .");
- return "$W/image.tar.bz2";
-}
-?>
diff --git a/backend/bundlers/tbz2/bundle.php b/backend/bundlers/tbz2/bundle.php
new file mode 100644
index 0000000..6024c3e
--- /dev/null
+++ b/backend/bundlers/tbz2/bundle.php
@@ -0,0 +1,4 @@
+<?php
+add_step('tar');
+return "$workdir/image.tar.bz2";
+?>
diff --git a/backend/bundlers/tbz2/tar.php b/backend/bundlers/tbz2/tar.php
new file mode 100644
index 0000000..2aead89
--- /dev/null
+++ b/backend/bundlers/tbz2/tar.php
@@ -0,0 +1,3 @@
+<?php
+execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$workdir/image.tar.bz2' -C '$imagedir' .");
+?>
diff --git a/backend/bundlers/tgz.php b/backend/bundlers/tgz.php
deleted file mode 100644
index 3b604d3..0000000
--- a/backend/bundlers/tgz.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-function bundle_tgz($I, $W) {
- execute_command('Compress finished image to tar/gz', "tar -p --same-owner -czvf '$W/image.tar.gz' -C '$I' .");
- return "$W/image.tar.gz";
-}
-?>
diff --git a/backend/bundlers/tgz/bundle.php b/backend/bundlers/tgz/bundle.php
new file mode 100644
index 0000000..b283ee7
--- /dev/null
+++ b/backend/bundlers/tgz/bundle.php
@@ -0,0 +1,4 @@
+<?php
+add_step('tar');
+return "$workdir/image.tar.gz";
+?>
diff --git a/backend/bundlers/tgz/tar.php b/backend/bundlers/tgz/tar.php
new file mode 100644
index 0000000..09fbf0c
--- /dev/null
+++ b/backend/bundlers/tgz/tar.php
@@ -0,0 +1,3 @@
+<?php
+execute_command('Compress finished image to tar/gz', "tar -p --same-owner -czvf '$workdir/image.tar.gz' -C '$imagedir' .");
+?>
diff --git a/backend/functions/api.php b/backend/functions/api.php
index d8d648c..cffbf65 100644
--- a/backend/functions/api.php
+++ b/backend/functions/api.php
@@ -57,7 +57,6 @@ function log_msg($msg, $nl=true) {
if (!isset($task)) {
start_internal_task($msg);
debug('log_msg creating task... this is bad');
- return;
}
$msg.=$nl?"\n":'';
debug($msg);
diff --git a/backend/functions/signals.php b/backend/functions/signals.php
index 70231c7..62f5fe3 100644
--- a/backend/functions/signals.php
+++ b/backend/functions/signals.php
@@ -5,6 +5,7 @@ function handle_signal($sig=null) {
unlink($pidfile);
if (isset($build)) {
if (isset($task)) {
+ log_msg("\nGot signal $sig\n");
$task->finish=time();
$task->exit=-$sig;
$task->write();
@@ -13,10 +14,7 @@ function handle_signal($sig=null) {
debug('$task not set');
}
$build->finish=time();
- $build->status='got_signal';
- $build->details=$sig;
$build->write();
- debug("build $build->id given status $build->status");
}
debug("\nGot signal $sig - exiting");
exit;
diff --git a/backend/include/includes.php b/backend/include/includes.php
deleted file mode 100644
index d20c3ac..0000000
--- a/backend/include/includes.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-foreach (glob(BACKEND.'/bundlers/*.php') as $file)
- require_once($file);
-?>
diff --git a/backend/modules/gentoo_portage/base-system.php b/backend/modules/gentoo_portage/base-system.php
index c99447e..0c730e9 100644
--- a/backend/modules/gentoo_portage/base-system.php
+++ b/backend/modules/gentoo_portage/base-system.php
@@ -1,6 +1,6 @@
<?php
$file=CACHE.'/stage3/'.$profile->stage3;
-execute_command('Unpack base system', "tar -xvjpf '$file' -C '$I'");
+execute_command('Unpack base system', "tar -xvjpf '$file' -C '$imagedir'");
if ($opts['basesystem'] == 'user_prune' && $opts['prunepkgs']) {
emerge($opts['prunepkgs'], 'Prune base system packages', '-C');
} elseif ($opts['basesystem'] == 'auto_prune') {
diff --git a/backend/modules/gentoo_portage/build.php b/backend/modules/gentoo_portage/build.php
index 781aaef..2d2f32f 100644
--- a/backend/modules/gentoo_portage/build.php
+++ b/backend/modules/gentoo_portage/build.php
@@ -2,9 +2,9 @@
require_once(dirname(__FILE__).'/packages.php'); // __DIR__ 5.3.0
$profile=new sql_gentoo_profile($opts['profile']);
$headers=$profile->get_headers();
-$I="$workdir/image";
-$C="$workdir/config_root";
-$S['prtg_cfgrt']=array('PORTAGE_CONFIGROOT' => $C);
+$imagedir="$workdir/image";
+$confdir="$workdir/config_root";
+$S['prtg_cfgrt']=array('PORTAGE_CONFIGROOT' => $confdir);
add_step('setup');
add_step('base-system');
$extra=explode(' ', $opts['options']);
@@ -22,5 +22,5 @@ if (strlen($opts['pkgsets']))
add_step('pkgsets');
if (strlen($opts['install_packages']))
add_step('misc-pkgs');
-return $I;
+return $imagedir;
?>
diff --git a/backend/modules/gentoo_portage/hostname.php b/backend/modules/gentoo_portage/hostname.php
index 11c7d20..e710560 100644
--- a/backend/modules/gentoo_portage/hostname.php
+++ b/backend/modules/gentoo_portage/hostname.php
@@ -1,4 +1,4 @@
<?php
$hn=str_replace('@', '\@', $opts['hostname']);
-execute_command('Set hostname in /etc/conf.d/hostname', "sed -i -r 's@^#?HOSTNAME=.*$@HOSTNAME=\"$hn\"@' '$I/etc/conf.d/hostname'");
+execute_command('Set hostname in /etc/conf.d/hostname', "sed -i -r 's@^#?HOSTNAME=.*$@HOSTNAME=\"$hn\"@' '$imagedir/etc/conf.d/hostname'");
?>
diff --git a/backend/modules/gentoo_portage/init.d.php b/backend/modules/gentoo_portage/init.d.php
index deef101..9ab61e6 100644
--- a/backend/modules/gentoo_portage/init.d.php
+++ b/backend/modules/gentoo_portage/init.d.php
@@ -2,7 +2,7 @@
start_internal_task('Remove unwanted init scripts');
foreach (explode(' ', $opts['pruneinit']) as $init) {
list($name, $runlevel)=explode(':', $init, 2);
- log_status("$name ($runlevel)", unlink("$I/etc/runlevels/$runlevel/$name"));
+ log_status("$name ($runlevel)", unlink("$imagedir/etc/runlevels/$runlevel/$name"));
}
end_internal_task(0);
?>
diff --git a/backend/modules/gentoo_portage/portage.php b/backend/modules/gentoo_portage/portage.php
index a1eb3ed..bcfa7d7 100644
--- a/backend/modules/gentoo_portage/portage.php
+++ b/backend/modules/gentoo_portage/portage.php
@@ -3,14 +3,14 @@ $file=glob(CACHE.'/portage/*.tar.bz2');
if ($file) {
$file=array_reverse($file);
$file=$file[0];
- execute_command('Unpack portage snapshot', "tar -xvjpf '$file' -C '$I/usr'");
+ execute_command('Unpack portage snapshot', "tar -xvjpf '$file' -C '$imagedir/usr'");
} else {
start_internal_task('Copy local portage tree to image');
foreach (glob("{$S['conf']['portdir']}/*") as $from) {
$file=substr($from, strlen($S['conf']['portdir'])+1);
// Skip distfiles, binary packages, and potential overlay directories
if ($file == 'distfiles' || $file == 'packages' || $file == 'local' || $file == 'overlay') continue;
- $cmd="cp -av -t '$I/usr/portage/' '$from'";
+ $cmd="cp -av -t '$imagedir/usr/portage/' '$from'";
error_get_last();
@shell_exec($cmd);
end_internal_task((int)(bool)error_get_last());
@@ -33,8 +33,8 @@ foreach ($makeconf as $name => $val)
$contents.=strtoupper($name).'="'.str_replace('"', '\"', $val)."\"\n";
unset($makeconf);
log_msg("/etc/make.conf:\n$contents");
-log_status('Writing /etc/make.conf', file_put_contents("$I/etc/make.conf", $contents));
-log_status('Remove previous make.profile', unlink("$I/etc/make.profile"), false);
-log_status("Symlink make.profile -> /usr/portage/profiles/{$headers['profile']}", symlink("/usr/portage/profiles/{$headers['profile']}", "$I/etc/make.profile"));
+log_status('Writing /etc/make.conf', file_put_contents("$imagedir/etc/make.conf", $contents));
+log_status('Remove previous make.profile', unlink("$imagedir/etc/make.profile"), false);
+log_status("Symlink make.profile -> /usr/portage/profiles/{$headers['profile']}", symlink("/usr/portage/profiles/{$headers['profile']}", "$imagedir/etc/make.profile"));
end_internal_task(0);
?>
diff --git a/backend/modules/gentoo_portage/setup.php b/backend/modules/gentoo_portage/setup.php
index d96eb51..93dbad8 100644
--- a/backend/modules/gentoo_portage/setup.php
+++ b/backend/modules/gentoo_portage/setup.php
@@ -1,12 +1,12 @@
<?php
start_internal_task('Create portage target environment');
-makedirs($I, $C, "$workdir/log", "$workdir/tmp");
-log_status("Make symlink $C/etc -> .", symlink('.', "$C/etc"));
+makedirs($imagedir, $confdir, "$workdir/log", "$workdir/tmp");
+log_status("Make symlink $confdir/etc -> .", symlink('.', "$confdir/etc"));
$makeconf=array(
'pkgdir' => $S['conf']['pkgdir_root'].'/'.$profile->pkgdir,
'chost' => $headers['chost'],
'accept_keywords' => $headers['accept_keywords'],
- 'root' => $I,
+ 'root' => $imagedir,
'port_logdir' => "$workdir/log",
'emerge_log_dir' => "$workdir/log",
'portage_tmpdir' => "$workdir/tmp"
@@ -15,8 +15,8 @@ $contents='';
foreach ($makeconf as $name => $val)
$contents.=strtoupper($name).'="'.str_replace('"', '\"', $val)."\"\n";
unset($makeconf);
-log_status("Write $C/etc/make.conf", file_put_contents("$C/etc/make.conf", $contents));
+log_status("Write $confdir/etc/make.conf", file_put_contents("$confdir/etc/make.conf", $contents));
unset($contents);
-log_status('Make make.profile symlink to '.$S['conf']['portdir'].'/profiles/'.$headers['profile'], symlink($S['conf']['portdir'].'/profiles/'.$headers['profile'], $C.'/etc/make.profile'));
+log_status('Make make.profile symlink to '.$S['conf']['portdir'].'/profiles/'.$headers['profile'], symlink($S['conf']['portdir'].'/profiles/'.$headers['profile'], $confdir.'/etc/make.profile'));
end_internal_task(0);
?>
diff --git a/backend/modules/gentoo_portage/timezone.php b/backend/modules/gentoo_portage/timezone.php
index e5cc196..b5d4e6e 100644
--- a/backend/modules/gentoo_portage/timezone.php
+++ b/backend/modules/gentoo_portage/timezone.php
@@ -1,9 +1,9 @@
<?php
-if (glob("$I/var/db/pkg/sys-apps/baselayout-2*", GLOB_ONLYDIR))
- file_put_contents("$I/etc/timezone", "{$opts['timezone']}\n");
+if (glob("$imagedir/var/db/pkg/sys-apps/baselayout-2*", GLOB_ONLYDIR))
+ file_put_contents("$imagedir/etc/timezone", "{$opts['timezone']}\n");
else {
$tz=str_replace('@', '\@', $opts['timezone']);
- execute_command('Set timezone in /etc/conf.d/clock', "sed -i -r 's@^#?TIMEZONE=.*$@TIMEZONE=\"$tz\"@' '$I/etc/conf.d/clock'");
+ execute_command('Set timezone in /etc/conf.d/clock', "sed -i -r 's@^#?TIMEZONE=.*$@TIMEZONE=\"$tz\"@' '$imagedir/etc/conf.d/clock'");
}
emerge('sys-libs/timezone-data', null, '-K -1 --root-deps=rdeps');
?>