From ed4e6670c58817a6dece1a5531f683445dfedb84 Mon Sep 17 00:00:00 2001 From: Eudyptula Date: Thu, 6 Aug 2009 19:12:48 -0400 Subject: 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. --- backend/backend.php | 21 ++++++------- backend/bundlers/installcd.php | 15 ++-------- backend/bundlers/livecd.php | 16 ++-------- backend/functions/api.php | 2 +- backend/modules/gentoo_portage/base-system.php | 7 ++--- backend/modules/gentoo_portage/build.php | 12 +++++--- backend/modules/gentoo_portage/dev-manager.php | 7 ++--- backend/modules/gentoo_portage/hostname.php | 4 +++ backend/modules/gentoo_portage/packages.php | 2 +- backend/modules/gentoo_portage/portage.php | 41 +++++++++++++++++++------- backend/modules/gentoo_portage/profile_use.py | 8 +++++ backend/modules/gentoo_portage/setup.php | 2 +- backend/modules/gentoo_portage/timezone.php | 9 ++++-- depend | 1 + frontend/classes/forms.php | 2 +- frontend/include/constants.php | 19 ------------ frontend/include/setup.php | 7 ++++- frontend/index.php | 1 - frontend/modules/gentoo/step2.php | 4 +-- frontend/modules/gentoo/step3.php | 2 ++ frontend/pages/builds/delete.php | 8 +++-- frontend/pages/builds/download.php | 1 + gentoo-steps | 6 ++-- pkglist.php | 2 +- setup.php | 4 +-- shared/classes/0sql_row_obj.php | 6 ++-- shared/classes/build.php | 20 ++++++++----- shared/classes/session.php | 2 +- shared/functions/url.php | 9 +++--- shared/include/definitions.php | 9 ++++++ shared/include/includes.php | 1 + todo | 11 +++++-- update_sql_classes.php | 14 ++------- 33 files changed, 149 insertions(+), 126 deletions(-) create mode 100644 backend/modules/gentoo_portage/hostname.php create mode 100755 backend/modules/gentoo_portage/profile_use.py delete mode 100644 frontend/include/constants.php create mode 100644 shared/include/definitions.php 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 id").'">'.url("build/$build->id").''); } $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 id").'">'.url("build/$build->id").''); } $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 @@ 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 @@ 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 @@ + 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 @@ $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 @@ 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 "$this->label: "; } 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 @@ - 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 @@ 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 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='
'.(isset($this->name) && strlen($this->name)?htmlentities($this->name):'Unnamed Build').' '; $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.="[Queued ($num/$total)]"; - } elseif ($this->status == -127) { + $html.="[queued ($num/$total)]"; + } elseif ($this->status == INGENUE_BUILD_UPLOADING) { $html.='[uploading]'; if ($perms) $links['Build log']="build/$this->id"; + } elseif ($this->status == INGENUE_BUILD_CANCEL) { + $html.='[pending cancellation]'; + if ($perms) $links['Build log']="build/$this->id"; } elseif ($this->status < 0) { // TODO Build stage X $html.='[building]'; @@ -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']?'id/history").'">':'').$r['count'].' download'.($r['count'] != 1?'s':'').($r['count']?($perms?'':'').'
(last at '.date($format, $r['time']).')':''); $html.=''.$d.'[successful]'; $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.='[upload failed]'; if ($perms) $links['Build log']="build/$this->id"; - } elseif ($this->status == 126) { + } elseif ($this->status == INGENUE_BUILD_FAILED) { $html.='[failed]'; 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.='[canceled]'; + if ($perms) $links['Build log']="build/$this->id"; } else { $html.='[failed: got signal '.$this->status.']'; 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 @@ + 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 @@ 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 $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_'; -- cgit v1.2.3-65-gdbad