diff options
Diffstat (limited to 'shared/classes')
-rw-r--r-- | shared/classes/buildopt.php | 2 | ||||
-rw-r--r-- | shared/classes/configopt.php | 2 | ||||
-rw-r--r-- | shared/classes/gentoo_baseinit.php | 23 | ||||
-rw-r--r-- | shared/classes/gentoo_basepkg.php | 19 | ||||
-rw-r--r-- | shared/classes/gentoo_profile.php | 35 |
5 files changed, 79 insertions, 2 deletions
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; + } } ?> |