summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-07-23 17:14:56 -0400
committerEudyptula <eitan@mosenkis.net>2009-07-23 17:14:56 -0400
commitb88a57ebaeb10a1fd1ebec0959f7eeeb5fc1e888 (patch)
tree56411c079cce9783aadf1425cc13a25a0db2fff6
parentUpdate todo (diff)
downloadingenue-b88a57ebaeb10a1fd1ebec0959f7eeeb5fc1e888.tar.gz
ingenue-b88a57ebaeb10a1fd1ebec0959f7eeeb5fc1e888.tar.bz2
ingenue-b88a57ebaeb10a1fd1ebec0959f7eeeb5fc1e888.zip
Use stage3 tarballs instead of doing emerge system
-rw-r--r--backend/modules/gentoo_portage/base-system.php5
-rw-r--r--backend/modules/gentoo_portage/build.php2
-rw-r--r--backend/modules/gentoo_portage/emerge-system.php10
-rw-r--r--gentoo_setup.php10
-rw-r--r--shared/classes/buildopt.php2
-rw-r--r--shared/classes/configopt.php2
-rw-r--r--shared/classes/gentoo_baseinit.php23
-rw-r--r--shared/classes/gentoo_basepkg.php19
-rw-r--r--shared/classes/gentoo_profile.php35
-rw-r--r--todo10
-rwxr-xr-xupdate_gentoo_profiles.php20
11 files changed, 117 insertions, 21 deletions
diff --git a/backend/modules/gentoo_portage/base-system.php b/backend/modules/gentoo_portage/base-system.php
new file mode 100644
index 0000000..df1eb26
--- /dev/null
+++ b/backend/modules/gentoo_portage/base-system.php
@@ -0,0 +1,5 @@
+<?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'");
+?>
diff --git a/backend/modules/gentoo_portage/build.php b/backend/modules/gentoo_portage/build.php
index 8e664e8..ad84a98 100644
--- a/backend/modules/gentoo_portage/build.php
+++ b/backend/modules/gentoo_portage/build.php
@@ -10,7 +10,7 @@ function gentoo_portage_build(&$build, &$opts, &$W) {
require(dirname(__FILE__).'/setup.php'); // __DIR__ in 5.3.0
if ($conf['debug'])
execute_command_with_env('Log portage setup', 'emerge --info', $prtg_cfgrt);
- require(dirname(__FILE__).'/emerge-system.php'); // __DIR__ 5.3.0
+ require(dirname(__FILE__).'/base-system.php'); // __DIR__ 5.3.0
if (in_array('timezone', $extra))
require(dirname(__FILE__).'/timezone.php'); // __DIR__ 5.3.0
if (in_array('dev-manager', $extra))
diff --git a/backend/modules/gentoo_portage/emerge-system.php b/backend/modules/gentoo_portage/emerge-system.php
deleted file mode 100644
index e7165fe..0000000
--- a/backend/modules/gentoo_portage/emerge-system.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-if (is_file(CACHE.'/system-'.$profile->id.'.tar.gz') && filemtime(CACHE.'/system-'.$profile->id.'.tar.gz') > filemtime($conf['pkgdir_root'].'/'.$profile->pkgdir.'/Packages')) {
- execute_command('Unpack cached base system', "tar -zxvf '".CACHE."/system-$profile->id.tar.gz' -C '$I'");
-} else {
- // TODO create make.conf, make.profile in target /etc
- portage_install('system', 'Install base system');
- execute_command('Cache base system for reuse', "tar -p --same-owner -czvf '$W/image.tar.gz' -C '$I' .");
- rename("$W/image.tar.gz", CACHE.'/system-'.$profile->id.'.tar.gz');
-}
-?>
diff --git a/gentoo_setup.php b/gentoo_setup.php
index 47cae96..657aa91 100644
--- a/gentoo_setup.php
+++ b/gentoo_setup.php
@@ -11,4 +11,14 @@ foreach (get_pkgdirs() as $dir) {
$profile->read_pkgsets();
echo "done\n";
}
+foreach (explode("\n", trim(file_get_contents(CACHE.'/stage3/map'))) as $line) {
+ list($profile, $file)=explode(' ', $line);
+ if (!is_numeric($profile)) continue;
+ $profile=new sql_gentoo_profile($profile);
+ $profile->stage3=$file;
+ $profile->write();
+ echo "Loading $profile->pkgdir stage3 data from $file...";
+ $profile->read_stage3();
+ echo "done\n";
+}
?>
diff --git a/shared/classes/buildopt.php b/shared/classes/buildopt.php
index 68dc3cd..4843576 100644
--- a/shared/classes/buildopt.php
+++ b/shared/classes/buildopt.php
@@ -15,7 +15,7 @@ class sql_buildopt extends sql_row_obj {
'default' => ''
),
'value' => array (
- 'type' => 'TEXT'
+ 'type' => 'LONGBLOB'
)
);
diff --git a/shared/classes/configopt.php b/shared/classes/configopt.php
index c157d22..de7de90 100644
--- a/shared/classes/configopt.php
+++ b/shared/classes/configopt.php
@@ -15,7 +15,7 @@ class sql_configopt extends sql_row_obj {
'default' => ''
),
'value' => array (
- 'type' => 'TEXT'
+ 'type' => 'LONGBLOB'
)
);
diff --git a/shared/classes/gentoo_baseinit.php b/shared/classes/gentoo_baseinit.php
new file mode 100644
index 0000000..d685635
--- /dev/null
+++ b/shared/classes/gentoo_baseinit.php
@@ -0,0 +1,23 @@
+<?php
+class sql_gentoo_baseinit extends sql_row_obj {
+ protected $table='gentoo_baseinit', $columns=array(
+ 'profile' => array (
+ 'type' => 'TINYINT',
+ 'length' => 3,
+ 'unsigned' => true,
+ 'not_null' => true
+ ),
+ 'name' => array (
+ 'type' => 'VARCHAR',
+ 'length' => 255,
+ 'not_null' => true
+ ),
+ 'runlevel' => array (
+ 'type' => 'VARCHAR',
+ 'length' => 255,
+ 'not_null' => true
+ )
+
+ );
+}
+?>
diff --git a/shared/classes/gentoo_basepkg.php b/shared/classes/gentoo_basepkg.php
new file mode 100644
index 0000000..824d495
--- /dev/null
+++ b/shared/classes/gentoo_basepkg.php
@@ -0,0 +1,19 @@
+<?php
+class sql_gentoo_basepkg extends sql_row_obj {
+ protected $table='gentoo_basepkgs', $columns=array(
+ 'profile' => array (
+ 'type' => 'TINYINT',
+ 'length' => 3,
+ 'unsigned' => true,
+ 'not_null' => true,
+ 'comment' => 'refers to:gentoo_profiles.id'
+ ),
+ 'pkg' => array (
+ 'type' => 'VARCHAR',
+ 'length' => 255,
+ 'not_null' => true
+ )
+
+ );
+}
+?>
diff --git a/shared/classes/gentoo_profile.php b/shared/classes/gentoo_profile.php
index 0cf071d..ad7a12f 100644
--- a/shared/classes/gentoo_profile.php
+++ b/shared/classes/gentoo_profile.php
@@ -15,6 +15,11 @@ class sql_gentoo_profile extends sql_row_obj {
'default' => '',
'unique' => true
),
+ 'stage3' => array (
+ 'type' => 'VARCHAR',
+ 'length' => 255,
+ 'not_null' => true
+ ),
'name' => array (
'type' => 'VARCHAR',
'length' => 255,
@@ -165,6 +170,30 @@ class sql_gentoo_profile extends sql_row_obj {
if ($update)
$S['pdo']->query('DELETE FROM `gentoo_pkgsets` WHERE `profile`='.$this->id.($exists?' AND `id` NOT IN ('.implode(',', $exists).')':''));
}
+ public function read_stage3($update=false) {
+ global $S;
+ if ($update) {
+ $S['pdo']->query('DELETE FROM `gentoo_basepkgs` WHERE `profile`='.$this->id);
+ $S['pdo']->query('DELETE FROM `gentoo_baseinit` WHERE `profile`='.$this->id);
+ }
+ $file=realpath(CACHE.'/stage3/'.$this->stage3);
+ if (!is_readable($file)) return false;
+ $opt='-tv'.(substr($file, -3) == 'bz2'?'j':'z').'f';
+ $prefix='./var/db/pkg/';
+ $files=explode("\n", is_readable("$file.CONTENTS")?file_get_contents("$file.CONTENTS"):shell_exec('tar '.$opt.' '.escapeshellarg($file)));
+ if (!is_file("$file.CONTENTS"))
+ file_put_contents("$file.CONTENTS", implode("\n", $files));
+ foreach ($files as $file) {
+ if (preg_match('#^[^.]+\./var/db/pkg/(.*/.*)/$#', $file, $match)) {
+ $pkg=new sql_gentoo_basepkg($this->id, $match[1]);
+ $pkg->write();
+ } elseif (preg_match('#^[^.]+\./etc/runlevels/([^/]+)/([^/]+) -> /etc/init\.d/#', $file, $match)) {
+ $init=new sql_gentoo_baseinit($this->id, $match[2], $match[1]);
+ $init->write();
+ }
+ }
+ return true;
+ }
public function &get_packages() {
global $S;
$r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE `profile`='.$this->id);
@@ -175,5 +204,11 @@ class sql_gentoo_profile extends sql_row_obj {
}
return $p;
}
+ function get_arch() {
+ $arch=$this->get_headers();
+ $arch=explode(' ', $arch['accept_keywords']);
+ $arch=ltrim($arch[0], '~');
+ return $arch;
+ }
}
?>
diff --git a/todo b/todo
index 0e41148..6c52996 100644
--- a/todo
+++ b/todo
@@ -9,15 +9,17 @@ Add masked indicator back to package selector, support ~arch installation
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
Move bundler selection out of gentoo module and generalize it
-Improve the quality of base system creation (if necessary)
- Figure out /lib -> /lib64 creation on amd64
Allow config viewing for builds, not just configurations
-Check if emerge system cache discards properly
Add `flags` column to configurations, builds, use it to implement public and private things
Clean up backend API
Add 'cancel', 'delete' options to builds
Add build->configuration and configuration duplication
+Add map file for liveCD, load it into DB, etc.
*** Switch over to use stage3's instead of doing emerge system ***
Write script for fetching latest stage3's from the desired FTP dirs
Add ability to trim the stage3 to a minimum set of packages automatically (cached) or manually (present db-cached list of packages present in stage3 and allow user to select which to remove)
- grep -o "/var/db/pkg/.*/.*/$" ~/downloads/stage3-amd64-20090716.tar.bz2.CONTENTS
+Only offer bundlers that will work - profiles without CD in map file can't make livecd, installcd, etc.
+Add option to remove default runscripts
+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
diff --git a/update_gentoo_profiles.php b/update_gentoo_profiles.php
index c01b455..e9f3ead 100755
--- a/update_gentoo_profiles.php
+++ b/update_gentoo_profiles.php
@@ -4,14 +4,26 @@ require_once(dirname(__FILE__).'/shared/include/includes.php'); // USE __DIR__ i
require_once(SHARED.'/config.php');
require_once(SHARED.'/include/dbinit.php');
$pdo=&$S['pdo'];
+$profiles=array();
$r=$pdo->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)) {
- $p=new sql_gentoo_profile($p);
- echo "Updating from {$conf['pkgdir_root']}/$p->pkgdir/Packages...\n";
- list($new, $updated, $deleted, $total)=$p->read_Packages(true, true);
+ $profiles[$p['id']]=new sql_gentoo_profile($p);
+ $profile=&$profiles[$p['id']];
+ echo "Updating from {$conf['pkgdir_root']}/$profile->pkgdir/Packages...\n";
+ list($new, $updated, $deleted, $total)=$profile->read_Packages(true, true);
echo "Packages: $new new, $updated updated, $deleted deleted, $total total.\n";
echo 'Updating package sets...';
- $p->read_pkgsets(true);
+ $profile->read_pkgsets(true);
echo "done\n";
}
+foreach (explode("\n", trim(file_get_contents(CACHE.'/stage3/map'))) as $line) {
+ list($p, $file)=explode(' ', $line, 2);
+ if (!is_numeric($p)) continue;
+ $profile=&$profiles[$p];
+ if ($profile->stage3 == $file) continue;
+ $profile->stage3=$file;
+ $profile->write();
+ echo "Loading info from profile $profile->pkgdir stage3 at $file...";
+ echo ($profile->read_stage3(true)?'done':color('failed', 'red'))."\n";
+}
?>