diff options
Diffstat (limited to 'shared/classes/gentoo_profile.php')
-rw-r--r-- | shared/classes/gentoo_profile.php | 35 |
1 files changed, 35 insertions, 0 deletions
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; + } } ?> |