summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'backend/functions/read_stage3.php')
-rw-r--r--backend/functions/read_stage3.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/backend/functions/read_stage3.php b/backend/functions/read_stage3.php
new file mode 100644
index 0000000..21cfd01
--- /dev/null
+++ b/backend/functions/read_stage3.php
@@ -0,0 +1,26 @@
+<?php
+function read_stage3($entry, $update=false) {
+ global $S;
+ if ($update) {
+ query('DELETE FROM `gentoo_basepkgs` WHERE `key`="'.$entry->key.'"');
+ query('DELETE FROM `gentoo_baseinit` WHERE `key`="'.$entry->key.'"');
+ }
+ $file=CACHE."/$entry->file";
+ 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($entry->key, $match[1]);
+ $pkg->write();
+ } elseif (preg_match('#^[^.]+\./etc/runlevels/([^/]+)/([^/]+) -> /etc/init\.d/#', $file, $match)) {
+ $init=new sql_gentoo_baseinit($entry->key, $match[2], $match[1]);
+ $init->write();
+ }
+ }
+ return true;
+}
+?>