diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 4ce75e95791d3b7d15d4053d72dd0003cb262506..872d8dd742cbd0446321fd9cffdee0617f358c5d 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
$bus_activ = "true";
$no_arp = 0;
my $packages_list_under_construction = 0;
$bus_activ = "true";
$no_arp = 0;
my $packages_list_under_construction = 0;
+my $watch_for_new_jobs_in_progress = 0;
our $prg= basename($0);
our $prg= basename($0);
our $job_db;
our $job_queue_tn = 'jobs';
my $job_queue_file_name;
our $job_db;
our $job_queue_tn = 'jobs';
my $job_queue_file_name;
-my @job_queue_col_names = ("id INTEGER",
- "timestamp",
+my @job_queue_col_names = ("id INTEGER PRIMARY KEY",
+ "timestamp DEFAULT 'none'",
"status DEFAULT 'none'",
"result DEFAULT 'none'",
"progress DEFAULT 'none'",
"status DEFAULT 'none'",
"result DEFAULT 'none'",
"progress DEFAULT 'none'",
- "headertag DEFAULT 'none'",
+ "headertag DEFAULT 'none'",
"targettag DEFAULT 'none'",
"xmlmessage DEFAULT 'none'",
"macaddress DEFAULT 'none'",
"targettag DEFAULT 'none'",
"xmlmessage DEFAULT 'none'",
"macaddress DEFAULT 'none'",
our $known_server_db;
our $known_server_tn = "known_server";
my $known_server_file_name;
our $known_server_db;
our $known_server_tn = "known_server";
my $known_server_file_name;
-my @known_server_col_names = ('hostname', 'status', 'hostkey', 'timestamp');
+my @known_server_col_names = ("hostname", "status", "hostkey", "timestamp");
# holds all registrated clients
our $known_clients_db;
our $known_clients_tn = "known_clients";
my $known_clients_file_name;
# holds all registrated clients
our $known_clients_db;
our $known_clients_tn = "known_clients";
my $known_clients_file_name;
-my @known_clients_col_names = ('hostname', 'status', 'hostkey', 'timestamp', 'macaddress', 'events');
+my @known_clients_col_names = ("hostname", "status", "hostkey", "timestamp", "macaddress", "events");
# holds all logged in user at each client
our $login_users_db;
our $login_users_tn = "login_users";
my $login_users_file_name;
# holds all logged in user at each client
our $login_users_db;
our $login_users_tn = "login_users";
my $login_users_file_name;
-my @login_users_col_names = ('client', 'user', 'timestamp');
+my @login_users_col_names = ("client", "user", "timestamp");
# holds all fai server, the debian release and tag
our $fai_server_db;
our $fai_server_tn = "fai_server";
my $fai_server_file_name;
# holds all fai server, the debian release and tag
our $fai_server_db;
our $fai_server_tn = "fai_server";
my $fai_server_file_name;
-our @fai_server_col_names = ('timestamp', 'server', 'release', 'sections', 'tag');
+our @fai_server_col_names = ("timestamp", "server", "release", "sections", "tag");
our $fai_release_db;
our $fai_release_tn = "fai_release";
my $fai_release_file_name;
our $fai_release_db;
our $fai_release_tn = "fai_release";
my $fai_release_file_name;
-our @fai_release_col_names = ('timestamp', 'release', 'class', 'type', 'state');
+our @fai_release_col_names = ("timestamp", "release", "class", "type", "state");
# holds all packages available from different repositories
our $packages_list_db;
our $packages_list_tn = "packages_list";
my $packages_list_file_name;
# holds all packages available from different repositories
our $packages_list_db;
our $packages_list_tn = "packages_list";
my $packages_list_file_name;
-our @packages_list_col_names = ('distribution', 'package', 'version', 'section', 'description', 'template', 'timestamp');
+our @packages_list_col_names = ("distribution", "package", "version", "section", "description", "template", "timestamp");
my $outdir = "/tmp/packages_list_db";
my $arch = "i386";
# holds all messages which should be delivered to a user
our $messaging_db;
our $messaging_tn = "messaging";
my $outdir = "/tmp/packages_list_db";
my $arch = "i386";
# holds all messages which should be delivered to a user
our $messaging_db;
our $messaging_tn = "messaging";
-our @messaging_col_names = ('subject', 'message_from', 'message_to', 'flag', 'direction', 'delivery_time', 'message', 'timestamp', 'id INTEGER' );
+our @messaging_col_names = ("id INTEGER", "subject", "message_from", "message_to",
+ "flag", "direction", "delivery_time", "message", "timestamp" );
my $messaging_file_name;
# path to directory to store client install log files
my $messaging_file_name;
# path to directory to store client install log files
if ( 0 < @{$answer_l} ) {
my $answer_str = join("\n", @{$answer_l});
daemon_log("$session_id DEBUG: $module: Got answer from module: \n".$answer_str,8);
if ( 0 < @{$answer_l} ) {
my $answer_str = join("\n", @{$answer_l});
daemon_log("$session_id DEBUG: $module: Got answer from module: \n".$answer_str,8);
+ } else {
+ daemon_log("$session_id DEBUG: $module: Got no answer from module!" ,8);
}
}
+
}
if( !$answer_l ) { $error++ };
}
if( !$answer_l ) { $error++ };
}
sub watch_for_new_jobs {
}
sub watch_for_new_jobs {
- my ($kernel,$heap) = @_[KERNEL, HEAP];
-
- # check gosa job queue for jobs with executable timestamp
- my $timestamp = &get_time();
- my $sql_statement = "SELECT * FROM $job_queue_tn WHERE status='waiting' AND (CAST (timestamp AS INTEGER)) < $timestamp ORDER BY timestamp";
- my $res = $job_db->exec_statement( $sql_statement );
-
- # Merge all new jobs that would do the same actions
- my @drops;
- my $hits;
- foreach my $hit (reverse @{$res} ) {
- my $macaddress= lc @{$hit}[8];
- my $headertag= @{$hit}[5];
- if(defined($hits->{$macaddress}->{$headertag})) {
- push @drops, "DELETE FROM $job_queue_tn WHERE id = '$hits->{$macaddress}->{$headertag}[0]'";
+ if($watch_for_new_jobs_in_progress == 0) {
+ $watch_for_new_jobs_in_progress = 1;
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
+
+ # check gosa job queue for jobs with executable timestamp
+ my $timestamp = &get_time();
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE status='waiting' AND (CAST (timestamp AS INTEGER)) < $timestamp ORDER BY timestamp";
+ my $res = $job_db->exec_statement( $sql_statement );
+
+ # Merge all new jobs that would do the same actions
+ my @drops;
+ my $hits;
+ foreach my $hit (reverse @{$res} ) {
+ my $macaddress= lc @{$hit}[8];
+ my $headertag= @{$hit}[5];
+ if(
+ defined($hits->{$macaddress}) &&
+ defined($hits->{$macaddress}->{$headertag}) &&
+ defined($hits->{$macaddress}->{$headertag}[0])
+ ) {
+ push @drops, "DELETE FROM $job_queue_tn WHERE id = '$hits->{$macaddress}->{$headertag}[0]'";
+ }
+ $hits->{$macaddress}->{$headertag}= $hit;
}
}
- $hits->{$macaddress}->{$headertag}= $hit;
- }
- # Delete new jobs with a matching job in state 'processing'
- foreach my $macaddress (keys %{$hits}) {
- foreach my $jobdb_headertag (keys %{$hits->{$macaddress}}) {
- my $jobdb_id = @{$hits->{$macaddress}->{$jobdb_headertag}}[0];
- my $sql_statement = "SELECT * FROM $job_queue_tn WHERE macaddress LIKE '$macaddress' AND headertag='$jobdb_headertag' AND status='processing'";
- my $res = $job_db->exec_statement( $sql_statement );
- foreach my $hit (@{$res}) {
- push @drops, "DELETE FROM $job_queue_tn WHERE id = '$jobdb_id'";
+ # Delete new jobs with a matching job in state 'processing'
+ foreach my $macaddress (keys %{$hits}) {
+ foreach my $jobdb_headertag (keys %{$hits->{$macaddress}}) {
+ my $jobdb_id = @{$hits->{$macaddress}->{$jobdb_headertag}}[0];
+ if(defined($jobdb_id)) {
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE macaddress LIKE '$macaddress' AND headertag='$jobdb_headertag' AND status='processing'";
+ my $res = $job_db->exec_statement( $sql_statement );
+ foreach my $hit (@{$res}) {
+ push @drops, "DELETE FROM $job_queue_tn WHERE id = '$jobdb_id'";
+ }
+ } else {
+ daemon_log("J ERROR: Job without id exists for macaddress $macaddress!", 1);
+ }
}
}
}
}
- }
- # Commit deletion
- $job_db->exec_statementlist(\@drops);
+ # Commit deletion
+ $job_db->exec_statementlist(\@drops);
- # Look for new jobs that could be executed
- foreach my $macaddress (keys %{$hits}) {
+ # Look for new jobs that could be executed
+ foreach my $macaddress (keys %{$hits}) {
- # Look if there is an executing job
- my $sql_statement = "SELECT * FROM $job_queue_tn WHERE macaddress LIKE '$macaddress' AND status='processing'";
- my $res = $job_db->exec_statement( $sql_statement );
+ # Look if there is an executing job
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE macaddress LIKE '$macaddress' AND status='processing'";
+ my $res = $job_db->exec_statement( $sql_statement );
- # Skip new jobs for host if there is a processing job
- if(defined($res) and defined @{$res}[0]) {
- next;
- }
+ # Skip new jobs for host if there is a processing job
+ if(defined($res) and defined @{$res}[0]) {
+ next;
+ }
- foreach my $jobdb_headertag (keys %{$hits->{$macaddress}}) {
- my $jobdb_id = @{$hits->{$macaddress}->{$jobdb_headertag}}[0];
- my $job_msg = @{$hits->{$macaddress}->{$jobdb_headertag}}[7];
+ foreach my $jobdb_headertag (keys %{$hits->{$macaddress}}) {
+ my $jobdb_id = @{$hits->{$macaddress}->{$jobdb_headertag}}[0];
+ if(defined($jobdb_id)) {
+ my $job_msg = @{$hits->{$macaddress}->{$jobdb_headertag}}[7];
- daemon_log("J DEBUG: its time to execute $job_msg", 7);
- my $sql_statement = "SELECT * FROM known_clients WHERE macaddress LIKE '$macaddress'";
- my $res_hash = $known_clients_db->select_dbentry( $sql_statement );
+ daemon_log("J DEBUG: its time to execute $job_msg", 7);
+ my $sql_statement = "SELECT * FROM known_clients WHERE macaddress LIKE '$macaddress'";
+ my $res_hash = $known_clients_db->select_dbentry( $sql_statement );
- # expect macaddress is unique!!!!!!
- my $target = $res_hash->{1}->{hostname};
+ # expect macaddress is unique!!!!!!
+ my $target = $res_hash->{1}->{hostname};
- # change header
- $job_msg =~ s/<header>job_/<header>gosa_/;
+ # change header
+ $job_msg =~ s/<header>job_/<header>gosa_/;
- # add sqlite_id
- $job_msg =~ s/<\/xml>$/<jobdb_id>$jobdb_id<\/jobdb_id><\/xml>/;
+ # add sqlite_id
+ $job_msg =~ s/<\/xml>$/<jobdb_id>$jobdb_id<\/jobdb_id><\/xml>/;
- $job_msg =~ /<header>(\S+)<\/header>/;
- my $header = $1 ;
- my $func_error = &send_msg_to_target($job_msg, $server_address, $GosaPackages_key, $header, "J");
+ $job_msg =~ /<header>(\S+)<\/header>/;
+ my $header = $1 ;
+ my $func_error = &send_msg_to_target($job_msg, $server_address, $GosaPackages_key, $header, "J");
- # update status in job queue to 'processing'
- $sql_statement = "UPDATE $job_queue_tn SET status='processing' WHERE id='$jobdb_id'";
- my $res = $job_db->update_dbentry($sql_statement);
+ # update status in job queue to 'processing'
+ $sql_statement = "UPDATE $job_queue_tn SET status='processing' WHERE id='$jobdb_id'";
+ my $res = $job_db->update_dbentry($sql_statement);
- # We don't want parallel processing
- last;
+ # We don't want parallel processing
+ last;
+ }
+ }
}
}
- }
- $kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
+ $watch_for_new_jobs_in_progress = 0;
+ $kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
+ }
}
}
my $timestamp = &get_time();
my $sql_statement = "SELECT * FROM $messaging_tn WHERE ( (CAST(timestamp AS INTEGER))<$timestamp AND flag='n' AND direction='in' )";
my $res = $messaging_db->exec_statement( $sql_statement );
my $timestamp = &get_time();
my $sql_statement = "SELECT * FROM $messaging_tn WHERE ( (CAST(timestamp AS INTEGER))<$timestamp AND flag='n' AND direction='in' )";
my $res = $messaging_db->exec_statement( $sql_statement );
-
foreach my $hit (@{$res}) {
# create outgoing messages
foreach my $hit (@{$res}) {
# create outgoing messages
- my $message_to = @{$hit}[2];
+ my $message_to = @{$hit}[3];
# translate message_to to plain login name
# translate message_to to plain login name
+# TODO implement reciever translation
my @reciever_l = ($message_to);
my @reciever_l = ($message_to);
- my $message_id = @{$hit}[8];
+ my $message_id = @{$hit}[0];
#add each outgoing msg to messaging_db
my $reciever;
foreach $reciever (@reciever_l) {
#add each outgoing msg to messaging_db
my $reciever;
foreach $reciever (@reciever_l) {
- my $sql_statement = "INSERT INTO $messaging_tn (subject, message_from, message_to, flag, direction, delivery_time, message, timestamp, id) ".
+ my $sql_statement = "INSERT INTO $messaging_tn (id, subject, message_from, message_to, flag, direction, delivery_time, message, timestamp) ".
"VALUES ('".
"VALUES ('".
- @{$hit}[0]."', '". # subject
- @{$hit}[1]."', '". # message_from
- $reciever."', '". # message_to
- "none"."', '". # flag
- "out"."', '". # direction
- @{$hit}[5]."', '". # delivery_time
- @{$hit}[6]."', '". # message
- $timestamp."', '". # timestamp
- @{$hit}[8]. # id
- "')";
+ $message_id."', '". # id
+ @{$hit}[1]."', '". # subject
+ @{$hit}[2]."', '". # message_from
+ $reciever."', '". # message_to
+ "none"."', '". # flag
+ "out"."', '". # direction
+ @{$hit}[6]."', '". # delivery_time
+ @{$hit}[7]."', '". # message
+ $timestamp."'". # timestamp
+ ")";
&daemon_log("M DEBUG: $sql_statement", 1);
my $res = $messaging_db->exec_statement($sql_statement);
&daemon_log("M DEBUG: $sql_statement", 1);
my $res = $messaging_db->exec_statement($sql_statement);
- &daemon_log("M INFO: message '".@{$hit}[8]."' is prepared for delivery to reciever '$reciever'", 5);
+ &daemon_log("M INFO: message '".@{$hit}[0]."' is prepared for delivery to reciever '$reciever'", 5);
}
# send outgoing messages
}
# send outgoing messages
my $res = $messaging_db->exec_statement( $sql_statement );
foreach my $hit (@{$res}) {
# add subject, from, to and message to list coll_user_msg
my $res = $messaging_db->exec_statement( $sql_statement );
foreach my $hit (@{$res}) {
# add subject, from, to and message to list coll_user_msg
- my @user_msg = [@{$hit}[0], @{$hit}[1], $reciever, @{$hit}[6]];
+ my @user_msg = [@{$hit}[1], @{$hit}[2], $reciever, @{$hit}[7]];
push( @coll_user_msg, \@user_msg);
}
push( @coll_user_msg, \@user_msg);
}
$sql_statement = "UPDATE $messaging_tn SET flag='p' WHERE id='$message_id'";
&daemon_log("M DEBUG: $sql_statement", 7);
$res = $messaging_db->update_dbentry($sql_statement);
$sql_statement = "UPDATE $messaging_tn SET flag='p' WHERE id='$message_id'";
&daemon_log("M DEBUG: $sql_statement", 7);
$res = $messaging_db->update_dbentry($sql_statement);
- &daemon_log("M INFO: message '".@{$hit}[8]."' is set to flag 'p' (processed)", 5);
+ &daemon_log("M INFO: message '$message_id' is set to flag 'p' (processed)", 5);
}
}
daemon_log("$session_id DEBUG: Inserting ".scalar @sql_list." entries to DB",8);
if(@sql_list) {
daemon_log("$session_id DEBUG: Inserting ".scalar @sql_list." entries to DB",8);
if(@sql_list) {
- unshift @sql_list, "DELETE FROM $table_name";
+ unshift @sql_list, "DELETE FROM $table_name"; # at first, clear db
$fai_release_db->exec_statementlist(\@sql_list);
}
$fai_release_db->exec_statementlist(\@sql_list);
}
- daemon_log("$session_id DEBUG: Done with inserting",6);
+ daemon_log("$session_id DEBUG: Done with inserting",7);
}
daemon_log("$session_id INFO: create_fai_release_db: finished",5);
}
}
daemon_log("$session_id INFO: create_fai_release_db: finished",5);
}
my $fai_filter= "(|(&(objectClass=FAIclass)(|(objectClass=".join(")(objectClass=", @possible_fai_classes).")))(objectClass=FAIbranch))";
my $fai_classes;
my $fai_filter= "(|(&(objectClass=FAIclass)(|(objectClass=".join(")(objectClass=", @possible_fai_classes).")))(objectClass=FAIbranch))";
my $fai_classes;
- daemon_log("$session_id DEBUG: Searching for FAI entries in base $fai_base",6);
+ daemon_log("$session_id DEBUG: Searching for FAI entries in base $fai_base",7);
my $mesg= $ldap_handle->search(
base => $fai_base,
scope => 'sub',
attrs => ['cn','objectClass','FAIstate'],
filter => $fai_filter,
);
my $mesg= $ldap_handle->search(
base => $fai_base,
scope => 'sub',
attrs => ['cn','objectClass','FAIstate'],
filter => $fai_filter,
);
- daemon_log("$session_id DEBUG: Found ".$mesg->count()." FAI entries",6);
+ daemon_log("$session_id DEBUG: Found ".$mesg->count()." FAI entries",7);
if($mesg->{'resultCode'} == 0 &&
$mesg->count != 0) {
if($mesg->{'resultCode'} == 0 &&
$mesg->count != 0) {
}
sub create_sources_list {
}
sub create_sources_list {
+ my ($session_id) = @_;
my $ldap_handle = &get_ldap_handle;
my $result="/tmp/gosa_si_tmp_sources_list";
# Remove old file
if(stat($result)) {
unlink($result);
my $ldap_handle = &get_ldap_handle;
my $result="/tmp/gosa_si_tmp_sources_list";
# Remove old file
if(stat($result)) {
unlink($result);
+ &main::daemon_log("$session_id DEBUG: remove an old version of '$result'", 7);
}
my $fh;
}
my $fh;
- open($fh, ">$result") or return undef;
+ open($fh, ">$result");
+ if (not defined $fh) {
+ &main::daemon_log("$session_id DEBUG: cannot open '$result' for writing", 7);
+ return undef;
+ }
if(defined($ldap_server_dn) and length($ldap_server_dn) > 0) {
my $mesg=$ldap_handle->search(
base => $ldap_server_dn,
if(defined($ldap_server_dn) and length($ldap_server_dn) > 0) {
my $mesg=$ldap_handle->search(
base => $ldap_server_dn,
}
}
}
}
}
}
- }
+ } else {
+ &main::daemon_log("$session_id ERROR: something wrong with ldap_server_dn '$ldap_server_dn', abort create_sources_list", 1);
+ }
close($fh);
return $result;
close($fh);
return $result;
sub create_packages_list_db {
sub create_packages_list_db {
- my ($ldap_handle, $sources_file, $session_id);
+ my ($ldap_handle, $sources_file, $session_id) = @_;
if (not defined $session_id) { $session_id = 0; }
if (not defined $ldap_handle) {
if (not defined $session_id) { $session_id = 0; }
if (not defined $ldap_handle) {
}
}
if (not defined $sources_file) {
}
}
if (not defined $sources_file) {
- $sources_file = &create_sources_list;
+ &main::daemon_log("$session_id INFO: no sources_file given for creating packages list so trigger creation of it", 5);
+ $sources_file = &create_sources_list($session_id);
+ }
+
+ if (not defined $sources_file) {
+ &main::daemon_log("$session_id ERROR: no sources_file given under '$sources_file', skip create_packages_list_db", 1);
+
}
# it should not be possible to trigger a recreation of packages_list_db
}
# it should not be possible to trigger a recreation of packages_list_db
sub parse_package_info {
sub parse_package_info {
- my ($baseurl, $dist, $section, $session_id)= @_;
- my ($package);
- if (not defined $session_id) { $session_id = 0; }
- my ($path) = ($baseurl =~ m%://[^/]*(.*)$%);
- $repo_dirs{ "${repo_path}/pool" } = 1;
-
- foreach $package ("Packages.gz"){
- daemon_log("$session_id DEBUG: create_packages_list: fetch $baseurl, $dist, $section", 7);
- get_package( "$baseurl/dists/$dist/$section/binary-$arch/$package", "$outdir/$dist/$section", $session_id );
- parse_package( "$outdir/$dist/$section", $dist, $path, $session_id );
- }
- find(\&cleanup_and_extract, keys( %repo_dirs ));
+ my ($baseurl, $dist, $section, $session_id)= @_;
+ my ($package);
+ if (not defined $session_id) { $session_id = 0; }
+ my ($path) = ($baseurl =~ m%://[^/]*(.*)$%);
+ $repo_dirs{ "${repo_path}/pool" } = 1;
+
+ foreach $package ("Packages.gz"){
+ daemon_log("$session_id DEBUG: create_packages_list: fetch $baseurl, $dist, $section", 7);
+ get_package( "$baseurl/dists/$dist/$section/binary-$arch/$package", "$outdir/$dist/$section", $session_id );
+ parse_package( "$outdir/$dist/$section", $dist, $path, $session_id );
+ }
+
+ find(\&cleanup_and_extract, keys( %repo_dirs ));
}
sub get_package {
}
sub get_package {
- my ($url, $dest, $session_id)= @_;
- if (not defined $session_id) { $session_id = 0; }
-
- my $tpath = dirname($dest);
- -d "$tpath" || mkpath "$tpath";
-
- # This is ugly, but I've no time to take a look at "how it works in perl"
- if(0 == system("wget '$url' -O '$dest' 2>/dev/null") ) {
- system("gunzip -cd '$dest' > '$dest.in'");
- daemon_log("$session_id DEBUG: run command: gunzip -cd '$dest' > '$dest.in'", 5);
-# unlink($dest);
- daemon_log("$session_id DEBUG: delete file '$dest'", 5);
- } else {
- daemon_log("$session_id ERROR: create_packages_list_db: get_packages: fetching '$url' failed!", 1);
- }
- return 0;
+ my ($url, $dest, $session_id)= @_;
+ if (not defined $session_id) { $session_id = 0; }
+
+ my $tpath = dirname($dest);
+ -d "$tpath" || mkpath "$tpath";
+
+ # This is ugly, but I've no time to take a look at "how it works in perl"
+ if(0 == system("wget '$url' -O '$dest' 2>/dev/null") ) {
+ system("gunzip -cd '$dest' > '$dest.in'");
+ daemon_log("$session_id DEBUG: run command: gunzip -cd '$dest' > '$dest.in'", 5);
+ unlink($dest);
+ daemon_log("$session_id DEBUG: delete file '$dest'", 5);
+ } else {
+ daemon_log("$session_id ERROR: create_packages_list_db: get_packages: fetching '$url' failed!", 1);
+ }
+ return 0;
}
}
+
sub parse_package {
my ($path, $dist, $srv_path, $session_id)= @_;
sub parse_package {
my ($path, $dist, $srv_path, $session_id)= @_;
- if (not defined $session_id) { $session_id = 0;}
+ if (not defined $session_id) { $session_id = 0;}
my ($package, $version, $section, $description);
my @sql_list;
my $PACKAGES;
my ($package, $version, $section, $description);
my @sql_list;
my $PACKAGES;
+ my $timestamp = &get_time();
if(not stat("$path.in")) {
daemon_log("$session_id ERROR: create_packages_list: parse_package: file '$path.in' is not readable",1);
if(not stat("$path.in")) {
daemon_log("$session_id ERROR: create_packages_list: parse_package: file '$path.in' is not readable",1);
}
open($PACKAGES, "<$path.in");
}
open($PACKAGES, "<$path.in");
- if(not defined($PACKAGES)) {
+ if(not defined($PACKAGES)) {
daemon_log("$session_id ERROR: create_packages_list_db: parse_package: cannot open '$path.in'",1);
return;
}
daemon_log("$session_id ERROR: create_packages_list_db: parse_package: cannot open '$path.in'",1);
return;
}
# Use empty lines as a trigger
if ($line =~ /^\s*$/){
# Use empty lines as a trigger
if ($line =~ /^\s*$/){
- my $sql = "INSERT INTO packages_list VALUES ('$dist', '$package', '$version', '$section', '', 'none', '0')";
+ my $sql = "INSERT INTO packages_list VALUES ('$dist', '$package', '$version', '$section', '', 'none', '$timestamp')";
push(@sql_list, $sql);
$package = "none";
$version = "none";
push(@sql_list, $sql);
$package = "none";
$version = "none";
next;
}
next;
}
- # Trigger for filename
- if ($line =~ /^Filename:\s/){
- my ($filename) = ($line =~ /^Filename: (.*)$/);
- store_fileinfo( $package, $filename, $dist, $srv_path, $version, $repo_path );
- next;
- }
+ # Trigger for filename
+ if ($line =~ /^Filename:\s/){
+ my ($filename) = ($line =~ /^Filename: (.*)$/);
+ store_fileinfo( $package, $filename, $dist, $srv_path, $version, $repo_path );
+ next;
+ }
}
close( $PACKAGES );
}
close( $PACKAGES );
-# unlink( "$path.in" );
-
+ unlink( "$path.in" );
+ &main::daemon_log("$session_id DEBUG: unlink '$path.in'", 1);
+ my $len_sql_list = @sql_list;
+ &main::daemon_log("$session_id DEBUG: add $len_sql_list insert-statements to packages_list_db", 5);
$packages_list_db->exec_statementlist(\@sql_list);
}
$packages_list_db->exec_statementlist(\@sql_list);
}
+
sub store_fileinfo {
sub store_fileinfo {
- my( $package, $file, $dist, $path, $vers, $srvdir) = @_;
+ my( $package, $file, $dist, $path, $vers, $srvdir) = @_;
- my %fileinfo = (
- 'package' => $package,
- 'dist' => $dist,
- 'version' => $vers,
- );
+ my %fileinfo = (
+ 'package' => $package,
+ 'dist' => $dist,
+ 'version' => $vers,
+ );
- $repo_files{ "${srvdir}/$file" } = \%fileinfo;
+ $repo_files{ "${srvdir}/$file" } = \%fileinfo;
}
}
+
sub cleanup_and_extract {
sub cleanup_and_extract {
- my ($session_id) = @_;
- if (not defined $session_id) { $session_id = 0; }
- my $fileinfo = $repo_files{ $File::Find::name };
+ my $fileinfo = $repo_files{ $File::Find::name };
- if( defined $fileinfo ) {
+ if( defined $fileinfo ) {
- my $dir = "$outdir/$fileinfo->{ 'dist' }/debconf.d";
- my $sql;
- my $package = $fileinfo->{ 'package' };
- my $newver = $fileinfo->{ 'version' };
+ my $dir = "$outdir/$fileinfo->{ 'dist' }/debconf.d";
+ my $sql;
+ my $package = $fileinfo->{ 'package' };
+ my $newver = $fileinfo->{ 'version' };
- mkpath($dir);
- system( "dpkg -e '$File::Find::name' '$dir/DEBIAN'" );
+ mkpath($dir);
+ system( "dpkg -e '$File::Find::name' '$dir/DEBIAN'" );
- if( -f "$dir/DEBIAN/templates" ) {
+ if( -f "$dir/DEBIAN/templates" ) {
- daemon_log("$session_id DEBUG: Found debconf templates in '$package' - $newver", 5);
+ daemon_log("DEBUG: Found debconf templates in '$package' - $newver", 5);
- my $tmpl= "";
- {
- local $/=undef;
- open FILE, "$dir/DEBIAN/templates";
- $tmpl = &encode_base64(<FILE>);
- close FILE;
- }
- rmtree("$dir/DEBIAN/templates");
+ my $tmpl= "";
+ {
+ local $/=undef;
+ open FILE, "$dir/DEBIAN/templates";
+ $tmpl = &encode_base64(<FILE>);
+ close FILE;
+ }
+ rmtree("$dir/DEBIAN/templates");
- $sql= "update $main::packages_list_tn set template = '$tmpl' where package = '$package' and version = '$newver';";
+ $sql= "update $main::packages_list_tn set template = '$tmpl' where package = '$package' and version = '$newver';";
- } else {
- $sql= "update $main::packages_list_tn set template = '' where package = '$package' and version = '$newver';";
- }
+ } else {
+ $sql= "update $main::packages_list_tn set template = '' where package = '$package' and version = '$newver';";
+ }
- my $res= $main::packages_list_db->update_dbentry($sql);
- }
+ my $res= $main::packages_list_db->update_dbentry($sql);
+ }
+
+ return;
}
}