summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c3e4b97)
raw | patch | inline | side by side (parent: c3e4b97)
author | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 22 Oct 2008 12:01:28 +0000 (12:01 +0000) | ||
committer | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 22 Oct 2008 12:01:28 +0000 (12:01 +0000) |
References #427
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12753 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12753 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server | patch | blob | history |
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index e4cc7185d2acf13542037bef68bc74183abc1a7c..ab73f33b93ff974cc48d09a9d25772df61be88d5 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
close (CONFIG);
-
if(keys(%repo_dirs)) {
find(\&cleanup_and_extract, keys( %repo_dirs ));
&main::strip_packages_list_statements();
# This function should do some intensive task to minimize the db-traffic
sub strip_packages_list_statements {
- my @existing_entries= @{$packages_list_db->exec_statement("SELECT * FROM $main::packages_list_tn")};
+ my @existing_entries= @{$packages_list_db->exec_statement("SELECT * FROM $main::packages_list_tn")};
my @new_statement_list=();
my $hash;
my $insert_hash;
my $update_hash;
my $delete_hash;
+ my $known_packages_hash;
my $local_timestamp=get_time();
foreach my $existing_entry (@existing_entries) {
(! (@{$hash->{$distribution}->{$package}->{$version}}[4] eq $description))
) {
@{$update_hash->{$distribution}->{$package}->{$version}} = ($distribution,$package,$version,$section,$description,undef);
+ } else {
+ # package is already present in database. cache this knowledge for later use
+ @{$known_packages_hash->{$distribution}->{$package}->{$version}} = ($distribution,$package,$version,$section,$description,$template);
}
} else {
# Insert a non-existing entry to db
}
}
- # TODO: Check for orphaned entries
+ # Check for orphaned entries
+ foreach my $existing_entry (@existing_entries) {
+ my $distribution= @{$existing_entry}[0];
+ my $package= @{$existing_entry}[1];
+ my $version= @{$existing_entry}[2];
+ my $section= @{$existing_entry}[3];
+
+ if(
+ exists($insert_hash->{$distribution}->{$package}->{$version}) ||
+ exists($update_hash->{$distribution}->{$package}->{$version}) ||
+ exists($known_packages_hash->{$distribution}->{$package}->{$version})
+ ) {
+ next;
+ } else {
+ # Insert entry to delete hash
+ @{$delete_hash->{$distribution}->{$package}->{$version}} = ($distribution,$package,$version,$section);
+ }
+ }
- # unroll the insert_hash
+ # unroll the insert hash
foreach my $distribution (keys %{$insert_hash}) {
foreach my $package (keys %{$insert_hash->{$distribution}}) {
foreach my $version (keys %{$insert_hash->{$distribution}->{$package}}) {
next;
}
push @new_statement_list,
- "UPDATE $main::packages_list_tn SET $set WHERE"
- ." distribution = '$distribution'"
- ." AND package = '$package'"
- ." AND version = '$version'";
+ "UPDATE $main::packages_list_tn SET $set WHERE"
+ ." distribution = '$distribution'"
+ ." AND package = '$package'"
+ ." AND version = '$version'";
+ }
+ }
+ }
+
+ # unroll the delete hash
+ foreach my $distribution (keys %{$delete_hash}) {
+ foreach my $package (keys %{$delete_hash->{$distribution}}) {
+ foreach my $version (keys %{$delete_hash->{$distribution}->{$package}}) {
+ my $section = @{$delete_hash->{$distribution}->{$package}->{$version}}[3];
+ push @new_statement_list, "DELETE FROM $main::packages_list_tn WHERE distribution='$distribution' AND package='$package' AND version='$version' AND section='$section'";
}
}
}
if( -f "$dir/DEBIAN/templates" ) {
- daemon_log("DEBUG: Found debconf templates in '$package' - $newver", 7);
+ daemon_log("0 DEBUG: Found debconf templates in '$package' - $newver", 7);
my $tmpl= ""; {
local $/=undef;