summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Dibb <beandog@gentoo.org>2010-02-14 18:13:40 +0000
committerSteve Dibb <beandog@gentoo.org>2010-02-14 18:13:40 +0000
commitab8d8a109a94286f9712e135656316a09d41de87 (patch)
tree7d543c7166552574354480d4222ff3ae3c520c34
parentcleanup (diff)
downloadznurt-org-backend-ab8d8a109a94286f9712e135656316a09d41de87.tar.gz
znurt-org-backend-ab8d8a109a94286f9712e135656316a09d41de87.tar.bz2
znurt-org-backend-ab8d8a109a94286f9712e135656316a09d41de87.zip
Import on hash change, not mtime
git-svn-id: file:///var/svn/portage@89 3218660a-b0cf-4799-a991-8ddcc5b9e0f3
-rw-r--r--class.portage.ebuild.php32
-rw-r--r--import.ebuilds.php20
2 files changed, 36 insertions, 16 deletions
diff --git a/class.portage.ebuild.php b/class.portage.ebuild.php
index 3f3bfb5..188263a 100644
--- a/class.portage.ebuild.php
+++ b/class.portage.ebuild.php
@@ -48,6 +48,7 @@
private $dir;
private $filename;
private $filename_cache;
+ private $filesize;
private $source;
private $portage;
private $cache;
@@ -69,7 +70,7 @@
private $cache_mtime;
// hash sums
- private $sha1sum;
+ private $hash;
@@ -175,12 +176,16 @@
return $this->filename;
break;
+ case 'filesize':
+ return $this->getFilesize();
+ break;
+
case 'source':
return $this->source = file_get_contents($this->filename);
break;
- case 'sha1sum':
- return $this->sha1sum = $this->getSha1Sum();
+ case 'hash':
+ return $this->hash = $this->getHash();
break;
}
@@ -455,15 +460,24 @@
}
- function getSha1Sum() {
+ function getHash() {
- require_once 'class.portage.package.manifest.php';
+ if(!$this->hash) {
+ $contents = file_get_contents($this->filename);
+ $this->hash = sha1($contents);
+ }
+
+ return $this->hash;
- $manifest = new PackageManifest($this->manifest_filename);
+ }
+
+ public function getFilesize() {
- $str = $manifest->getFilenameSha1Sum($this->basename);
+ if(!$this->filesize) {
+ $this->filesize = filesize($this->filename);
+ }
- return $str;
+ return $this->filesize;
}
@@ -528,7 +542,7 @@
}
- function getMtime() {
+ public function getMtime() {
if(file_exists($this->filename))
return filemtime($this->filename);
diff --git a/import.ebuilds.php b/import.ebuilds.php
index 9abd8e1..8dcdedd 100644
--- a/import.ebuilds.php
+++ b/import.ebuilds.php
@@ -80,6 +80,12 @@
}
}
+ // If no ebuilds, reset the sequence
+ if($count === "0") {
+ $sql = "ALTER SEQUENCE ebuild_id_seq RESTART WITH 1;";
+ $db->query($sql);
+ }
+
$categories = $tree->getCategories();
$arr_import = array();
@@ -186,7 +192,7 @@
$arr_delete = array_diff($arr_db_ebuilds, $arr_fs_ebuilds);
$arr_insert = array_diff($arr_fs_ebuilds, $arr_db_ebuilds);
- // Next, look at the mtimes and see if any need to be updated
+ // Next, look at the hashes and see if any need to be updated
if(count($arr_fs_ebuilds)) {
foreach($arr_fs_ebuilds as $ebuild_name) {
@@ -198,13 +204,14 @@
if($ebuild) {
$db_ebuild = new DBEbuild($ebuild);
- if(($e->portage_mtime != $db_ebuild->portage_mtime) || ($e->cache_mtime != $db_ebuild->cache_mtime)) {
+ if($db_ebuild->hash != $e->hash) {
$arr_update[] = $ebuild_name;
$arr_insert[] = $ebuild_name;
+
// Normally I'd add this here, but instead, just go ahead and mark it
// right away, and avoid having it run twice.
- $db_ebuild->status = 2;
+ $db_ebuild->status = 2;
if($verbose) {
shell::msg("[update] $category_name/$ebuild_name");
@@ -269,6 +276,8 @@
'status' => 1,
'udate' => $udate,
'source' => $e->source,
+ 'filesize' => $e->filesize,
+ 'hash' => $e->hash,
);
$db->autoExecute('ebuild', $arr, MDB2_AUTOQUERY_INSERT);
@@ -284,10 +293,7 @@
}
- unset($e);
- unset($p);
- unset($db_ebuild);
- unset($db_package);
+ unset($e, $p, $db_ebuild, $db_package, $arr, $arr_insert, $arr_update);
// Update the package_recent entries
$sql = "DELETE FROM package_recent WHERE status = 1;";