Hello community, here is the log from the commit of package suseRegister checked in at Mon Jan 8 18:33:06 CET 2007. -------- --- suseRegister/suseRegister.changes 2006-12-07 12:11:48.000000000 +0100 +++ /mounts/work_src_done/NOARCH/suseRegister/suseRegister.changes 2007-01-08 15:55:10.576969000 +0100 @@ -1,0 +2,11 @@ +Mon Jan 8 15:53:45 CET 2007 - mc@suse.de + +- implement --norug, --nozypper and --batch command + [Feature #301745] +- fix call of rugPreferences +- send mail to root in batchmode when an error happens +- add init script to look for new catalogs during boot. + [Feature #301745, #301822] +- add cronjob to trigger register on boot [Fate #301822] + +------------------------------------------------------------------- New: ---- suseRegister.init suse-trigger-register.cron ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ suseRegister.spec ++++++ --- /var/tmp/diff_new_pack.h29418/_old 2007-01-08 18:32:52.000000000 +0100 +++ /var/tmp/diff_new_pack.h29418/_new 2007-01-08 18:32:52.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package suseRegister (Version 1.2) # -# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. # This file and all modifications and additions to the pristine # package are under the same license as the package itself. # @@ -12,11 +12,13 @@ Name: suseRegister Version: 1.2 -Release: 1 +Release: 7 Summary: Registration Tool Group: Productivity/Other License: GNU General Public License (GPL) Source: %{name}-%{version}.tar.bz2 +Source1: suseRegister.init +Source2: suse-trigger-register.cron BuildRoot: %{_tmppath}/%{name}-%{version}-build Requires: curl Requires: perl-XML-Parser @@ -50,6 +52,17 @@ %install make DESTDIR=$RPM_BUILD_ROOT BINDIR=%{_bindir} SYSCONFIGDIR=%{_sysconfdir} install +%if %{sles_version} > 0 +mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/cron.monthly/ +mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/init.d +install -m 755 $RPM_SOURCE_DIR/suse-trigger-register.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.monthly/suse-trigger-register +install -m 755 $RPM_SOURCE_DIR/suseRegister.init $RPM_BUILD_ROOT/%{_sysconfdir}/init.d/suseRegister +%endif +%if %{sles_version} > 0 + +%post +%{fillup_and_insserv -f -Y suseRegister} +%endif %clean rm -rf $RPM_BUILD_ROOT @@ -63,8 +76,20 @@ %{perl_vendorlib}/SUSE %{_bindir}/* /usr/lib/suseRegister/bin/* +%if %{sles_version} > 0 +%attr(0755, root, root) /%{_sysconfdir}/init.d/suseRegister +%attr(0755, root, root) /%{_sysconfdir}/cron.monthly/suse-trigger-register +%endif %changelog -n suseRegister +* Mon Jan 08 2007 - mc@suse.de +- implement --norug, --nozypper and --batch command + [Feature #301745] +- fix call of rugPreferences +- send mail to root in batchmode when an error happens +- add init script to look for new catalogs during boot. + [Feature #301745, #301822] +- add cronjob to trigger register on boot [Fate #301822] * Thu Dec 07 2006 - mc@suse.de - version 1.2 * Feature #301790: modularize suse-register ++++++ suseRegister-1.2.tar.bz2 ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/suseRegister-1.2/SRPrivate.pm new/suseRegister-1.2/SRPrivate.pm --- old/suseRegister-1.2/SRPrivate.pm 2006-12-07 12:06:08.000000000 +0100 +++ new/suseRegister-1.2/SRPrivate.pm 2007-01-08 14:16:32.000000000 +0100 @@ -24,6 +24,64 @@ my $code = 0; my $msg = ""; + ############### batch mode ######################## + + if($ctx->{batch}) + { + # if --no-optional or --no-hw-data are not given in batch mode + # read the sysconfig values for the default + + my $sysconfigOptional = "false"; + my $sysconfigHWData = "false"; + + + open(CNF, "< $ctx->{sysconfigFile}") or do { + logPrintReturn("cannot open file $ctx->{sysconfigFile}: $!\n", 12); + }; + + while(<CNF>) + { + if($_ =~ /^\s*#/) + { + next; + } + elsif($_ =~ /^SUBMIT_OPTIONAL\s*=\s*"*([^"\s]*)"*\s*/ && defined $1 && $1 ne "") + { + $sysconfigOptional = $1; + + } + elsif($_ =~ /^SUBMIT_HWDATA\s*=\s*"*([^"\s]*)"*\s*/ && defined $1 && $1 ne "") + { + $sysconfigHWData = $1; + } + } + close CNF; + + + if(!$ctx->{nooptional}) + { + if(lc($sysconfigOptional) eq "true") + { + $ctx->{nooptional} = 0; + } + else + { + $ctx->{nooptional} = 1; + } + } + if(!$ctx->{nohwdata}) + { + if(lc($sysconfigHWData) eq "true") + { + $ctx->{nohwdata} = 0; + } + else + { + $ctx->{nohwdata} = 1; + } + } + } + ############### read the config ################### if(-e $ctx->{configFile}) { @@ -477,7 +535,7 @@ defined $kid->{description} && defined $kid->{id}) { - if ( ($ctx->{initnooptional} && $local_mandatory) || !$ctx->{initnooptional}) + if ( ($ctx->{nooptional} && $local_mandatory) || !$ctx->{nooptional}) { if(! exists $kid->{command}) { @@ -519,7 +577,7 @@ } elsif (ref($kid) ne "SR::privacy" && defined $kid->{description}) { - if ( ($ctx->{initnooptional} && $local_mandatory) || !$ctx->{initnooptional}) + if ( ($ctx->{nooptional} && $local_mandatory) || !$ctx->{nooptional}) { print STDERR "Add description\n" if($ctx->{debug} >= 3); push @{$ctx->{registerReadableText}}, $indent.$kid->{description}." $mandstr with:\n"; @@ -701,7 +759,7 @@ { $a{accept} = "optional"; } - if($ctx->{acceptmand}) + if($ctx->{acceptmand} || $ctx->{nooptional}) { $a{accept} = "mandatory"; } @@ -709,6 +767,10 @@ { $a{force} = "registration"; } + if($ctx->{batch}) + { + $a{force} = "batch"; + } $writer->startTag("register", %a); @@ -1243,16 +1305,16 @@ # do zmd configuration directly here # ignore possible errors - rugPreferences("inventory-enabled", "false"); + rugPreferences($ctx, "inventory-enabled", "false"); if($oldService eq "globalzmdoptions") { if(exists $ctx->{tmpZmdConfig}->{globalzmdoptions}->{update_inventory} && defined $ctx->{tmpZmdConfig}->{globalzmdoptions}->{update_inventory} && - !$ctx->{nohwdata} && !$ctx->{initnooptional}) + !$ctx->{nohwdata} && !$ctx->{nooptional}) { # ignore possible errors - rugPreferences("inventory-enabled", + rugPreferences($ctx, "inventory-enabled", $ctx->{tmpZmdConfig}->{globalzmdoptions}->{update_inventory}); } next; @@ -1456,7 +1518,7 @@ $ctx->{args}->{secret}->{value} = "secret"; } my $cmdtxt = "Commandline params: no-optional:$ctx->{nooptional} forceregistration:$ctx->{forcereg} "; - $cmdtxt .= "no-hw-data:$ctx->{nohwdata} "; + $cmdtxt .= "no-hw-data:$ctx->{nohwdata} batch:$ctx->{batch} "; syslog("err", $cmdtxt); syslog("err", "Argument Dump: ".Data::Dumper->Dump([$ctx->{args}])); diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/suseRegister-1.2/suse_register new/suseRegister-1.2/suse_register --- old/suseRegister-1.2/suse_register 2006-12-07 12:06:08.000000000 +0100 +++ new/suseRegister-1.2/suse_register 2007-01-08 14:16:32.000000000 +0100 @@ -28,9 +28,12 @@ my $dumpfilehack = ""; my $dumpxmlfilehack = ""; my $nozypp = 0; +my $norug = 0; +my $nozypper = 0; my $nooptional = 0; my $forcereg = 0; my $nohwdata = 0; +my $batch = 0; my $logfile = undef; my $browser = undef; my $noproxy = 0; @@ -66,7 +69,7 @@ $ctx->{args}->{secret}->{value} = "secret"; } my $cmdtxt = "Commandline params: no-optional:$ctx->{nooptional} forceregistration:$ctx->{forcereg} "; - $cmdtxt .= "no-hw-data:$ctx->{nohwdata} "; + $cmdtxt .= "no-hw-data:$ctx->{nohwdata} batch:$ctx->{batch} "; syslog("err", $cmdtxt); syslog("err", "Argument Dump: ".Data::Dumper->Dump([$ctx->{args}])); @@ -76,12 +79,41 @@ closelog; close $ctx->{LOGDESCR} if(defined $ctx->{LOGDESCR}); - + + + if($batch) + { + mailToRoot($ctx, "Error during registration", $message); + } + print STDERR "total time: ".(tv_interval($ctx->{programStartTime}))."\n" if($ctx->{time}); exit $code; } +sub mailToRoot +{ + my $ctx = shift; + my $subject = shift || undef; + my $message = shift || undef; + + if(!defined $subject || $subject eq ""|| + !defined $message || $message eq "") + { + return; + } + + if($subject =~ /^[a-zA-Z0-9\s._-]+$/) + { + my @cmdArgs = ("-s", "$subject", "root"); + open(MAIL, "|-", "mail", @cmdArgs) or return; + + print MAIL $message; + + close MAIL; + } +} + sub usage { @@ -129,6 +161,9 @@ "dumpfile=s" => \$dumpfilehack, "dumpxmlfile=s" => \$dumpxmlfilehack, "nozypp" => \$nozypp, + "norug" => \$norug, + "nozypper" => \$nozypper, + "batch" => \$batch, "no-optional|n" => \$nooptional, "force-registration|f" => \$forcereg, "no-hw-data" => \$nohwdata, @@ -159,11 +194,14 @@ $data->{dumpfilehack} = $dumpfilehack; $data->{dumpxmlfilehack} = $dumpxmlfilehack; $data->{nozypp} = $nozypp; +$data->{norug} = $norug; +$data->{nozypper} = $nozypper; $data->{nooptional} = $nooptional; $data->{nohwdata} = $nohwdata; $data->{logfile} = $logfile; $data->{locale} = $locale; $data->{forcereg} = $forcereg; +$data->{batch} = $batch; $data->{noproxy} = $noproxy; $data->{yastcall} = $yastcall; $data->{mirrorCount} = $mirrorCount; @@ -173,6 +211,11 @@ $data->{time} = $time; +if($batch) +{ + $interactive = 0; +} + my $ctx = SUSE::SuseRegister::init_ctx($data); if($ctx->{errorcode} != 0) { @@ -233,8 +276,16 @@ } else { - print STDERR join("", @{$ctx->{registerReadableText}})."\n"; - print $ctx->{registerManuallyURL}."\n"; + if($batch) + { + mailToRoot($ctx, "Manual registration required", + join("", @{$ctx->{registerReadableText}})."\n"); + } + else + { + print STDERR join("", @{$ctx->{registerReadableText}})."\n"; + print $ctx->{registerManuallyURL}."\n"; + } exit 1; } } @@ -349,9 +400,6 @@ $ctx->{lastResponse} = ""; $ret = SUSE::SuseRegister::register($ctx); - - print "Third register with return $ret\n"; - } } } @@ -379,11 +427,14 @@ logPrintExit($ctx, $ctx->{errormsg}, $ctx->{errorcode}); } - #SUSE::SuseRegister::currentServices($ctx); - #print Data::Dumper->Dump([$ctx])."\n"; } + else + { + logPrintExit($ctx, $ctx->{errormsg}, $ret); + } + if($ret == 0 && $yastcall) { foreach my $service (keys %{$ctx->{zmdConfig}}) diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/suseRegister-1.2/SuseRegister.pm new/suseRegister-1.2/SuseRegister.pm --- old/suseRegister-1.2/SuseRegister.pm 2006-12-07 12:06:08.000000000 +0100 +++ new/suseRegister-1.2/SuseRegister.pm 2007-01-08 14:16:32.000000000 +0100 @@ -142,6 +142,7 @@ $ctx->{version} = "1.0"; $ctx->{configFile} = "/etc/suseRegister.conf"; + $ctx->{sysconfigFile} = "/etc/sysconfig/suse_register"; $ctx->{GUID_FILE} = "/etc/zmd/deviceid"; $ctx->{SECRET_FILE} = "/etc/zmd/secret"; @@ -162,12 +163,15 @@ $ctx->{listParams} = 0; $ctx->{xmlout} = 0; $ctx->{nozypp} = 0; + $ctx->{norug} = 0; + $ctx->{nozypper} = 0; $ctx->{dumpfilehack} = ""; # FIXME: is this nedded ? $ctx->{dumpxmlfilehack} = ""; # FIXME: is this nedded ? $ctx->{nooptional} = 0; $ctx->{acceptmand} = 0; $ctx->{forcereg} = 0; $ctx->{nohwdata} = 0; + $ctx->{batch} = 0; $ctx->{logfile} = undef; $ctx->{noproxy} = 0; $ctx->{debug} = 0; @@ -213,7 +217,6 @@ $ctx->{createGuid} = "/usr/bin/uuidgen"; - $ctx->{initnooptional} = 0; $ctx->{lastResponse} = ""; $ctx->{initialDomain} = ""; @@ -242,6 +245,16 @@ $ctx->{nozypp} = $data->{nozypp}; } + if(exists $data->{norug} && defined $data->{norug}) + { + $ctx->{norug} = $data->{norug}; + } + + if(exists $data->{nozypper} && defined $data->{nozypper}) + { + $ctx->{nozypper} = $data->{nozypper}; + } + if(exists $data->{dumpfilehack} && defined $data->{dumpfilehack}) { $ctx->{dumpfilehack} = $data->{dumpfilehack}; @@ -267,6 +280,11 @@ $ctx->{nohwdata} = $data->{nohwdata}; } + if(exists $data->{batch} && defined $data->{batch}) + { + $ctx->{batch} = $data->{batch}; + } + if(exists $data->{logfile} && defined $data->{logfile}) { $ctx->{logfile} = $data->{logfile}; @@ -321,11 +339,19 @@ { $ctx->{rugzmdInstalled} = 1; } - + if($ctx->{norug}) + { + $ctx->{rugzmdInstalled} = 0; + } + if(-e $ctx->{zypper}) { $ctx->{zypperInstalled} = 1; } + if($ctx->{nozypper}) + { + $ctx->{zypperInstalled} = 0; + } # check and fix mirrorCount @@ -409,34 +435,36 @@ } -# print STDERR "list-parameters: $listParams\n" if($debug); -# print STDERR "product: ".Data::Dumper->Dump([\@comlineProducts])."\n" if($debug); -# print STDERR "xml-output: $xmlout\n" if($debug); -# print STDERR "dumpfile: $dumpfilehack\n" if($debug); -# print STDERR "dumpxmlfile: $dumpxmlfilehack\n" if($debug); -# print STDERR "no-optional: $nooptional\n" if($debug); -# print STDERR "forcereg: $forcereg\n" if($debug); -# print STDERR "no-hw-data: $nohwdata\n" if($debug); -# print STDERR "log: ".(($logfile)?$logfile:"undef")."\n" if($debug); -# print STDERR "locale: ".(($locale)?$locale:"undef")."\n" if($debug); -# print STDERR "no-proxy: $noproxy\n" if($debug); -# print STDERR "yastcall: $yastcall\n" if($debug); -# print STDERR "mirrorCount: $mirrorCount\n" if($debug); -# print STDERR "arg: ".Data::Dumper->Dump([{%args}])."\n" if($debug); -# print STDERR "extra-curl-option:".Data::Dumper->Dump([@extraCurlOption])."\n" if($debug); - -# print STDERR "URL: $URL\n" if($debug); -# print STDERR "listParams: $URLlistParams\n" if($debug); -# print STDERR "register: $URLregister\n" if($debug); - - $ctx->{initnooptional} = $ctx->{nooptional}; + print STDERR "list-parameters: $ctx->{listParams}\n" if($ctx->{debug}); + print STDERR "product: ".Data::Dumper->Dump([$ctx->{comlineProducts}])."\n" if($ctx->{debug}); + print STDERR "xml-output: $ctx->{xmlout}\n" if($ctx->{debug}); + print STDERR "dumpfile: $ctx->{dumpfilehack}\n" if($ctx->{debug}); + print STDERR "dumpxmlfile: $ctx->{dumpxmlfilehack}\n" if($ctx->{debug}); + print STDERR "no-optional: $ctx->{nooptional}\n" if($ctx->{debug}); + print STDERR "batch: $ctx->{batch}\n" if($ctx->{debug}); + print STDERR "forcereg: $ctx->{forcereg}\n" if($ctx->{debug}); + print STDERR "no-hw-data: $ctx->{nohwdata}\n" if($ctx->{debug}); + print STDERR "norug: $ctx->{norug}\n" if($ctx->{debug}); + print STDERR "nozypper: $ctx->{nozypper}\n" if($ctx->{debug}); + print STDERR "log: ".(($ctx->{logfile})?$ctx->{logfile}:"undef")."\n" if($ctx->{debug}); + print STDERR "locale: ".(($ctx->{locale})?$ctx->{locale}:"undef")."\n" if($ctx->{debug}); + print STDERR "no-proxy: $ctx->{noproxy}\n" if($ctx->{debug}); + print STDERR "yastcall: $ctx->{yastcall}\n" if($ctx->{debug}); + print STDERR "mirrorCount: $ctx->{mirrorCount}\n" if($ctx->{debug}); + print STDERR "arg: ".Data::Dumper->Dump([$ctx->{args}])."\n" if($ctx->{debug}); + print STDERR "extra-curl-option:".Data::Dumper->Dump([$ctx->{extraCurlOption}])."\n" if($ctx->{debug}); + + print STDERR "URL: $ctx->{URL}\n" if($ctx->{debug}); + print STDERR "listParams: $ctx->{URLlistParams}\n" if($ctx->{debug}); + print STDERR "register: $ctx->{URLregister}\n" if($ctx->{debug}); + my $iuri = URI->new($ctx->{URL}); $ctx->{initialDomain} = $iuri->host; $ctx->{initialDomain} =~ s/.+(\.[^.]+\.[^.]+)$/$1/; -#print STDERR "initialDomain: $initialDomain\n" if($debug); + print STDERR "initialDomain: $ctx->{initialDomain}\n" if($ctx->{debug}); if(exists $ENV{LANG} && $ENV{LANG} =~ /^([\w_]+)\.?/) { @@ -471,7 +499,7 @@ } } -#print STDERR "lang: $lang\n" if($debug); + print STDERR "lang: $ctx->{lang}\n" if($ctx->{debug}); # set LANG to en_US to get the error messages in english $ENV{LANG} = "en_US"; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org