summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-07-10 14:09:00 -0400
committerEudyptula <eitan@mosenkis.net>2009-07-10 14:09:00 -0400
commit06ab593e5dd40df96f79179a68ba8f3d7c70033a (patch)
tree75f4d351328893b2cf7f6f9e74951409212ac576 /shared
parentFinished porting package selection to new wizard format - everything works again (diff)
downloadingenue-06ab593e5dd40df96f79179a68ba8f3d7c70033a.tar.gz
ingenue-06ab593e5dd40df96f79179a68ba8f3d7c70033a.tar.bz2
ingenue-06ab593e5dd40df96f79179a68ba8f3d7c70033a.zip
Made bundling finished images separate from modules in backend; added metadata for frontend modules; added default config options and simplified config file; added verbose output to update_gentoo_profiles.php; etc.
Diffstat (limited to 'shared')
-rw-r--r--shared/classes/gentoo_profile.php18
-rw-r--r--shared/config.php45
-rw-r--r--shared/functions/load_config.php12
-rw-r--r--shared/include/defaults.php32
-rw-r--r--shared/include/includes.php2
5 files changed, 83 insertions, 26 deletions
diff --git a/shared/classes/gentoo_profile.php b/shared/classes/gentoo_profile.php
index b705a97..b2b970f 100644
--- a/shared/classes/gentoo_profile.php
+++ b/shared/classes/gentoo_profile.php
@@ -48,9 +48,12 @@ class sql_gentoo_profile extends sql_row_obj {
return $this->headers_cache;
}
// Reads the data from the Packages file in $this->pkgdir
- public function read_Packages($update_pkgs=false) {
+ public function read_Packages($update_pkgs=false, $verbose=false) {
global $conf;
- $file=fopen($conf['pkgdir_root'].'/'.$this->pkgdir.'/Packages', 'r');
+ if (!is_readable($file="{$conf['pkgdir_root']}/$this->pkgdir/Packages")) {
+ throw_exception("Packages file doesn't exist for pkgdir $this->pkgdir");
+ }
+ $file=fopen($file, 'r');
$this->headers='';
while (!feof($file)) {
$line=rtrim(fgets($file));
@@ -83,6 +86,7 @@ class sql_gentoo_profile extends sql_row_obj {
}
if (isset($p[$bcat][$lcat][$name][$ver])) {
debug("Duplicate package $bcat$lcat/$name-$ver");
+ continue;
}
$p[$bcat][$lcat][$name][$ver]='';
$cur=&$p[$bcat][$lcat][$name][$ver];
@@ -91,20 +95,24 @@ class sql_gentoo_profile extends sql_row_obj {
}
}
unset($cur);
- $u=0;
+ $u=$d=$t=0;
if ($update_pkgs) {
global $S;
$r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE `profile`='.$this->id);
while ($pkg=$r->fetch(PDO::FETCH_ASSOC)) {
$pkg=new sql_gentoo_package($pkg);
if (isset($p[$pkg->bcat][$pkg->lcat][$pkg->name][$pkg->version])) {
+ $t++;
if ($pkg->data != $p[$pkg->bcat][$pkg->lcat][$pkg->name][$pkg->version]) {
$u++;
$pkg->data=$p[$pkg->bcat][$pkg->lcat][$pkg->name][$pkg->version];
+ if ($verbose) echo "U $pkg->bcat$pkg->lcat/$pkg->name/$pkg->version\n";
$pkg->write();
}
unset($p[$pkg->bcat][$pkg->lcat][$pkg->name][$pkg->version]);
} else {
+ $d++;
+ if ($verbose) echo "D $pkg->bcat$pkg->lcat/$pkg->name-$pkg->version\n";
$pkg->delete();
}
}
@@ -114,14 +122,16 @@ class sql_gentoo_profile extends sql_row_obj {
foreach ($lcats as $lcat => $pkgs) {
foreach ($pkgs as $pkg => $vers) {
foreach ($vers as $ver => $data) {
+ $t++;
$n++;
$gp=new sql_gentoo_package(null, $this->id, $bcat, $lcat, $pkg, $ver, $data);
+ if ($verbose) echo "A $bcat$lcat/$pkg-$ver\n";
$gp->write();
}
}
}
}
- return array($n, $u);
+ return array($n, $u, $d, $t);
}
public function &get_packages() {
global $S;
diff --git a/shared/config.php b/shared/config.php
index b42cb8a..1ac1ae7 100644
--- a/shared/config.php
+++ b/shared/config.php
@@ -1,23 +1,26 @@
<?php
-$conf['title']='Ingenue'; // Used in <title>
-$conf['sqlhost']='localhost'; // MySQL server
-$conf['sqluser']='soc'; // MySQL username
-$conf['sqlpass']='socpassword'; // MySQL password
-$conf['sqldb']='soc'; // MySQL database
-$conf['debug']=true; // Whether to print debugging information
-$conf['cache']=true; // Whether to enable built-in caching
-$conf['modules']='gentoo_portage x gentoo_catalyst'; // Space-separated list of modules to offer the user
-$conf['cookiename']='ingenueid'; // Name of the cookie to send for keeping sessions
-$conf['sessionlength']=1814400; // Time in seconds before sessions are purged
-$conf['timezone']=10800; // Time difference in seconds between UTC and the default timezone
-$conf['mod_rewrite']=true; // Use mod_rewrite for pretty URLs
-$conf['emailfrom']='noreply@gentoo.org'; // Used as the From: field in emails
-$conf['check_email_dns']=true; // Use DNS to check the domain of submitted emails for validity
-$conf['pkgdir_root']='/home/eitan/soc/tinderbox'; // The directory to recursively search for pkgdirs in (Backend only)
-$conf['emerge_default_opts']='-t -v -K --color=y --root-deps=rdeps'; // DON'T CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING
-$conf['portdir']='/usr/portage'; // The directory conatining the portage tree to use (/usr/portage unless you have a reason to think otherwise)
-$conf['logview_max']=1000; // The maximum number of log entries shown on one page (1000 is a good start)
-$conf['split_setup']=true; // Whether the frontend and backend are running on different hosts
-$conf['frontend_location']='http://soc'; // The base address of the frontend installation (for use by the backend)
-$conf['backend_id']='red'; // A name or other way of identifying this backend as opposed to other backends working for the same frontend TODO use gethostname() by default in 5.3.0
+// Default values are commented
+// $title='Ingenue'; // Used in <title> and in emails
+// $sqlhost='localhost'; // MySQL server
+$sqluser='soc'; // MySQL username
+$sqlpass='socpassword'; // MySQL password
+$sqldb='soc'; // MySQL database
+$debug=true; // Whether to print debugging information
+// $modules='All non-hidden dirs in frontend/modules'; // Space-separated list of modules to offer the user
+// $bundlers='All non-hidden <bundler>.php files in backend/bundlers'; // Space-separated list of bundlers to offer the user
+// $cookiename='ingenueid'; // Name of the cookie to send for keeping sessions
+// $sessionlength=1814400; // Time in seconds before sessions are purged
+// $mod_rewrite=true; // Use mod_rewrite for pretty URLs
+$emailfrom='noreply@gentoo.org'; // Used as the From: field in emails
+$check_email_dns=true; // Use DNS to check the domain of submitted emails for validity
+// $split_setup=false; // Whether the frontend and backend are running on different hosts
+// Frontend options:
+// $logview_max=1000; // The maximum number of log entries shown on one page (1000 is a good start)
+// $progressbar_width=350; // The width, in pixels, of the config wizard progress bar
+// Backend options:
+$pkgdir_root='/home/eitan/soc/tinderbox'; // The directory to recursively search for pkgdirs (Backend only)
+// $emerge_default_opts='-t -v -K --color=y --root-deps=rdeps'; // DON'T CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING
+// $portdir='/usr/portage'; // The directory conatining the portage tree to use (/usr/portage unless you have a reason to think otherwise)
+$frontend_location='http://soc'; // The base address of the frontend installation
+$backend_id='red'; // A name or other way of identifying this backend as opposed to other backends working for the same frontend TODO use gethostname() by default in 5.3.0
?>
diff --git a/shared/functions/load_config.php b/shared/functions/load_config.php
new file mode 100644
index 0000000..27e01bc
--- /dev/null
+++ b/shared/functions/load_config.php
@@ -0,0 +1,12 @@
+<?php
+function load_config() {
+ require(SHARED.'/include/defaults.php');
+ require(SHARED.'/config.php');
+ $modules=explode(' ', $modules);
+ foreach (explode(' ', 'title sqlhost sqluser sqlpass sqldb debug modules bundlers cookiename sessionlength mod_rewrite emailfrom check_email_dns split_setup logview_max progressbar_width pkgdir_root emerge_default_opts portdir frontend_location backend_id') as $var) {
+ if (isset($$var)) {
+ $GLOBALS['conf'][$var]=$$var;
+ }
+ }
+}
+?>
diff --git a/shared/include/defaults.php b/shared/include/defaults.php
new file mode 100644
index 0000000..4065cc0
--- /dev/null
+++ b/shared/include/defaults.php
@@ -0,0 +1,32 @@
+<?php
+$title='Ingenue';
+$sqlhost='localhost';
+$sqluser=posix_getpwuid(posix_geteuid());
+$sqluser=$sqluser['name'];
+$sqlpass=null;
+$sqldb='ingenue';
+$debug=false;
+$modules=array();
+foreach (glob(FRONTEND.'/modules/*.info') as $module) {
+ $module=basename($module);
+ $modules[]=substr($module, 0, strlen($module)-5);
+}
+$modules=implode(' ', $modules);
+$bundlers=array();
+foreach (glob(BACKEND.'/bundlers/*.php') as $bundler) {
+ $bundler=basename($bundler);
+ $bundlers[]=substr($bundler, 0, strlen($bundler)-4);
+}
+$bundlers=implode(' ', $bundlers);
+$cookiename='ingenueid';
+$sessionlength=1814400;
+$mod_rewrite=true;
+$emailfrom='noreply@noreply.net';
+$check_email_dns=false;
+$split_setup=false;
+$logview_max=1000;
+$progressbar_width=350;
+$emerge_default_opts='-t -v -K --color=y --root-deps=rdeps';
+$portdir='/usr/portage';
+//$backend_id=gethostname(); // TODO Uncomment in 5.3.0
+?>
diff --git a/shared/include/includes.php b/shared/include/includes.php
index ae12d81..bfd358d 100644
--- a/shared/include/includes.php
+++ b/shared/include/includes.php
@@ -9,5 +9,5 @@ foreach (array('functions', 'classes') as $type) {
}
}
unset($dir, $file, $type);
-require_once(SHARED.'/config.php');
+load_config();
?>