diff options
-rw-r--r-- | import.packages.php | 86 |
1 files changed, 74 insertions, 12 deletions
diff --git a/import.packages.php b/import.packages.php index ea555c4..0692f7c 100644 --- a/import.packages.php +++ b/import.packages.php @@ -1,6 +1,6 @@ <? -// $verbose = true; + $verbose = true; // $debug = false; /** @@ -38,7 +38,11 @@ require_once 'class.portage.category.php'; require_once 'class.portage.package.php'; + require_once 'class.portage.package.changelog.php'; + require_once 'class.portage.package.manifest.php'; require_once 'class.db.package.php'; + require_once 'class.db.package.changelog.php'; + require_once 'class.db.package.manifest.php'; $arr_update = array(); @@ -120,21 +124,79 @@ foreach($arr_diff['insert'] as $package_name) { $p = new PortagePackage($category_name, $package_name); + $ch = new PackageChangelog($category_name, $package_name); + $ma = new PackageManifest($category_name, $package_name); $arr_insert = array( 'category' => $category_id, 'name' => $package_name, - 'changelog' => $p->changelog, 'portage_mtime' => $p->portage_mtime, - 'changelog_mtime' => $p->changelog_mtime, - 'metadata_mtime' => $p->metadata_mtime, ); $db->autoExecute($table, $arr_insert, MDB2_AUTOQUERY_INSERT); + + $package_id = $db->lastInsertID(); + + // New changelog entry + $arr_insert = array( + 'package' => $package_id, + 'changelog' => $ch->changelog, + 'mtime' => $ch->mtime, + 'hash' => $ch->hash, + 'filesize' => $ch->filesize, + ); + + $db->autoExecute('package_changelog', $arr_insert, MDB2_AUTOQUERY_INSERT); + + // New Manifest entry + $arr_insert = array( + 'package' => $package_id, + 'manifest' => $ma->manifest, + 'mtime' => $ma->mtime, + 'hash' => $ma->hash, + 'filesize' => $ma->filesize, + ); + + $db->autoExecute('package_manifest', $arr_insert, MDB2_AUTOQUERY_INSERT); + + // Import package files + $arr = $ma->getDistfiles(); + + foreach($arr as $filename) { + + $arr_insert = array( + 'package' => $package_id, + 'filename' => $filename, + 'type' => 'DIST', + 'hash' => $ma->getHash($filename), + 'filesize' => $ma->getFilesize($filename), + ); + + $db->autoExecute('package_files', $arr_insert, MDB2_AUTOQUERY_INSERT); + + } + + // Import patches + $arr = $ma->getFiles(); + + foreach($arr as $filename) { + + $arr_insert = array( + 'package' => $package_id, + 'filename' => $filename, + 'type' => 'AUX', + 'hash' => $ma->getHash($filename), + 'filesize' => $ma->getFilesize($filename), + ); + + $db->autoExecute('package_files', $arr_insert, MDB2_AUTOQUERY_INSERT); + + } + } } } - unset($c); + unset($c, $p, $ch, $ma); foreach($arr_update as $category_name => $arr_packages) { @@ -162,13 +224,13 @@ $db_package->status = 1; } - if($p->changelog_mtime != $db_package->changelog_mtime) { - $db_package->changelog_mtime = $p->changelog_mtime; - $db_package->changelog = $p->changelog; - } - - if($p->metadata_mtime != $db_package->metadata_mtime) - $db_package->metadata_mtime = $p->metadata_mtime; +// if($p->changelog_mtime != $db_package->changelog_mtime) { +// $db_package->changelog_mtime = $p->changelog_mtime; +// $db_package->changelog = $p->changelog; +// } +// +// if($p->metadata_mtime != $db_package->metadata_mtime) +// $db_package->metadata_mtime = $p->metadata_mtime; } } |