diff options
author | Eudyptula <eitan@mosenkis.net> | 2009-08-04 17:58:55 -0400 |
---|---|---|
committer | Eudyptula <eitan@mosenkis.net> | 2009-08-04 17:58:55 -0400 |
commit | d3da989d3e2d2cb03cdc4bd2e23783f716ef5035 (patch) | |
tree | 2f9f8c413d2800a3f72282dec0f86170a00ff4f6 /backend | |
parent | Add visibility column to builds, configurations (diff) | |
download | ingenue-d3da989d3e2d2cb03cdc4bd2e23783f716ef5035.tar.gz ingenue-d3da989d3e2d2cb03cdc4bd2e23783f716ef5035.tar.bz2 ingenue-d3da989d3e2d2cb03cdc4bd2e23783f716ef5035.zip |
Widespread cleanup - moved $conf, $death into $S; $S is given as arg to init_x() and body_x(); $request removed in favor of $_REQUEST; query() replaces $S[pdo]->query(); etc.
Diffstat (limited to 'backend')
-rwxr-xr-x | backend/backend.php | 24 | ||||
-rw-r--r-- | backend/functions/get_pkgdirs.php | 6 | ||||
-rw-r--r-- | backend/modules/gentoo_catalyst/build.php | 71 | ||||
-rw-r--r-- | backend/modules/gentoo_catalyst/catalyst.conf | 79 | ||||
-rw-r--r-- | backend/modules/gentoo_catalyst/catalystrc | 6 | ||||
-rw-r--r-- | backend/modules/gentoo_portage/base-system.php | 2 | ||||
-rw-r--r-- | backend/modules/gentoo_portage/build.php | 4 | ||||
-rw-r--r-- | backend/modules/gentoo_portage/packages.php | 4 | ||||
-rw-r--r-- | backend/modules/gentoo_portage/setup.php | 4 |
9 files changed, 22 insertions, 178 deletions
diff --git a/backend/backend.php b/backend/backend.php index 343be9f..5090c63 100755 --- a/backend/backend.php +++ b/backend/backend.php @@ -8,7 +8,7 @@ if (isset($opts['f'])) { case -1: die("Failed to fork"); case 0: - $conf['debug']=false; + $S['conf']['debug']=false; break; default: die(); @@ -49,19 +49,19 @@ declare(ticks=1); 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) - $S['pdo']->query('LOCK TABLES `builds` WRITE'); - $r=$S['pdo']->query('SELECT * FROM `builds` WHERE `status`=-128 ORDER BY `ctime` ASC LIMIT 1'); + query('LOCK TABLES `builds` WRITE'); + $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)); $build->start=time(); $build->status=-1; $build->write(); - $S['pdo']->query('UNLOCK TABLES'); + query('UNLOCK TABLES'); debug('Starting build id='.$build->id); $file=null; try { - if ($conf['split_setup']) { - $opt=new sql_buildopt($build->id, 'backend', $conf['backend_id']); + if ($S['conf']['split_setup']) { + $opt=new sql_buildopt($build->id, 'backend', $S['conf']['backend_id']); $opt->write(); unset($opt); } @@ -75,7 +75,7 @@ while (true) { require_once(BACKEND."/bundlers/{$opts['bundler']}.php"); $proc='bundle_'.$opts['bundler']; $file=$proc($image, $workdir, $opts); - if (!$conf['debug']) { + if (!$S['conf']['debug']) { execute_command('Delete work directory', 'rm -rf "'.$workdir.'"'); } } catch (Exception $e) { @@ -83,13 +83,13 @@ while (true) { log_msg('Caught exception: '.$e->getMessage()); $build->status=126; $owner=$build->get_owner(); - xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $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>'); + 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(); debug('Finished with build id='.$build->id); if (isset($file)) { debug("Completed build successfully"); - if ($conf['split_setup']) { + if ($S['conf']['split_setup']) { $build->status=-127; $build->write(); $key=randstring(30); @@ -104,7 +104,7 @@ while (true) { )); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); $result=curl_exec($c); - if ($conf['debug'] && is_string($result)) { + if ($S['conf']['debug'] && is_string($result)) { debug($result); } if ($result === false || strpos($result, 'Upload successful') === false) { @@ -120,12 +120,12 @@ while (true) { $ext=substr($base, strpos($base, '.')); rename($file, COMPLETED.'/build-'.$build->id.$ext); } - xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $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>'); + 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(); unset($build); } else { - $S['pdo']->query('UNLOCK TABLES'); + query('UNLOCK TABLES'); } // log_msg('Sleeping...', false); sleep(5); diff --git a/backend/functions/get_pkgdirs.php b/backend/functions/get_pkgdirs.php index 1f39420..b441f38 100644 --- a/backend/functions/get_pkgdirs.php +++ b/backend/functions/get_pkgdirs.php @@ -1,12 +1,12 @@ <?php function get_pkgdirs($dir=null) { - global $conf; + global $S; if ($dir===null) { - $dir=$conf['pkgdir_root']; + $dir=$S['conf']['pkgdir_root']; } if (is_file($dir.'/Packages')) { // We assume that a dir with a Packages file will not contain other complete ppkgdirs - return array(substr($dir, strlen($conf['pkgdir_root'])+1)); + return array(substr($dir, strlen($S['conf']['pkgdir_root'])+1)); } else { $return=array(); foreach (glob ($dir.'/*', GLOB_ONLYDIR) as $subdir) { diff --git a/backend/modules/gentoo_catalyst/build.php b/backend/modules/gentoo_catalyst/build.php deleted file mode 100644 index 80746b2..0000000 --- a/backend/modules/gentoo_catalyst/build.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php -function gentoo_catalyst_build(&$build, &$opts, &$W) { - global $conf, $profile; - $profile=new sql_gentoo_profile($opts['profile']); - $headers=$profile->get_headers(); - $arch=explode(' ', $headers['accept_keywords']); - $arch=$arch[0]; - if (substr($arch, 0, 1) == '~') - $arch=substr($arch, 1); -// $C=$W.'/config_root'; - makedirs('catalyst_tmp', 'snapshot_cache'); - $catalyst=array( - 'digests' => '', - 'contents' => '', - 'distdir' => '', - // 'envscript' => '', - 'hash_function' => 'crc32', - 'options' => 'pkgcache metadata_overlay seedcache snapcache', - 'portdir' => $conf['portdir'], - 'sharedir' => '/usr/lib/catalyst', // This may not work on all systems - 'snapshotcache' => "$W/snapshot_cache", - 'storedir' => "$W/catalyst_tmp" - ); - $ctc=fopen("$W/catalyst.conf", 'w'); - foreach ($catalyst as $name => $val) { - fputs($ctc, "$name=\"$val\"\n"); - } - fclose($ctc); - // TODO - stages 1-3 first, only do stage4 if we have extra packages to install - $spec=array( - 'subarch' => $arch, - 'version_stamp' => gmdate('Ymd-His'), - 'target' => 'stage4', - 'rel_type' => 'default', - 'profile' => $headers['profile'], - 'snapshot' => gmdate('Ymd'), - 'source_subpath' => 'default', // FIXME - 'portage_confdir' => '', - 'portage_overlay' => '', - 'pkgcache_path' => "$W/pkgcache", - 'kerncache_path' => '', - 'stage4/use' => $headers['use'], - 'stage4/packages' => $opts['install_packages'], - 'stage4/fsscript' => '', - 'stage4/splash_theme' => '', - 'stage4/gk_mainargs' => '', - 'stage4/linuxrc' => '', - 'stage4/motd' => '', -// 'stage4/modblacklist' => '8139cp', // Not recognized by catalyst - 'stage4/rcadd' => '', - 'stage4/rcdel' => '', - 'stage4/root_overlay' => '', - 'stage4/xinitrc' => '', - 'stage4/users' => '', - 'boot/kernel' => '', - 'stage4/unmerge' => '', - 'stage4/empty' => '/var/tmp /var/cache /var/db /var/empty /var/lock /var/log /var/run /var/spool /var/state /tmp /usr/portage /usr/share/man /usr/share/info /usr/share/unimaps /usr/include /usr/share/zoneinfo /usr/share/dict /usr/share/doc /usr/share/ss /usr/share/state /usr/share/texinfo /usr/lib/python2.2 /usr/lib/portage /usr/share/gettext /usr/share/i18n /usr/share/rfc /usr/lib/X11/config /usr/lib/X11/etc /usr/lib/X11/doc /usr/src /usr/share/doc /usr/share/man /root/.ccache /etc/cron.daily /etc/cron.hourly /etc/cron.monthly /etc/cron.weekly /etc/logrotate.d /etc/rsync /usr/lib/awk /usr/lib/ccache /usr/lib/gcc-config /usr/lib/nfs /usr/local /usr/diet/include /usr/diet/man /usr/share/consolefonts/partialfonts /usr/share/consoletrans /usr/share/emacs /usr/share/gcc-data /usr/share/genkernel /etc/splash/gentoo /etc/splash/emergence /usr/share/gnuconfig /usr/share/lcms /usr/share/locale /etc/skel', - 'stage4/rm' => '/lib/*.a /usr/lib/*.a /usr/lib/gcc-lib/*/*/libgcj* /etc/dispatch-conf.conf /etc/etc-update.conf /etc/*- /etc/issue* /etc/make.conf /etc/man.conf /etc/*.old /root/.viminfo /usr/sbin/fb* /usr/sbin/fsck.cramfs /usr/sbin/fsck.minix /usr/sbin/mkfs.minix /usr/sbin/mkfs.bfs /usr/sbin/mkfs.cramfs /lib/security/pam_access.so /lib/security/pam_chroot.so /lib/security/pam_debug.so /lib/security/pam_ftp.so /lib/security/pam_issue.so /lib/security/pam_mail.so /lib/security/pam_motd.so /lib/security/pam_mkhomedir.so /lib/security/pam_postgresok.so /lib/security/pam_rhosts_auth.so /lib/security/pam_userdb.so /usr/share/consolefonts/1* /usr/share/consolefonts/7* /usr/share/consolefonts/8* /usr/share/consolefonts/9* /usr/share/consolefonts/A* /usr/share/consolefonts/C* /usr/share/consolefonts/E* /usr/share/consolefonts/G* /usr/share/consolefonts/L* /usr/share/consolefonts/M* /usr/share/consolefonts/R* /usr/share/consolefonts/a* /usr/share/consolefonts/c* /usr/share/consolefonts/dr* /usr/share/consolefonts/g* /usr/share/consolefonts/i* /usr/share/consolefonts/k* /usr/share/consolefonts/l* /usr/share/consolefonts/r* /usr/share/consolefonts/s* /usr/share/consolefonts/t* /usr/share/consolefonts/v* /etc/splash/livecd-2006.1/16* /etc/splash/livecd-2006.1/12* /etc/splash/livecd-2006.1/6* /etc/splash/livecd-2006.1/8* /etc/splash/livecd-2006.1/images/silent-16* /etc/splash/livecd-2006.1/images/silent-12* /etc/splash/livecd-2006.1/images/silent-6* /etc/splash/livecd-2006.1/images/silent-8* /etc/splash/livecd-2006.1/images/verbose-16* /etc/splash/livecd-2006.1/images/verbose-12* /etc/splash/livecd-2006.1/images/verbose-6* /etc/splash/livecd-2006.1/images/verbose-8* /etc/make.conf.example /etc/make.globals /etc/resolv.conf' - ); - $specfile=fopen("$W/stage4.spec", 'w'); - foreach ($spec as $name => $val) { - if (strlen($val)) - fputs($specfile, "$name: $val\n"); - } - fclose($specfile); - $pkgdir=$spec['pkgcache_path'].'/'.$spec['rel_type'].'/'.$spec['target'].'-'.$spec['version_stamp']; - makedir(dirname($pkgdir)); - symlink($pkgdir, $profile->pkgdir); - execute_command('Running Catalyst for build stage 4', "catalyst -c '$W/catalyst.conf' -f '$W/stage4.spec'"); -} -?> diff --git a/backend/modules/gentoo_catalyst/catalyst.conf b/backend/modules/gentoo_catalyst/catalyst.conf deleted file mode 100644 index ba5505b..0000000 --- a/backend/modules/gentoo_catalyst/catalyst.conf +++ /dev/null @@ -1,79 +0,0 @@ -# /etc/catalyst/catalyst.conf - -# Simple desriptions of catalyst settings. Please refer to the online -# documentation for more information. - -# Creates a .DIGESTS file containing the hash output from any of the supported -# options below. Adding them all may take a long time. -# Supported options: sha1, sha224, ripemd128, ripemd320, sha384, crc32, -# ripemd256, sha256, sha512, ripemd160, md5 -digests="md5 sha1" - -# Creates a .CONTENTS file listing the contents of the file. Pick from any of -# the supported options below: -# auto - strongly recommended -# tar-tv - does 'tar tvf FILE' -# tar-tvz - does 'tar tvzf FILE' -# tar-tvy - does 'tar tvyf FILE' -# isoinfo-l - does 'isoinfo -l -i FILE' -# isoinfo-f - does 'isoinfo -f -i FILE' -# 'isoinfo-f' is the only option not chosen by the automatic algorithm. -# If this variable is empty, no .CONTENTS will be generated at all. -contents="auto" - -# distdir specifies where your distfiles are located. This setting should -# work fine for most default installations. -distdir="/usr/portage/distfiles" - -# envscript allows users to set options such as http proxies, MAKEOPTS, -# GENTOO_MIRRORS, or any other environment variables needed for building. -# The envscript file sets environment variables like so: -# export FOO="bar" -envscript="/etc/catalyst/catalystrc" - -# Internal hash function catalyst should use for things like autoresume, -# seedcache, etc. The default and fastest is crc32. You should not ever need -# to change this unless your OS does not support it. -# Supported options: sha1, sha224, ripemd128, ripemd320, sha384, crc32, -# ripemd256, sha256, sha512, ripemd160, md5 -hash_function="crc32" - -# options set different build-time options for catalyst. Some examples are: -# autoresume = Attempt to resume a failed build, clear the autoresume flags with -# the -a option to the catalyst cmdline. -p will clear the autoresume flags -# as well as your pkgcache and kerncache -# ( This option is not fully tested, bug reports welcome ) -# ccache = enables build time ccache support (highly recommended) -# distcc = enable distcc support for building. You have to set distcc_hosts in -# your spec file. -# icecream = enables icecream compiler cluster support for building -# kerncache = keeps a tbz2 of your built kernel and modules (useful if your -# build stops in livecd-stage2) -# metadata_overlay = enabled the metadata_overlay cache module in portage, which -# uses the in-tree metadata -# pkgcache = keeps a tbz2 of every built package (useful if your build stops -# prematurely) -# seedcache = use the build output of a previous target if it exists to speed up -# the copy -# snapcache = cache the snapshot so that it can be bind-mounted into the chroot. -# WARNING: moving parts of the portage tree from within fsscript *will* break -# your cache. The cache is unlinked before any empty or rm processing, though. -# -# (These options can be used together) -options="autoresume kerncache metadata_overlay pkgcache seedcache snapcache" - -# portdir specifies the source portage tree used by the snapshot target. -portdir="/usr/portage" - -# sharedir specifies where all of the catalyst runtime executables are. Most -# users do not need to change this. -sharedir="/usr/lib64/catalyst" - -# snapshot_cache specifies where the snapshots will be cached to if snapcache is -# enabled in the options. -snapshot_cache="/var/tmp/catalyst/snapshot_cache" - -# storedir specifies where catalyst will store everything that it builds, and -# also where it will put its temporary files and caches. -storedir="/var/tmp/catalyst" - diff --git a/backend/modules/gentoo_catalyst/catalystrc b/backend/modules/gentoo_catalyst/catalystrc deleted file mode 100644 index 581772d..0000000 --- a/backend/modules/gentoo_catalyst/catalystrc +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# This is an example catalystrc. As such, it doesn't actually *do* anything. - -# Uncomment the following to increase the number of threads used to compile. -# export MAKEOPTS="-j16" - diff --git a/backend/modules/gentoo_portage/base-system.php b/backend/modules/gentoo_portage/base-system.php index 35dc91e..a940c87 100644 --- a/backend/modules/gentoo_portage/base-system.php +++ b/backend/modules/gentoo_portage/base-system.php @@ -8,7 +8,7 @@ if ($opts['basesystem'] == 'manual' && $opts['prunepkgs']) { throw_exception('Base system autoprune not implemented - need package list'); $keep=explode(' ', $keep_pkgs); $remove=array(); - $r=$S['pdo']->query('SELECT * FROM `gentoo_basepkgs` WHERE `profile`='.$profile->id); + $r=query('SELECT * FROM `gentoo_basepkgs` WHERE `profile`='.$profile->id); while ($pkg=$r->fetch(PDO::FETCH_ASSOC)) { $pkg=$pkg['pkg']; if (($i=array_search($pkg, $keep)) === false) diff --git a/backend/modules/gentoo_portage/build.php b/backend/modules/gentoo_portage/build.php index aef8bde..5c1a1fd 100644 --- a/backend/modules/gentoo_portage/build.php +++ b/backend/modules/gentoo_portage/build.php @@ -2,13 +2,13 @@ require_once(dirname(__FILE__).'/packages.php'); // __DIR__ 5.3.0 // This is the main function that carries out a build from start to finish function gentoo_portage_build(&$build, &$opts, &$W) { - global $conf; + global $S; $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 ($conf['debug']) + 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 if (in_array('pruneinit', $extra)) diff --git a/backend/modules/gentoo_portage/packages.php b/backend/modules/gentoo_portage/packages.php index 234186c..cfbb71d 100644 --- a/backend/modules/gentoo_portage/packages.php +++ b/backend/modules/gentoo_portage/packages.php @@ -1,7 +1,7 @@ <?php function portage_install($pkgs, $desc=null, $opts=null, $use=null) { - global $prtg_cfgrt, $conf; - $opts=$conf['emerge_default_opts'].' '.($opts === null?'-K -n --root-deps=rdeps':$opts); + global $prtg_cfgrt, $S; + $opts=$S['conf']['emerge_default_opts'].' '.($opts === null?'-K -n --root-deps=rdeps':$opts); if (!$pkgs) return; if (!is_array($pkgs)) $pkgs=explode(' ', $pkgs); diff --git a/backend/modules/gentoo_portage/setup.php b/backend/modules/gentoo_portage/setup.php index d946b81..6e8bf03 100644 --- a/backend/modules/gentoo_portage/setup.php +++ b/backend/modules/gentoo_portage/setup.php @@ -4,7 +4,7 @@ $C=$W.'/config_root'; makedirs($I, $C, "$W/log", "$W/tmp"); log_status("Making symlink $C/etc -> .", symlink('.', "$C/etc")); $makeconf=array( - 'pkgdir' => $conf['pkgdir_root'].'/'.$profile->pkgdir, + 'pkgdir' => $S['conf']['pkgdir_root'].'/'.$profile->pkgdir, 'chost' => $headers['chost'], 'accept_keywords' => $headers['accept_keywords'], 'root' => $I, @@ -18,7 +18,7 @@ foreach ($makeconf as $name => $val) unset($makeconf); log_status('Writing '.$C.'/make.conf', file_put_contents($C.'/etc/make.conf', $contents)); unset($contents); -log_status('Making make.profile symlink to '.$conf['portdir'].'/profiles/'.$headers['profile'], symlink($conf['portdir'].'/profiles/'.$headers['profile'], $C.'/etc/make.profile')); +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; $prtg_cfgrt=array('PORTAGE_CONFIGROOT' => $C); end_internal_task(0); |