summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7508a9c)
raw | patch | inline | side by side (parent: 7508a9c)
author | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 14 Mar 2008 18:06:05 +0000 (18:06 +0000) | ||
committer | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 14 Mar 2008 18:06:05 +0000 (18:06 +0000) |
Templates get extracted.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9878 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9878 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server | patch | blob | history | |
gosa-si/modules/GosaPackages.pm | patch | blob | history | |
gosa-si/modules/SIPackages.pm | patch | blob | history |
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 2d13fb1c5376fb9f0c763db2d8fe2d0cf712297d..aa3f9c65396857afde8c00c17e04f2c4c3f1bf3d 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
use Cwd;
use File::Spec;
use File::Basename;
+use File::Find;
+use File::Copy;
use File::Path;
use GOSA::DBsqlite;
use GOSA::GosaSupportDaemon;
my (%cfg_defaults, $foreground, $verbose, $ping_timeout);
my ($bus_activ, $bus, $msg_to_bus, $bus_cipher);
-my ($server, $server_mac_address);
+my ($server);
my ($gosa_server, $job_queue_timeout, $job_queue_loop_delay);
my ($known_modules);
my ($pid_file, $procid, $pid, $log_file);
my ($xml);
my $sources_list;
my $max_clients;
+my %repo_files=();
+my $repo_path;
+my %repo_dirs=();
# variables declared in config file are always set to 'our'
our (%cfg_defaults, $log_file, $pid_file,
$server_ip, $server_port, $SIPackages_key,
# additional variable which should be globaly accessable
our $server_address;
+our $server_mac_address;
our $bus_address;
our $gosa_address;
our $no_bus;
"packages-list" => [\$packages_list_file_name, '/var/lib/gosa-si/packages.db'],
"messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'],
"source-list" => [\$sources_list, '/etc/apt/sources.list'],
+ "repo-path" => [\$repo_path, '/srv/www/repository'],
"ldap-uri" => [\$ldap_uri, ""],
"ldap-base" => [\$ldap_base, ""],
"ldap-admin-dn" => [\$ldap_admin_dn, ""],
sub _start {
my ($kernel) = $_[KERNEL];
&trigger_db_loop($kernel);
- #$kernel->yield('create_fai_server_db', $fai_server_tn );
+ $kernel->yield('create_fai_server_db', $fai_server_tn );
#$kernel->yield('create_fai_release_db', $fai_release_tn );
}
sub refresh_ldap_handle {
my $mesg;
+ daemon_log("DEBUG: Trying to create a connection to URI $ldap_uri", 5);
# Get an ldap handle, if we don't have one
if( ! defined $ldap_handle ){
$ldap_handle = Net::LDAP->new( $ldap_uri );
my $fh;
open($fh, ">$result") or return undef;
- if(defined($ldap_server_dn) && length($ldap_server_dn)>0) {
+ if(defined($ldap_server_dn) and length($ldap_server_dn) > 0) {
my $mesg=$ldap_handle->search(
- base => $ldap_server_dn,
- scope => 'base',
- attrs => 'FAIrepository',
- );
-
+ base => $ldap_server_dn,
+ scope => 'base',
+ attrs => 'FAIrepository',
+ filter => 'objectClass=FAIrepositoryServer'
+ );
if($mesg->count) {
foreach my $entry(@{$mesg->{'entries'}}) {
my ($server, $tag, $release, $sections)= split /\|/, $entry->get_value('FAIrepository');
daemon_log("INFO: create_packages_list_db: finished", 5);
return;
}
+
sub run_create_packages_list_db {
my ($session, $heap) = @_[SESSION, HEAP];
my $task = POE::Wheel::Run->new(
);
$heap->{task}->{ $task->ID } = $task;
}
+
sub parse_package_info {
my ($baseurl, $dist, $section)= @_;
my ($package);
my ($path) = ($baseurl =~ m%://[^/]*(.*)$%);
+ $repo_dirs{ "${repo_path}/pool" } = 1;
foreach $package ("Packages.gz"){
daemon_log("DEBUG: create_packages_list: fetch $baseurl, $dist, $section", 7);
get_package( "$baseurl/dists/$dist/$section/binary-$arch/$package", "$outdir/$dist/$section" );
parse_package( "$outdir/$dist/$section", $dist, $path );
}
+ find(\&cleanup_and_extract, keys( %repo_dirs ) );
}
+
sub get_package {
my ($url, $dest)= @_;
}
return 0;
}
+
sub parse_package {
- my ($path, $dist, $srv_path )= @_;
+ my ($path, $dist, $srv_path)= @_;
my ($package, $version, $section, $description);
my @sql_list;
my $PACKAGES;
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 );
$packages_list_db->exec_statementlist(\@sql_list);
}
-#
-#sub store_fileinfo {
-# my( $package, $file, $dist, $path, $vers ) = @_;
-#
-# my %fileinfo = (
-# 'package' => $package,
-# 'dist' => $dist,
-# 'version' => $vers
-# );
-#
-# $repo_files{ "${srvdir}${path}/$file" } = \%fileinfo;
-#}
+sub store_fileinfo {
+ my( $package, $file, $dist, $path, $vers, $srvdir) = @_;
+
+ my %fileinfo = (
+ 'package' => $package,
+ 'dist' => $dist,
+ 'version' => $vers,
+ );
+
+ $repo_files{ "${srvdir}/$file" } = \%fileinfo;
+}
+
+sub cleanup_and_extract {
+
+ my %templates = ();
+ my $fileinfo = $repo_files{ $File::Find::name };
+
+ if( defined $fileinfo ) {
+
+ my $dir = "$outdir/$fileinfo->{ 'dist' }/debconf.d";
+ system( "mkdir -p '$dir'" );
+
+ system( "dpkg -e '$File::Find::name' '$dir/DEBIAN'" );
+ if( -f "$dir/DEBIAN/templates" ) {
+ my $package = $fileinfo->{ 'package' };
+ my $newver = $fileinfo->{ 'version' };
+
+ daemon_log("DEBUG: Found debconf templates in '$package' - $newver", 5);
+ if( exists $templates{ "$fileinfo->{ 'dist' }/$package" } ) {
+ my $oldver = $templates{ "$fileinfo->{ 'dist' }/$package" };
+ my $ret = system( "dpkg --compare-versions '$oldver' gt '$newver'" );
+ if( ! $ret ) {
+ daemon_log("DEBUG: duplicated '$package' ($newver) in $fileinfo->{ 'dist' } - keeping tmpl v'$oldver'", 5);
+ return;
+ }
+ else {
+ daemon_log("DEBUG: duplicated '$package' ($newver) in $fileinfo->{ 'dist' } - overwriting tmpl v'$oldver'", 5);
+ }
+ }
+ $templates{ "$fileinfo->{ 'dist' }/$package" } = $newver;
+ move( "$dir/DEBIAN/templates", "$dir/$package.templates" );
+ }
+ }
+}
#==== MAIN = main ==============================================================
index 7b23346ab8620a4854b83ef9297a3ba32164d147..1e6ad1457ceabc55503ecbf3054c9dc049a91681 100644 (file)
BEGIN{}
END{}
-my ($server_ip, $server_mac_address, $server_port, $server_passwd, $max_clients);
+my ($server_ip, $server_port, $server_passwd, $max_clients);
my ($gosa_ip, $gosa_mac_address, $gosa_port, $gosa_passwd, $network_interface);
my ($job_queue_timeout, $job_queue_file_name);
index 0169c1c4deb1ca6652b5f73a351bcac661dae560..83245316007fec667035780972e76137acc6c2f2 100644 (file)
BEGIN{}
END {}
-my ($server_ip, $server_mac_address, $server_port, $SIPackages_key, $max_clients, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $server_interface);
+my ($server_ip, $server_port, $SIPackages_key, $max_clients, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $server_interface);
my ($bus_activ, $bus_key, $bus_ip, $bus_port);
my $server;
my $event_hash;
},
"server" => {
"ip" => [\$server_ip, "0.0.0.0"],
- "mac-address" => [\$server_mac_address, "00:00:00:00:00"],
+ "mac-address" => [\$main::server_mac_address, "00:00:00:00:00"],
"port" => [\$server_port, "20081"],
"ldap-uri" => [\$ldap_uri, ""],
"ldap-base" => [\$ldap_base, ""],
# if server_ip is not an ip address but a name
if( inet_aton($server_ip) ){ $server_ip = inet_ntoa(inet_aton($server_ip)); }
$network_interface= &get_interface_for_ip($server_ip);
-$server_mac_address= &get_mac($network_interface);
+$main::server_mac_address= &get_mac($network_interface);
&import_events();
# Unit tag can be defined in config
if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) {
# Read gosaUnitTag from LDAP
- &main::refresh_ldap_handle();
+ &main::refresh_ldap_handle();
if( defined($main::ldap_handle) ) {
- &main::daemon_log("INFO: Searching for servers gosaUnitTag with mac address $server_mac_address",5);
+ &main::daemon_log("INFO: Searching for servers gosaUnitTag with mac address $main::server_mac_address",5);
# Perform search for Unit Tag
$mesg = $main::ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
- filter => "(macaddress=$server_mac_address)"
+ filter => "(macaddress=$main::server_mac_address)"
);
if ($mesg->count == 1) {
my $entry= $mesg->entry(0);
my $unit_tag= $entry->get_value("gosaUnitTag");
+ $main::ldap_server_dn= $mesg->entry(0)->dn;
if(defined($unit_tag) && length($unit_tag) > 0) {
&main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5);
$main::gosa_unit_tag= $unit_tag;
if ($mesg->count == 1) {
my $entry= $mesg->entry(0);
my $unit_tag= $entry->get_value("gosaUnitTag");
+ $main::ldap_server_dn= $mesg->entry(0)->dn;
if(defined($unit_tag) && length($unit_tag) > 0) {
&main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5);
$main::gosa_unit_tag= $unit_tag;
if ($mesg->count == 1) {
my $entry= $mesg->entry(0);
my $unit_tag= $entry->get_value("gosaUnitTag");
+ $main::ldap_server_dn= $mesg->entry(0)->dn;
if(defined($unit_tag) && length($unit_tag) > 0) {
&main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5);
$main::gosa_unit_tag= $unit_tag;
my $SIOCGIFHWADDR= 0x8927; # man 2 ioctl_list
# A configured MAC Address should always override a guessed value
- if ($server_mac_address and length($server_mac_address) > 0) {
- $result= $server_mac_address;
+ if ($main::server_mac_address and length($main::server_mac_address) > 0) {
+ $result= $main::server_mac_address;
}
socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')