summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-08-06 19:12:48 -0400
committerEudyptula <eitan@mosenkis.net>2009-08-06 19:12:48 -0400
commited4e6670c58817a6dece1a5531f683445dfedb84 (patch)
treec8e13990de43d86adcd1262dcb6c22d98bfe1915
parentAdded more package sets, created status document from Gentoo install guide, u... (diff)
downloadingenue-ed4e6670c58817a6dece1a5531f683445dfedb84.tar.gz
ingenue-ed4e6670c58817a6dece1a5531f683445dfedb84.tar.bz2
ingenue-ed4e6670c58817a6dece1a5531f683445dfedb84.zip
Numerous backend bugs fixed; use portage snapshot if available; frontend figures out its own URL; choose hostname; timezone config file set up; Fix setup.php; etc.
-rwxr-xr-xbackend/backend.php21
-rw-r--r--backend/bundlers/installcd.php15
-rw-r--r--backend/bundlers/livecd.php16
-rw-r--r--backend/functions/api.php2
-rw-r--r--backend/modules/gentoo_portage/base-system.php7
-rw-r--r--backend/modules/gentoo_portage/build.php12
-rw-r--r--backend/modules/gentoo_portage/dev-manager.php7
-rw-r--r--backend/modules/gentoo_portage/hostname.php4
-rw-r--r--backend/modules/gentoo_portage/packages.php2
-rw-r--r--backend/modules/gentoo_portage/portage.php41
-rwxr-xr-xbackend/modules/gentoo_portage/profile_use.py8
-rw-r--r--backend/modules/gentoo_portage/setup.php2
-rw-r--r--backend/modules/gentoo_portage/timezone.php9
-rw-r--r--depend1
-rw-r--r--frontend/classes/forms.php2
-rw-r--r--frontend/include/constants.php19
-rw-r--r--frontend/include/setup.php7
-rw-r--r--frontend/index.php1
-rw-r--r--frontend/modules/gentoo/step2.php4
-rw-r--r--frontend/modules/gentoo/step3.php2
-rw-r--r--frontend/pages/builds/delete.php8
-rw-r--r--frontend/pages/builds/download.php1
-rw-r--r--gentoo-steps6
-rwxr-xr-xpkglist.php2
-rwxr-xr-xsetup.php4
-rw-r--r--shared/classes/0sql_row_obj.php6
-rw-r--r--shared/classes/build.php20
-rw-r--r--shared/classes/session.php2
-rw-r--r--shared/functions/url.php9
-rw-r--r--shared/include/definitions.php9
-rw-r--r--shared/include/includes.php1
-rw-r--r--todo11
-rwxr-xr-xupdate_sql_classes.php14
33 files changed, 149 insertions, 126 deletions
diff --git a/backend/backend.php b/backend/backend.php
index 5090c63..c35385e 100755
--- a/backend/backend.php
+++ b/backend/backend.php
@@ -53,6 +53,7 @@ while (true) {
$r=query('SELECT * FROM `builds` WHERE `status`=-128 ORDER BY `ctime` ASC LIMIT 1');
if ($r->rowCount()) {
$build=new sql_build($r->fetch(PDO::FETCH_ASSOC));
+ $owner=$build->get_owner();
$build->start=time();
$build->status=-1;
$build->write();
@@ -75,14 +76,11 @@ while (true) {
require_once(BACKEND."/bundlers/{$opts['bundler']}.php");
$proc='bundle_'.$opts['bundler'];
$file=$proc($image, $workdir, $opts);
- if (!$S['conf']['debug']) {
- execute_command('Delete work directory', 'rm -rf "'.$workdir.'"');
- }
+ end_internal_task(0); // Just in case
} catch (Exception $e) {
end_internal_task(1);
- log_msg('Caught exception: '.$e->getMessage());
- $build->status=126;
- $owner=$build->get_owner();
+// log_msg('Caught exception: '.$e->getMessage());
+ $build->status=INGENUE_BUILD_FAILED;
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>');
}
$build->finish=time();
@@ -90,7 +88,7 @@ while (true) {
if (isset($file)) {
debug("Completed build successfully");
if ($S['conf']['split_setup']) {
- $build->status=-127;
+ $build->status=INGENUE_BUILD_UPLOADING;
$build->write();
$key=randstring(30);
$opt=new sql_buildopt($build->id, 'uploadkey', $key);
@@ -108,18 +106,21 @@ while (true) {
debug($result);
}
if ($result === false || strpos($result, 'Upload successful') === false) {
- $build->status=127;
+ $build->status=INGENUE_BUILD_UPLOAD_FAILED;
} else {
debug("Transferred $file... unlinking it");
unlink($file);
- $build->status=0;
+ $build->status=INGENUE_BUILD_COMPLETE;
}
} else {
- $build->status=0;
+ $build->status=INGENUE_BUILD_COMPLETE;
$base=basename($file);
$ext=substr($base, strpos($base, '.'));
rename($file, COMPLETED.'/build-'.$build->id.$ext);
}
+ if (!$S['conf']['debug']) {
+ shell_exec('rm -rf "'.$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>');
}
$build->write();
diff --git a/backend/bundlers/installcd.php b/backend/bundlers/installcd.php
index 49420b0..05918ea 100644
--- a/backend/bundlers/installcd.php
+++ b/backend/bundlers/installcd.php
@@ -3,25 +3,14 @@ function bundle_installcd($I, $W, &$opts) {
$profile=new sql_gentoo_profile($opts['profile']);
$headers=$profile->get_headers();
if (strpos($headers['chost'], 'x86_64') === false)
- $minimaliso='/home/eitan/soc/install-x86-minimal-20090623.iso';
+ $minimaliso=CACHE.'/cd/install-x86-minimal-20090623.iso';
else
- $minimaliso='/home/eitan/soc/install-amd64-minimal-20090625.iso';
+ $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('Copy kernel modules from SquashFS to image', "unsquashfs -i -d '$I' -e '$W/unsquashfs-files' '$W/image.squashfs'");
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'");
-/* execute_command('Mount minimal CD image', "mount -o loop -t iso9660 '$minimaliso' '$W/tmp'");
- execute_command('Copy CD image to writable temp directory', "cp -va '$W/tmp' '$W/cd'");
- execute_command('Unmount CD image', "umount '$W/tmp'");
- execute_command('Copy kernel and initrd from CD to image', "cp -va '$W/cd/isolinux/gentoo' '$W/cd/isolinux/gentoo.igz' '$I/boot/'");
- file_put_contents("$W/unsquashfs-files", "/lib64/modules\n\lib\modules\n");
- execute_command('Copy kernel modules from SquashFS to image', "unsquashfs -i -d '$I' -e '$W/unsquashfs-files' '$W/cd/image.squashfs'");
- execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$W/cd/image.tar.bz2' -C '$I' .");
- // TODO port the rest of /usr/lib/catalyst/targets/support/create-iso.sh to support other bootloaders
- // ISOLINUX bootloader
- // mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path}
- execute_command('Create ISO image', "mkisofs -J -R -l -V 'Ingenue Build $build->id' -o '$W/image.iso' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table '$W/cd'");*/
return "$W/image.iso";
}
diff --git a/backend/bundlers/livecd.php b/backend/bundlers/livecd.php
index d269bd1..ec4de83 100644
--- a/backend/bundlers/livecd.php
+++ b/backend/bundlers/livecd.php
@@ -3,27 +3,15 @@ function bundle_livecd($I, $W, &$opts) {
$profile=new sql_gentoo_profile($opts['profile']);
$headers=$profile->get_headers();
if (strpos($headers['chost'], 'x86_64') === false)
- $minimaliso='/home/eitan/soc/install-x86-minimal-20090623.iso';
+ $minimaliso=CACHE.'/cd/install-x86-minimal-20090623.iso';
else
- $minimaliso='/home/eitan/soc/install-amd64-minimal-20090625.iso';
+ $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('Copy kernel modules from SquashFS to image', "unsquashfs -i -d '$I' -e '$W/unsquashfs-files' '$W/image.squashfs'");
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'");
-/* execute_command('Mount minimal CD image', "mount -o loop -t iso9660 '$minimaliso' '$W/tmp'");
- execute_command('Copy CD image to writable temp directory', "cp -va '$W/tmp' '$W/cd'");
- execute_command('Unmount CD image', "umount '$W/tmp'");
- execute_command('Copy kernel and initrd from CD to image', "cp -va '$W/cd/isolinux/gentoo' '$W/cd/isolinux/gentoo.igz' '$I/boot/'");
- file_put_contents("$W/unsquashfs-files", "/lib64/modules\n\lib\modules\n");
- execute_command('Copy kernel modules from SquashFS to image', "unsquashfs -i -d '$I' -e '$W/unsquashfs-files' '$W/cd/image.squashfs'");
- rename("$W/cd/image.squashfs", "$W/image.squashfs.old") || debug('Failed to move old SquashFS');
- execute_command('Compress finished image to squashfs', "mksquashfs '$I' '$W/cd/image.squashfs' -noappend -info");
- // TODO port the rest of /usr/lib/catalyst/targets/support/create-iso.sh to support other bootloaders
- // ISOLINUX bootloader
- // mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path}
- execute_command('Create ISO image', "mkisofs -J -R -l -V 'Ingenue Build $build->id' -o '$W/image.iso' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table '$W/cd'");*/
return "$W/image.iso";
}
?>
diff --git a/backend/functions/api.php b/backend/functions/api.php
index 843e410..1a0cc43 100644
--- a/backend/functions/api.php
+++ b/backend/functions/api.php
@@ -4,7 +4,7 @@ function execute_command_with_all($description, $command, $vital=true, $path=nul
if (isset($task))
end_internal_task();
$default_env=array(
- 'PATH' => $_ENV['PATH']
+ 'PATH' => getenv('PATH')
);
$env=is_array($env)?array_merge($default_env, $env):$default_env;
$task=new sql_task($build->id, task_get_order(), 'exec', $description, $command);
diff --git a/backend/modules/gentoo_portage/base-system.php b/backend/modules/gentoo_portage/base-system.php
index a940c87..6cf2194 100644
--- a/backend/modules/gentoo_portage/base-system.php
+++ b/backend/modules/gentoo_portage/base-system.php
@@ -1,9 +1,8 @@
<?php
$file=CACHE.'/stage3/'.$profile->stage3;
-$opt='-xv'.(substr($file, -3) == 'bz2'?'j':'z').'f';
-execute_command('Unpack base system', "tar $opt '$file' -C '$I'");
+execute_command('Unpack base system', "tar -xvjpf '$file' -C '$I'");
if ($opts['basesystem'] == 'manual' && $opts['prunepkgs']) {
- portage_install($opts['prunepkgs'], 'Prune base system packages', '-C');
+ emerge($opts['prunepkgs'], 'Prune base system packages', '-C');
} elseif ($opts['basesystem'] == 'autoprune') {
throw_exception('Base system autoprune not implemented - need package list');
$keep=explode(' ', $keep_pkgs);
@@ -16,6 +15,6 @@ if ($opts['basesystem'] == 'manual' && $opts['prunepkgs']) {
else
unset($keep[$i]);
}
- portage_install($remove, 'Automatically prune base system packages', '-C');
+ emerge($remove, 'Automatically prune base system packages', '-C');
}
?>
diff --git a/backend/modules/gentoo_portage/build.php b/backend/modules/gentoo_portage/build.php
index 5c1a1fd..631cf0f 100644
--- a/backend/modules/gentoo_portage/build.php
+++ b/backend/modules/gentoo_portage/build.php
@@ -6,28 +6,32 @@ function gentoo_portage_build(&$build, &$opts, &$W) {
$profile=new sql_gentoo_profile($opts['profile']);
$headers=$profile->get_headers();
$I="$W/image";
- $extra=explode(' ', $opts['options']);
require(dirname(__FILE__).'/setup.php'); // __DIR__ in 5.3.0
if ($S['conf']['debug'])
execute_command_with_env('Log portage setup', 'emerge --info', $prtg_cfgrt);
require(dirname(__FILE__).'/base-system.php'); // __DIR__ 5.3.0
+ $extra=explode(' ', $opts['options']);
+ if (in_array('portage', $extra))
+ require(dirname(__FILE__).'/portage.php'); // __DIR__ 5.3.0
if (in_array('pruneinit', $extra))
require(dirname(__FILE__).'/init.d.php'); // __DIR__ 5.3.0
if (in_array('timezone', $extra))
require(dirname(__FILE__).'/timezone.php'); // __DIR__ 5.3.0
+ if (in_array('hostname', $extra))
+ require(dirname(__FILE__).'/hostname.php'); // __DIR__ 5.3.0
if (in_array('dev-manager', $extra))
require(dirname(__FILE__).'/dev-manager.php'); // __DIR__ 5.3.0
if ($opts['bundler'] == 'livecd')
- portage_install('app-misc/livecd-tools', 'Install LiveCD utilities');
+ emerge('app-misc/livecd-tools', 'Install LiveCD utilities');
if (strlen($opts['pkgsets'])) {
foreach (explode(' ', $opts['pkgsets']) as $pkgset) {
if (strlen($opts['pkgset-'.$pkgset])) {
- portage_install($opts['pkgset-'.$pkgset]);
+ emerge($opts['pkgset-'.$pkgset]);
}
}
}
if (strlen($opts['install_packages']))
- portage_install($opts['install_packages'], 'Install selected packages');
+ emerge($opts['install_packages'], 'Install selected packages');
return $I;
}
?>
diff --git a/backend/modules/gentoo_portage/dev-manager.php b/backend/modules/gentoo_portage/dev-manager.php
index 40c06fb..0b2ebb4 100644
--- a/backend/modules/gentoo_portage/dev-manager.php
+++ b/backend/modules/gentoo_portage/dev-manager.php
@@ -1,8 +1,7 @@
<?php
if ($opts['dev-manager'] == 'udev') {
- portage_install('sys-fs/udev');
-} else { // if ($opts['dev-manager'] == 'static-dev') {
- portage_install('sys-fs/udev', 'Uninstall udev', '-C');
- portage_install('sys-fs/static-dev');
+ emerge('sys-fs/udev');
+} else { // if ($opts['dev-manager'] == 'static-dev') { // If we add another option
+ emerge('sys-fs/udev', 'Uninstall udev', '-C');
}
?>
diff --git a/backend/modules/gentoo_portage/hostname.php b/backend/modules/gentoo_portage/hostname.php
new file mode 100644
index 0000000..11c7d20
--- /dev/null
+++ b/backend/modules/gentoo_portage/hostname.php
@@ -0,0 +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'");
+?>
diff --git a/backend/modules/gentoo_portage/packages.php b/backend/modules/gentoo_portage/packages.php
index cfbb71d..167ca73 100644
--- a/backend/modules/gentoo_portage/packages.php
+++ b/backend/modules/gentoo_portage/packages.php
@@ -1,5 +1,5 @@
<?php
-function portage_install($pkgs, $desc=null, $opts=null, $use=null) {
+function emerge($pkgs, $desc=null, $opts=null, $use=null) {
global $prtg_cfgrt, $S;
$opts=$S['conf']['emerge_default_opts'].' '.($opts === null?'-K -n --root-deps=rdeps':$opts);
if (!$pkgs) return;
diff --git a/backend/modules/gentoo_portage/portage.php b/backend/modules/gentoo_portage/portage.php
index c09d4d7..291a858 100644
--- a/backend/modules/gentoo_portage/portage.php
+++ b/backend/modules/gentoo_portage/portage.php
@@ -1,16 +1,35 @@
<?php
-start_internal_task('Set up portage in image');
-end_internal_task(0);
-start_internal_task('Copy portage tree into 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'";
- error_get_last();
- @shell_exec($cmd);
- log_status("$cmd", !(error_get_last()));
+$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'");
+} 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'";
+ error_get_last();
+ @shell_exec($cmd);
+ end_internal_task((int)(bool)error_get_last());
+ }
+ end_internal_task(0);
}
+start_internal_task('Set up portage in image');
+$makeconf=array(
+ 'chost' => $headers['chost'],
+ 'accept_keywords' => $headers['accept_keywords'],
+ 'gentoo_mirrors' => $headers['gentoo_mirrors'],
+ 'use' => $headers['use']
+);
+$contents='';
+foreach ($makeconf as $name => $val)
+ $contents.=strtoupper($name).'='.escapeshellarg($val)."\n";
+unset($makeconf);
+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"));
end_internal_task(0);
?>
diff --git a/backend/modules/gentoo_portage/profile_use.py b/backend/modules/gentoo_portage/profile_use.py
new file mode 100755
index 0000000..68209d5
--- /dev/null
+++ b/backend/modules/gentoo_portage/profile_use.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+import sys
+import portage
+
+profile_path = sys.argv[1]
+settings = portage.config(config_profile_path=profile_path, config_root='/tmp')
+print settings['USE']
diff --git a/backend/modules/gentoo_portage/setup.php b/backend/modules/gentoo_portage/setup.php
index 6e8bf03..5738bee 100644
--- a/backend/modules/gentoo_portage/setup.php
+++ b/backend/modules/gentoo_portage/setup.php
@@ -16,7 +16,7 @@ $contents='';
foreach ($makeconf as $name => $val)
$contents.=strtoupper($name).'='.escapeshellarg($val)."\n";
unset($makeconf);
-log_status('Writing '.$C.'/make.conf', file_put_contents($C.'/etc/make.conf', $contents));
+log_status("Writing $C/etc/make.conf", file_put_contents("$C/etc/make.conf", $contents));
unset($contents);
log_status('Making make.profile symlink to '.$S['conf']['portdir'].'/profiles/'.$headers['profile'], symlink($S['conf']['portdir'].'/profiles/'.$headers['profile'], $C.'/etc/make.profile'));
global $prtg_cfgrt;
diff --git a/backend/modules/gentoo_portage/timezone.php b/backend/modules/gentoo_portage/timezone.php
index 3ac2774..e5cc196 100644
--- a/backend/modules/gentoo_portage/timezone.php
+++ b/backend/modules/gentoo_portage/timezone.php
@@ -1,4 +1,9 @@
<?php
-portage_install('sys-libs/timezone-data');
-execute_command('Making timezone symlink', "ln -sf '/usr/share/zoneinfo/{$opts['timezone']}' '$I/etc/localtime'");
+if (glob("$I/var/db/pkg/sys-apps/baselayout-2*", GLOB_ONLYDIR))
+ file_put_contents("$I/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'");
+}
+emerge('sys-libs/timezone-data', null, '-K -1 --root-deps=rdeps');
?>
diff --git a/depend b/depend
index faf9cff..907b18c 100644
--- a/depend
+++ b/depend
@@ -1,6 +1,7 @@
>=dev-lang/php-5.2.2 USE=pdo hash pcntl pcre cli pdo mysqli apache2 curl ctype reflection
>=virtual/mysql-5
sys-apps/portage # In case you use paludis
+sys-apps/sed
www-servers/apache APACHE2_MODULES=rewrite
>=sys-fs/squashfs-tools-4
JFFS2: sys-fs/mtd-utils
diff --git a/frontend/classes/forms.php b/frontend/classes/forms.php
index daa95cf..6e5b43e 100644
--- a/frontend/classes/forms.php
+++ b/frontend/classes/forms.php
@@ -7,7 +7,7 @@ abstract class form_element {
$this->label=htmlentities($label);
}
public function output($rw=true, $val=false) {
- echo "$this->label: ";
+ echo "<b>$this->label:</b> ";
}
public function process() {
return isset($_REQUEST[$this->htmlname])?$_REQUEST[$this->htmlname]:false;
diff --git a/frontend/include/constants.php b/frontend/include/constants.php
deleted file mode 100644
index fb16d89..0000000
--- a/frontend/include/constants.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-define('RECIPE_CATEGORY', 'r');
-define('DISH_CATEGORY', 'd');
-define('INGREDIENT_CATEGORY', 'i');
-define('FAVORITE_RECIPE', 'R');
-define('FAVORITE_DISH', 'D');
-define('FAVORITE_MEAL', 'M');
-define('FAVORITE_TIP', 'T');
-define('FAVORITE_INGREDIENT', 'I');
-define('MODE_SET', 'set');
-define('MODE_WHERE', 'where');
-define('TYPE_CATEGORY', 'c');
-define('TYPE_RECIPE', 'r');
-define('TYPE_IMAGE', 'p');
-define('TYPE_USER', 'u');
-define('TYPE_DISH', 'd');
-define('TYPE_INGREDIENT', 'i');
-define('USER_TITLES', 'Mr. Mrs. Ms. Dr. Rabbi Rav Rabbi Dr. Rav Dr.');
-?>
diff --git a/frontend/include/setup.php b/frontend/include/setup.php
index 825d759..8c70af4 100644
--- a/frontend/include/setup.php
+++ b/frontend/include/setup.php
@@ -18,7 +18,12 @@ $S=array_merge($S, array(
'sql' => null
));
unset($_REQUEST['req'], $_GET['req']);
-$S['cookie_dir']=substr($S['conf']['url'], strpos($S['conf']['url'], '/', 8)).'/';
+$S['url']=rtrim('http://'.$_SERVER['HTTP_HOST'].($_SERVER['SERVER_PORT']==(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']?443:80)?'':':'.$_SERVER['SERVER_PORT']).dirname($_SERVER['PHP_SELF']), '/');
+if (($i=strpos($S['url'], '/', 8)) === false)
+ $S['cookie_dir']='/';
+else
+ $S['cookie_dir']=substr($S['url'], $i).'/';
+unset($i);
require_once(SHARED.'/include/dbinit.php');
if (isset($_COOKIE[$S['conf']['cookiename']])) {
$cookie=$_COOKIE[$S['conf']['cookiename']];
diff --git a/frontend/index.php b/frontend/index.php
index 1c1ea7d..0fdfa17 100644
--- a/frontend/index.php
+++ b/frontend/index.php
@@ -3,7 +3,6 @@ define('E_DEFAULT', error_reporting(E_ALL|E_STRICT));
require_once('../shared/include/includes.php');
require_once('include/error_handling.php');
register_shutdown_function('onshutdown', realpath('include/footer.php'), realpath('include/header.php')); // Needed to ensure that errors are printed
-require_once('include/constants.php');
require_once('include/setup.php');
if (get_magic_quotes_gpc()) r_stripslashes($_REQUEST);
$routing=fopen('routing.csv', 'r');
diff --git a/frontend/modules/gentoo/step2.php b/frontend/modules/gentoo/step2.php
index 1800255..7fa5456 100644
--- a/frontend/modules/gentoo/step2.php
+++ b/frontend/modules/gentoo/step2.php
@@ -1,8 +1,8 @@
<?php
global $S;
$profile=new sql_gentoo_profile($this->get_opt('profile'));
-$this->checkbox_array('options', 'options', 'Configuration options', array('timezone' => 'Select timezone', 'dev-manager' => 'Select /dev manager', 'pruneinit' => 'Remove enabled-by-default init scripts'));
-$this->select('basesystem', 'basesystem', 'Base system', array('stage3' => 'Stage3 Tarball', 'autoprune' => 'Remove all non-vital packages', 'manual' => 'Manually select packages to remove from stage3'));
+$this->checkbox_array('options', 'options', 'Configuration options', array('timezone' => 'Select timezone', 'hostname' => 'Choose hostname', 'dev-manager' => 'Select /dev manager', 'pruneinit' => 'Remove enabled-by-default init scripts', 'portage' => 'Install portage snapshot and configure portage'));
+$this->select('basesystem', 'basesystem', 'Base system', array('stage3' => 'Stage3 Tarball', /*'autoprune' => 'Remove all non-vital packages',*/ 'manual' => 'Manually select packages to remove from stage3'));
$pkgsets=array();
$r=query('SELECT * FROM `gentoo_pkgsets` WHERE `profile`='.$profile->id);
while ($pkgset=$r->fetch(PDO::FETCH_ASSOC)) {
diff --git a/frontend/modules/gentoo/step3.php b/frontend/modules/gentoo/step3.php
index 7074049..6af5b2e 100644
--- a/frontend/modules/gentoo/step3.php
+++ b/frontend/modules/gentoo/step3.php
@@ -3,6 +3,8 @@ global $S;
$opts=explode(' ', $this->get_opt('options'));
if (in_array('timezone', $opts))
$this->select('timezone', 'timezone', 'Timezone', get_timezones());
+if (in_array('hostname', $opts))
+ $this->text_input('hostname', 'hostname', 'Hostname');
if (in_array('dev-manager', $opts))
$this->select('dev-manager', 'dev-manager', '/dev Manager', array('udev' => 'udev', 'static-dev' => 'Static /dev'));
$profile=new sql_gentoo_profile($this->get_opt('profile'));
diff --git a/frontend/pages/builds/delete.php b/frontend/pages/builds/delete.php
index 51aa9cf..5ff1d9a 100644
--- a/frontend/pages/builds/delete.php
+++ b/frontend/pages/builds/delete.php
@@ -9,10 +9,14 @@ function init_builds_delete(&$S) {
return array('title' => 'Delete Build');
}
function body_builds_delete(&$S) {
- if ($S['build']->status >= 0 || $S['build']->status == -128) {
+ if ($S['build']->status >= 0 || $S['build']->status == INGENUE_BUILD_QUEUED) {
$S['build']->delete();
echo print_success('Build deleted.');
+ } elseif ($S['build']->status != INGENUE_BUILD_CANCEL) {
+ $S['build']->status=INGENUE_BUILD_CANCEL;
+ $S['build']->write();
+ echo print_success('Build queued for cancellation.');
} else
- echo print_error('Cannot delete build while it is being built.');
+ echo print_error('This build is already queued for cancellation.');
}
?>
diff --git a/frontend/pages/builds/download.php b/frontend/pages/builds/download.php
index 411efbf..759b5c4 100644
--- a/frontend/pages/builds/download.php
+++ b/frontend/pages/builds/download.php
@@ -41,6 +41,7 @@ function init_builds_download(&$S) {
header('Content-Disposition: attachment; filename="'.(isset($build->name) && strlen($build->name)?str_replace('"', '\"', $build->name):'ingenue-'.$build->id).$ext);
}
function body_builds_download(&$S) {
+ ob_end_flush(); // At least in 5.3, we get a 500 Internal Server Error without this
readfile($S['builds_download']['file']);
// Log the download to db after sending data so hopefully HEAD requests won't artificially inflate the # of dls
$S['builds_download']['dl']->write();
diff --git a/gentoo-steps b/gentoo-steps
index e10e379..d17d61b 100644
--- a/gentoo-steps
+++ b/gentoo-steps
@@ -13,12 +13,14 @@ Kernel source installation (pkgset)
X*Kernel compilation
#*Kernel module config
#*Fstab generation
-*/etc/conf.d/hostname
+/etc/conf.d/hostname
#*/etc/conf.d/net
#*/etc/hosts
X*set root password
?*/etc/rc.conf
-*/etc/conf.d/clock (just reuse choice of /etc/localtime symlink)
+/etc/conf.d/clock (baselayout 1 only - timezone only)
+/etc/timezone (baselayout 2 only)
+?*/etc/conf.d/{hw,}clock (clock="UTC"/"local")
Syslogger (pkgset)
Cron daemon (pkgset)
?*File indexing (package set with just slocate in it?)
diff --git a/pkglist.php b/pkglist.php
index 2307fe1..8b0fab4 100755
--- a/pkglist.php
+++ b/pkglist.php
@@ -1,7 +1,7 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__).'/shared/include/includes.php'); // USE __DIR__ in 5.3.0
-require_once(SHARED.'/config.php');
+$S['conf']['debug']=false;
require_once(SHARED.'/include/dbinit.php');
$r=query('SELECT * FROM `gentoo_profiles`'.(isset($argv[1])?' WHERE `name` LIKE "%'.$argv[1].'%" OR `pkgdir` LIKE "%'.$argv[1].'%"':''));
while ($p=$r->fetch(PDO::FETCH_ASSOC)) {
diff --git a/setup.php b/setup.php
index 78ba8d9..393a1fe 100755
--- a/setup.php
+++ b/setup.php
@@ -24,12 +24,12 @@ foreach (get_declared_classes() as $class) {
}
query($o->create_table());
}
+$user=new sql_user();
do {
if ($user->email) {
echo 'Invalid entry: '.$user->email."\n";
}
echo 'Admin email address: ';
- $user=new sql_user();
$user->email=trim(fgets(STDIN));
if (!$interactive) {
echo "\n";
@@ -49,7 +49,7 @@ if ($interactive) {
system('stty -echo');
}
do {
- if ($pass && $passconfirm) {
+ if (isset($pass)) {
echo "Entered passwords did not match. Try again.\n";
}
echo 'Admin password: ';
diff --git a/shared/classes/0sql_row_obj.php b/shared/classes/0sql_row_obj.php
index 4efacbd..30fe479 100644
--- a/shared/classes/0sql_row_obj.php
+++ b/shared/classes/0sql_row_obj.php
@@ -277,7 +277,7 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up
return $cols_filled;
}
// Writes the object's data to the database, either by UPDATE or INSERT
- function write() {
+ public function write() {
$q=($this->is_in_db()?'UPDATE':'INSERT INTO').' `'.$this->table.'` SET ';
$i=0; // Number of columns we've set so far
$to_change=array();
@@ -310,14 +310,14 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up
return $r;
}
// (Re-)Loads data from the database
- function load() {
+ public function load() {
if ($this->is_in_db()) {
$r=self::sql_query('SELECT * FROM `'.$this->table.'` WHERE '.$this->sql_id());
$this->from_array($r->fetch(PDO::FETCH_ASSOC), true);
}
}
// Deletes this row from the database and clears db_values array
- function delete() {
+ public function delete() {
if ($this->is_in_db()) {
self::sql_query('DELETE FROM `'.$this->table.'` WHERE '.$this->sql_id());
$this->db_values=array();
diff --git a/shared/classes/build.php b/shared/classes/build.php
index 7230673..c863f1f 100644
--- a/shared/classes/build.php
+++ b/shared/classes/build.php
@@ -59,13 +59,16 @@ class sql_build extends conf_build_common {
$perms=$this->visibility == 'public' || owner_or_admin($this->id);
$html='<div class="build"><span class="name">'.(isset($this->name) && strlen($this->name)?htmlentities($this->name):'Unnamed Build').'</span> ';
$links=array();
- if ($this->status == -128) {
+ if ($this->status == INGENUE_BUILD_QUEUED) {
$total=query('SELECT COUNT(*) FROM `builds` WHERE `status`=-128')->fetch(PDO::FETCH_COLUMN);
$num=query('SELECT COUNT(*) FROM `builds` WHERE `status`=-128 AND `ctime` <= '.$this->ctime)->fetch(PDO::FETCH_COLUMN);
- $html.="<span class=\"status queued\">[Queued ($num/$total)]</span>";
- } elseif ($this->status == -127) {
+ $html.="<span class=\"status queued\">[queued ($num/$total)]</span>";
+ } elseif ($this->status == INGENUE_BUILD_UPLOADING) {
$html.='<span class="status successful">[uploading]</span>';
if ($perms) $links['Build log']="build/$this->id";
+ } elseif ($this->status == INGENUE_BUILD_CANCEL) {
+ $html.='<span class="status queued">[pending cancellation]</span>';
+ if ($perms) $links['Build log']="build/$this->id";
} elseif ($this->status < 0) {
// TODO Build stage X
$html.='<span class="status building">[building]</span>';
@@ -73,26 +76,29 @@ class sql_build extends conf_build_common {
//$links['Watch']="build/$this->id/live";
$links['Build Log']="build/$this->id";
}
- } elseif ($this->status == 0) {
+ } elseif ($this->status == INGENUE_BUILD_COMPLETE) {
$r=query('SELECT COUNT(*) as `count`, MAX(`time`) as `time` FROM `downloads` WHERE `build`="'.$this->id.'"')->fetch(PDO::FETCH_ASSOC);
$d=($perms && $r['count']?'<a href="'.url("build/$this->id/history").'">':'').$r['count'].' download'.($r['count'] != 1?'s':'').($r['count']?($perms?'</a>':'').'<br/><span class="time">(last at '.date($format, $r['time']).')</span>':'');
$html.='<span class="downloads">'.$d.'</span><span class="status successful">[successful]</span>';
$links['Download image']="build/$this->id/download";
if ($perms) $links['Build log']="build/$this->id";
- } elseif ($this->status == 127) {
+ } elseif ($this->status == INGENUE_BUILD_UPLOAD_FAILED) {
$html.='<span class="status failed">[upload failed]</span>';
if ($perms) $links['Build log']="build/$this->id";
- } elseif ($this->status == 126) {
+ } elseif ($this->status == INGENUE_BUILD_FAILED) {
$html.='<span class="status failed">[failed]</span>';
if ($perms) {
//$links['View output of failed command']="build/$this->id/failure";
$links['Build log']="build/$this->id";
}
+ } elseif ($this->status == INGENUE_BUILD_CANCELED) {
+ $html.='<span class="status failed">[canceled]</span>';
+ if ($perms) $links['Build log']="build/$this->id";
} else {
$html.='<span class="status failed">[failed: got signal '.$this->status.']</span>';
if ($perms) $links['Build log']="build/$this->id";
}
- if ($this->status >= 0 || $this->status == -128) // Finished or queued
+ if ($this->status >= 0 || $this->status == INGENUE_BUILD_QUEUED) // Finished or queued
$links['Delete']="build/$this->id/delete";
if ($links) {
foreach ($links as $label => $url) {
diff --git a/shared/classes/session.php b/shared/classes/session.php
index 1233a71..d9df028 100644
--- a/shared/classes/session.php
+++ b/shared/classes/session.php
@@ -32,7 +32,7 @@ class sql_session extends sql_row_obj {
);
// Creates a new session for the user at $S['user'] with a unique id, sends a cookie to the user and returns true for success, false for failure
- static function create() {
+ public static function create() {
global $S;
$id=null;
while (!$id) {
diff --git a/shared/functions/url.php b/shared/functions/url.php
index 0234b2b..b8e5c31 100644
--- a/shared/functions/url.php
+++ b/shared/functions/url.php
@@ -2,22 +2,23 @@
// Makes all URLs absolute
function url($url='') {
global $S;
+ $base=isset($S['url'])?$S['url']:$S['conf']['url'];
if (strlen($url) == 0) {
- return $S['conf']['url'].($S['conf']['mod_rewrite']?'':'/index.php');
+ return $base.($S['conf']['mod_rewrite']?'':'/index.php');
} elseif (substr($url, 0, 7) == 'http://') {
return $url;
}
if ($S['conf']['mod_rewrite']) {
- return $S['conf']['url'].'/'.$url;
+ return $base.'/'.$url;
} else {
if (strpos($url, '?')) {
$q=substr($url, strpos($url, '?')+1);
$url=substr($url, 0, strpos($url, '?'));
}
if (strlen($url)) {
- return $S['conf']['url'].'/index.php?req='.$url.(isset($q)?'&'.$q:'');
+ return $base.'/index.php?req='.$url.(isset($q)?'&'.$q:'');
} else {
- return $S['conf']['url'].'/index.php?'.$q;
+ return $base.'/index.php?'.$q;
}
}
}
diff --git a/shared/include/definitions.php b/shared/include/definitions.php
new file mode 100644
index 0000000..b568959
--- /dev/null
+++ b/shared/include/definitions.php
@@ -0,0 +1,9 @@
+<?php
+define('INGENUE_BUILD_QUEUED', -128);
+define('INGENUE_BUILD_UPLOADING', -127);
+define('INGENUE_BUILD_CANCEL', -126);
+define('INGENUE_BUILD_COMPLETE', 0);
+define('INGENUE_BUILD_UPLOAD_FAILED', 127);
+define('INGENUE_BUILD_FAILED', 126);
+define('INGENUE_BUILD_CANCELED', 125);
+?>
diff --git a/shared/include/includes.php b/shared/include/includes.php
index 8a75b58..1394049 100644
--- a/shared/include/includes.php
+++ b/shared/include/includes.php
@@ -1,6 +1,7 @@
<?php
date_default_timezone_set('UTC');
require_once(dirname(__FILE__).'/paths.php'); // USE __dir__ in 5.3.0
+require_once(SHARED.'/include/definitions.php');
// Load functions and classes from the shared directory and either foreground or background
foreach (array('functions', 'classes') as $type) {
foreach (array(SHARED, ($_SERVER['DOCUMENT_ROOT']?FRONTEND:BACKEND)) as $dir) {
diff --git a/todo b/todo
index ee11830..05476c3 100644
--- a/todo
+++ b/todo
@@ -5,7 +5,7 @@ Add cleanup functions to the frontend and backend (tasks dir in backend containi
Only offer bundlers that will work - profiles without CD in map file can't make livecd, installcd, etc.
Allow config viewing for builds, not just configurations
Add `flags` column to configurations, builds, use it to implement public and private things
-Add 'cancel', option to builds, allow deletion of currently running builds
+Add 'cancel', option to builds, allow deletion of currently running builds (have backend check if canceled before and after each task)
Add build->configuration and configuration duplication
Add map file for liveCD, load it into DB, etc.
Add gentoo_profileopts column for liveCD, stage3, etc.
@@ -14,5 +14,10 @@ Add ability to trim the stage3 to a minimum set of packages automatically (cache
Add option to add arbitrary runscripts
Add option to upload a kernel
Add option to upload an arbitrary tar.gz/bz2 to be unzipped over the finished image
-*** Implement selected items from install-steps ***
-*** Documentation
+*** Implement selected items from gentoo-steps ***
+*** Documentation ***
+Ponder whether to remove the split-setup option and always upload to the frontend
+Improve the upload step so it tries more than once
+Offer FTP upload
+Offer SCP upload?
+Use zmedico's deafult USE flags script in backend/modules/gentoo_portage to trim the USE we put in the make.conf generated
diff --git a/update_sql_classes.php b/update_sql_classes.php
index 90a1d96..c345694 100755
--- a/update_sql_classes.php
+++ b/update_sql_classes.php
@@ -1,6 +1,5 @@
#!/usr/bin/php
<?php
-// TODO Get rid of interactive merging
require_once(dirname(__FILE__).'/shared/include/includes.php'); // USE __DIR__ in 5.3.0
require_once(SHARED.'/config.php');
require_once(SHARED.'/include/dbinit.php');
@@ -90,7 +89,7 @@ foreach ($tables as $i => $table) {
}
unlink('.temp_diff');
if (is_file('.temp_class'))
- unlink('.temp_class'); // TODO unlink others
+ unlink('.temp_class');
}
}
}
@@ -102,17 +101,8 @@ if ($tables) {
} else {
echo "No tables found without corresponding classes.\n";
}
-if (!$tables) {
+if (!$tables)
die("Exiting.\n");
- /*
- echo 'Which tables should we generate classes for? (space-separated) ';
- $tables=explode(' ', trim(fgets(STDIN)));
- if ($tables[0] == '') {
- echo "Exiting.\n";
- exit;
- }
- */
-}
echo 'Generating classes for table(s): '.implode(', ', $tables)."\n";
foreach ($tables as $table) {
$default='sql_';