summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-07-16 16:39:03 -0400
committerEudyptula <eitan@mosenkis.net>2009-07-16 16:39:03 -0400
commitb04ca72439752a5c964c75b18994311d0aef5618 (patch)
tree13a190764f26bffea538ea77aaa7a15108c454cd
parentAdd dev-manager support to gentoo/portage modules (diff)
downloadingenue-b04ca72439752a5c964c75b18994311d0aef5618.tar.gz
ingenue-b04ca72439752a5c964c75b18994311d0aef5618.tar.bz2
ingenue-b04ca72439752a5c964c75b18994311d0aef5618.zip
Added predefined package sets; separated gentoo-specific setup into gentoo_setup.php
-rw-r--r--backend/modules/gentoo_portage/build.php13
-rw-r--r--frontend/modules/gentoo/step2.php19
-rw-r--r--frontend/modules/gentoo/step3.php28
-rw-r--r--frontend/modules/gentoo/step4.php25
-rw-r--r--frontend/modules/gentoo_common.php2
-rw-r--r--gentoo_pkgsets.csv7
-rw-r--r--gentoo_setup.php14
-rwxr-xr-xsetup.php20
-rw-r--r--shared/classes/build.php3
-rw-r--r--shared/classes/gentoo_package.php20
-rw-r--r--shared/classes/gentoo_pkgset.php32
-rw-r--r--shared/classes/gentoo_profile.php30
-rw-r--r--todo7
-rwxr-xr-xupdate_gentoo_profiles.php3
14 files changed, 178 insertions, 45 deletions
diff --git a/backend/modules/gentoo_portage/build.php b/backend/modules/gentoo_portage/build.php
index 599c9fe..1b18bf5 100644
--- a/backend/modules/gentoo_portage/build.php
+++ b/backend/modules/gentoo_portage/build.php
@@ -14,12 +14,23 @@ function gentoo_portage_build(&$build, &$opts, &$W) {
if ($conf['debug'])
execute_command_with_env('Log portage setup', 'emerge --info', $prtg_cfgrt);
require(dirname(__FILE__).'/emerge-system.php'); // __DIR__ 5.3.0
- if (in_array('timezone', $extra))
+ if (in_array('timezone', $extra)) {
+ $pkgs='sys-libs/timezone-data';
+ require(dirname(__FILE__).'/packages.php'); // __DIR__ 5.3.0
require(dirname(__FILE__).'/timezone.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')
execute_command_with_env('Install LiveCD utilities', 'emerge -1 livecd-tools', $prtg_cfgrt);
+ if (strlen($opts['pkgsets'])) {
+ foreach (explode(' ', $opts['pkgsets']) as $pkgset) {
+ if (strlen($opts['pkgset-'.$pkgset])) {
+ $pkgs=$opts['pkgset-'.$pkgset];
+ require(dirname(__FILE__).'/packages.php'); // __DIR__ 5.3.0
+ }
+ }
+ }
if (strlen($opts['install_packages'])) {
$pkgs=$opts['install_packages'];
require(dirname(__FILE__).'/packages.php'); // __DIR__ 5.3.0
diff --git a/frontend/modules/gentoo/step2.php b/frontend/modules/gentoo/step2.php
index b5b95df..2c9f769 100644
--- a/frontend/modules/gentoo/step2.php
+++ b/frontend/modules/gentoo/step2.php
@@ -1,12 +1,13 @@
<?php
+$this->checkbox_array('options', 'options', 'Configuration options', array('timezone' => 'Select timezone', 'dev-manager' => 'Select /dev manager'));
$profile=new sql_gentoo_profile($this->get_opt('profile'));
-$pkgs=$profile->get_packages();
-$meta=array(
- array('id' => 'plist', 'autosize'=> true),
- array('delim' => '', 'tag' => 'div', 'label' => '%n', 'collapsed' => true),
- array('delim' => '/', 'tag' => 'div', 'label' => '%p', 'collapsed' => true),
- array('delim' => '-', 'tag' => 'div', 'label' => '%p: $desc', 'checkbox' => '%p', 'collapsed' => true, 'search' => true),
- array('tag' => 'div', 'label' => '=%p', 'checkbox' => '=%p', 'search' => true)
-);
-$this->layered_checkbox_array('install_packages', 'p', null, $pkgs, ' ', $meta);
+global $S;
+$pkgsets=array();
+$r=$S['pdo']->query('SELECT * FROM `gentoo_pkgsets` WHERE `profile`='.$profile->id);
+while ($pkgset=$r->fetch(PDO::FETCH_ASSOC)) {
+ $pkgset=new sql_gentoo_pkgset($pkgset);
+ $pkgsets[$pkgset->id]=$pkgset->name;
+}
+if ($pkgsets)
+ $this->checkbox_array('pkgsets', 'pkgsets', 'Select packages from the following groups', $pkgsets);
?>
diff --git a/frontend/modules/gentoo/step3.php b/frontend/modules/gentoo/step3.php
index ee0cb84..89e7ec3 100644
--- a/frontend/modules/gentoo/step3.php
+++ b/frontend/modules/gentoo/step3.php
@@ -1,3 +1,29 @@
<?php
-$this->checkbox_array('options', 'options', null, array('timezone' => 'Select timezone', 'dev-manager' => 'Select /dev manager'));
+$opts=explode(' ', $this->get_opt('options'));
+if (in_array('timezone', $opts))
+ $this->select('timezone', 'timezone', 'Timezone', get_timezones());
+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($opts['profile']);
+foreach (explode(' ', $this->get_opt('pkgsets')) as $pkgset) {
+ $pkgset=new sql_gentoo_pkgset($pkgset);
+ $pkgs=array();
+ foreach (explode("\n", $pkgset->packages) as $pkg) {
+ if ($obj=sql_gentoo_package::from_atom($pkg, $profile)) {
+ $array=$obj->to_array();
+ $pkgs[$pkg]="$pkg: {$array['desc']}";
+ }
+ }
+ $this->checkbox_array('pkgset-'.$pkgset->id, 'pkgset-'.$pkgset->id, $pkgset->name, $pkgs);
+}
+// TODO This shouldn't be a step at all, it should be in wizard.php to choose between bundlers
+// TODO This shouldn't be part of configurations, except possibly a default value. It should be for builds
+$this->select('bundler', 'bundler', 'Image type', array(
+ 'tgz' => 'Tar/Gzip',
+ 'tbz2' => 'Tar/Bzip2',
+ 'installcd' => 'Installer CD with Tar/Bzip2',
+ 'livecd' => 'LiveCD',
+ 'ext2' => 'ext2',
+ 'jffs2' => 'jffs2'
+));
?>
diff --git a/frontend/modules/gentoo/step4.php b/frontend/modules/gentoo/step4.php
index 3eb3e1d..b5b95df 100644
--- a/frontend/modules/gentoo/step4.php
+++ b/frontend/modules/gentoo/step4.php
@@ -1,17 +1,12 @@
<?php
-$opts=explode(' ', $this->get_opt('options'));
-if (in_array('timezone', $opts))
- $this->select('timezone', 'timezone', 'Timezone', get_timezones());
-if (in_array('dev-manager', $opts))
- $this->select('dev-manager', 'dev-manager', '/dev Manager', array('udev' => 'udev', 'static-dev' => 'Static /dev'));
-// TODO This shouldn't be a step at all, it should be in wizard.php to choose between bundlers
-// TODO This shouldn't be part of configurations, except possibly a default value. It should be for builds
-$this->select('bundler', 'bundler', 'Image type', array(
- 'tgz' => 'Tar/Gzip',
- 'tbz2' => 'Tar/Bzip2',
- 'installcd' => 'Installer CD with Tar/Bzip2',
- 'livecd' => 'LiveCD',
- 'ext2' => 'ext2',
- 'jffs2' => 'jffs2'
-));
+$profile=new sql_gentoo_profile($this->get_opt('profile'));
+$pkgs=$profile->get_packages();
+$meta=array(
+ array('id' => 'plist', 'autosize'=> true),
+ array('delim' => '', 'tag' => 'div', 'label' => '%n', 'collapsed' => true),
+ array('delim' => '/', 'tag' => 'div', 'label' => '%p', 'collapsed' => true),
+ array('delim' => '-', 'tag' => 'div', 'label' => '%p: $desc', 'checkbox' => '%p', 'collapsed' => true, 'search' => true),
+ array('tag' => 'div', 'label' => '=%p', 'checkbox' => '=%p', 'search' => true)
+);
+$this->layered_checkbox_array('install_packages', 'p', null, $pkgs, ' ', $meta);
?>
diff --git a/frontend/modules/gentoo_common.php b/frontend/modules/gentoo_common.php
index ee2e7f1..b1e36b6 100644
--- a/frontend/modules/gentoo_common.php
+++ b/frontend/modules/gentoo_common.php
@@ -1,4 +1,4 @@
<?php
-$steps=array('Profile', 'Packages', 'Extra Options', 'Etc.');
+$steps=array('Profile', 'Extra Options', 'Etc.', 'Misc. Packages');
$dir='gentoo';
?>
diff --git a/gentoo_pkgsets.csv b/gentoo_pkgsets.csv
new file mode 100644
index 0000000..34d506a
--- /dev/null
+++ b/gentoo_pkgsets.csv
@@ -0,0 +1,7 @@
+HTTP Servers apache lighttpd mini_httpd thttpd
+FTP Servers pure-ftpd proftpd oftpd vsftpd
+Cron Daemons vixie-cron dcron fcron anacron
+Loggers logrotate syslog-ng rsyslog sysklogd metalog
+Filesystem Tools xfsprogs reiserfsprogs jfsutils
+DHCP Clients dhcpcd dhclient pump
+Desktop Environments gnome kde gnome-light blackbox fluxbox openbox enlightenment
diff --git a/gentoo_setup.php b/gentoo_setup.php
new file mode 100644
index 0000000..47cae96
--- /dev/null
+++ b/gentoo_setup.php
@@ -0,0 +1,14 @@
+<?php
+$profiles=array();
+foreach (get_pkgdirs() as $dir) {
+ echo 'Creating profile for '.$conf['pkgdir_root'].'/'.$dir.'...';
+ $profiles[]=new sql_gentoo_profile();
+ $profile=&$profiles[count($profiles)-1];
+ $profile->pkgdir=$dir;
+ echo "done\n";
+ echo 'Loading data from '.$conf['pkgdir_root'].'/'.$dir.'/Packages...';
+ $profile->read_Packages();
+ $profile->read_pkgsets();
+ echo "done\n";
+}
+?>
diff --git a/setup.php b/setup.php
index 532bf9f..fc4e001 100755
--- a/setup.php
+++ b/setup.php
@@ -2,19 +2,19 @@
<?php
require_once(dirname(__FILE__).'/shared/include/includes.php'); // USE __DIR__ in 5.3.0
function echo_and_query($q) {
- global $pdo;
+ global $S;
echo $q."\n";
- return $pdo->query($q);
+ return $S['pdo']->query($q);
}
$interactive=posix_isatty(STDIN);
$opts=getopt('R');
-$pdo=new PDO('mysql:host='.$conf['sqlhost'], $conf['sqluser'], $conf['sqlpass']);
+$S['pdo']=new PDO('mysql:host='.$conf['sqlhost'], $conf['sqluser'], $conf['sqlpass']);
if (isset($opts['R'])) {
echo_and_query('DROP DATABASE IF EXISTS `'.$conf['sqldb'].'`');
}
echo_and_query('CREATE DATABASE IF NOT EXISTS `'.$conf['sqldb'].'`'); // We can add charset and collate here if we want
echo_and_query('USE `'.$conf['sqldb'].'`');
-sql_row_obj::set_pdo_obj($pdo);
+sql_row_obj::set_pdo_obj($S['pdo']);
foreach (get_declared_classes() as $class) {
if (!is_subclass_of($class, 'sql_row_obj')) {
continue;
@@ -28,15 +28,6 @@ foreach (get_declared_classes() as $class) {
}
echo_and_query($o->create_table());
}
-foreach (get_pkgdirs() as $dir) {
- echo 'Creating profile for '.$conf['pkgdir_root'].'/'.$dir.'...';
- $profile=new sql_gentoo_profile();
- $profile->pkgdir=$dir;
- echo "done\n";
- echo 'Loading data from '.$conf['pkgdir_root'].'/'.$dir.'/Packages...';
- $profile->read_Packages();
- echo "done\n";
-}
do {
if ($user->email) {
echo 'Invalid entry: '.$user->email."\n";
@@ -77,4 +68,7 @@ if ($interactive) {
$user->passhash=substr($pass, 0, 5)=='sha1:'?substr($pass, 5):sha1($pass);
$user->flags='a'; // Admin
$user->write();
+foreach (glob(dirname(__FILE__).'/*_setup.php') as $file) { // __DIR__ 5.3.0
+ require($file);
+}
?>
diff --git a/shared/classes/build.php b/shared/classes/build.php
index 3f76b7d..8b19b41 100644
--- a/shared/classes/build.php
+++ b/shared/classes/build.php
@@ -22,7 +22,8 @@ class sql_build extends conf_build_common {
'module' => array (
'type' => 'VARCHAR',
'length' => 255,
- 'not_null' => true
+ 'not_null' => true,
+ 'default' => ''
),
'status' => array (
'type' => 'VARCHAR',
diff --git a/shared/classes/gentoo_package.php b/shared/classes/gentoo_package.php
index f16a3e1..4426565 100644
--- a/shared/classes/gentoo_package.php
+++ b/shared/classes/gentoo_package.php
@@ -66,5 +66,25 @@ class sql_gentoo_package extends sql_row_obj {
$heads=$this->get_profile()->get_headers();
return !count(array_intersect(explode(' ', $array['keywords']), explode(' ', $heads['accept_keywords'])));
}
+ public static function from_atom($atom, &$profile=null) {
+ global $S;
+ if (strpos($atom, '/')) {
+ list($bcat, $name)=explode('/', $atom);
+ if ($i=strpos($bcat, '-')) {
+ $lcat=substr($bcat, $i);
+ $bcat=substr($bcat, 0, strlen($bcat)-strlen($lcat));
+ }
+ } else {
+ $name=$atom;
+ }
+ $c=array();
+ if ($profile) $c[]='`profile`='.$profile->id;
+ if ($bcat) $c[]='`bcat`="'.$bcat.'"';
+ if ($lcat) $c[]='`lcat`="'.$lcat.'"';
+ if ($name) $c[]='`name`="'.$name.'"';
+ $c=implode(' AND ', $c);
+ $r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE '.$c.' LIMIT 1');
+ return $r->rowCount()?new sql_gentoo_package($r->fetch(PDO::FETCH_ASSOC)):null;
+ }
}
?>
diff --git a/shared/classes/gentoo_pkgset.php b/shared/classes/gentoo_pkgset.php
new file mode 100644
index 0000000..3829bbb
--- /dev/null
+++ b/shared/classes/gentoo_pkgset.php
@@ -0,0 +1,32 @@
+<?php
+class sql_gentoo_pkgset extends sql_row_obj {
+ protected $table='gentoo_pkgsets', $primary_key=array('id'), $columns=array(
+ 'id' => array (
+ 'type' => 'TINYINT',
+ 'length' => 3,
+ 'unsigned' => true,
+ 'not_null' => true,
+ 'auto_increment' => true
+ ),
+ 'profile' => array (
+ 'type' => 'TINYINT',
+ 'length' => 3,
+ 'unsigned' => true,
+ 'not_null' => true,
+ 'default' => 0,
+ 'refers_to' => 'gentoo_profiles.id'
+ ),
+ 'name' => array (
+ 'type' => 'VARCHAR',
+ 'length' => 255,
+ 'not_null' => true,
+ 'default' => ''
+ ),
+ 'packages' => array (
+ 'type' => 'TEXT',
+ 'not_null' => true
+ )
+
+ );
+}
+?>
diff --git a/shared/classes/gentoo_profile.php b/shared/classes/gentoo_profile.php
index b2b970f..5657ed1 100644
--- a/shared/classes/gentoo_profile.php
+++ b/shared/classes/gentoo_profile.php
@@ -133,6 +133,36 @@ class sql_gentoo_profile extends sql_row_obj {
}
return array($n, $u, $d, $t);
}
+ public function read_pkgsets($update=false) {
+ global $S;
+ $file=realpath(BACKEND.'/../gentoo_pkgsets.csv');
+ if (!is_readable($file)) return false;
+ $file=fopen($file, 'r');
+ while (!feof($file)) {
+ $add=array();
+ $pkgs=explode("\t", rtrim(fgets($file)));
+ $name=array_shift($pkgs);
+ $obj=new sql_gentoo_pkgset();
+ if ($update) {
+ $r=$S['pdo']->query('SELECT * FROM `gentoo_pkgsets` WHERE `profile`='.$this->id.' AND `name`="'.$name.'" LIMIT 1');
+ if ($r->rowCount()) {
+ $obj->from_array($r->fetch(PDO::FETCH_ASSOC), true);
+ }
+ }
+ foreach ($pkgs as $pkg) {
+ if ($pkg=sql_gentoo_package::from_atom($pkg, $this))
+ $add[]="$pkg->bcat$pkg->lcat/$pkg->name";
+ }
+ if (count($add)) {
+ $obj->profile=$this->id;
+ $obj->name=$name;
+ $obj->packages=implode("\n", $add);
+ $obj->write();
+ } elseif (isset($obj->id)) {
+ $obj->delete();
+ }
+ }
+ }
public function &get_packages() {
global $S;
$r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE `profile`='.$this->id);
diff --git a/todo b/todo
index 0c277a1..821c195 100644
--- a/todo
+++ b/todo
@@ -8,7 +8,6 @@ Have builds and tasks not give links to logs if we're already viewing the logs
Either make task status a TEXT or stop putting command name in the status (via thrown exception) - we can fetch this later anyway - just store the task id that failed (or use the last task)
Consider saving env. passed to tasks, path if we ever use it
Add metadata back to logviewer
-Add configurable groups of suggested packages to frontend, backend
Add a statistics page
Add a profiles management page/backend utility
Add cleanup functions to the frontend and backend (tasks dir in backend containing scripts that can be launched through frontend)
@@ -18,9 +17,9 @@ Completely plan out how frontend modules should function - each step needs to re
Allow backend to define bail-out functions to call when it dies (things like unmounting the ISO it was copying)
Add STDERR (maybe STDOUT) only option to log viewer
Simplify status to numeric on builds - varchar isn't necessary
-Move gentoo_profiles setup out of the general setup.php, allow per-module setup
-Move bundler selection out of gentoo module and generalize it (switch to builds instead of configurations)
+Move bundler selection out of gentoo module and generalize it
Improve the quality of base system creation (if necessary)
-Allow config viewing for builds, not just logs
+Allow config viewing for builds, not just configurations
Write basic command-line wrapper to bkisofs and replace the ISO mounter with it
Fix emerge system cache to discard properly
+Make sure that pkgsets updater in sql_gentoo_profile will remove empty and nonexistent pkgsets
diff --git a/update_gentoo_profiles.php b/update_gentoo_profiles.php
index c2e9f20..c01b455 100755
--- a/update_gentoo_profiles.php
+++ b/update_gentoo_profiles.php
@@ -10,5 +10,8 @@ while ($p=$r->fetch(PDO::FETCH_ASSOC)) {
echo "Updating from {$conf['pkgdir_root']}/$p->pkgdir/Packages...\n";
list($new, $updated, $deleted, $total)=$p->read_Packages(true, true);
echo "Packages: $new new, $updated updated, $deleted deleted, $total total.\n";
+ echo 'Updating package sets...';
+ $p->read_pkgsets(true);
+ echo "done\n";
}
?>