Hello community, here is the log from the commit of package suseRegister checked in at Sat Mar 3 14:31:04 CET 2007. -------- --- suseRegister/suseRegister.changes 2007-02-23 16:28:29.000000000 +0100 +++ /mounts/work_src_done/NOARCH/suseRegister/suseRegister.changes 2007-03-02 19:18:01.850730000 +0100 @@ -1,0 +2,13 @@ +Fri Mar 2 19:17:56 CET 2007 - mc@suse.de + +- fix fillURL + +------------------------------------------------------------------- +Fri Mar 2 17:14:09 CET 2007 - mc@suse.de + +- workaround zypper delete problems + [#219770] +- create a copy of the cache and do a rollback, when + configureZMD failed + +------------------------------------------------------------------- New: ---- zypper_wrap ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ suseRegister.spec ++++++ --- /var/tmp/diff_new_pack.i26734/_old 2007-03-03 14:30:59.000000000 +0100 +++ /var/tmp/diff_new_pack.i26734/_new 2007-03-03 14:30:59.000000000 +0100 @@ -12,7 +12,7 @@ Name: suseRegister Version: 1.2 -Release: 23 +Release: 25 Summary: Registration Tool Group: Productivity/Other License: GNU General Public License (GPL) @@ -20,6 +20,7 @@ Source1: suseRegister.init Source2: suse-trigger-register.cron Source3: suseRegister.NetworkManager +Source4: zypper_wrap BuildRoot: %{_tmppath}/%{name}-%{version}-build Requires: curl Requires: perl-XML-Parser @@ -54,6 +55,9 @@ %install make DESTDIR=$RPM_BUILD_ROOT BINDIR=%{_bindir} SYSCONFIGDIR=%{_sysconfdir} install +install -m 755 $RPM_SOURCE_DIR/zypper_wrap $RPM_BUILD_ROOT/usr/lib/suseRegister/bin/ +ln -s /usr/lib/suseRegister/bin/zypper_wrap $RPM_BUILD_ROOT/usr/lib/suseRegister/bin/zypp_sa +ln -s /usr/lib/suseRegister/bin/zypper_wrap $RPM_BUILD_ROOT/usr/lib/suseRegister/bin/zypp_sd %if %{sles_version} > 0 mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/cron.monthly/ mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/init.d @@ -91,6 +95,13 @@ %endif %changelog +* Fri Mar 02 2007 - mc@suse.de +- fix fillURL +* Fri Mar 02 2007 - mc@suse.de +- workaround zypper delete problems + [#219770] +- create a copy of the cache and do a rollback, when + configureZMD failed * Fri Feb 23 2007 - mc@suse.de - fix alias handling of manualy added URLs [#248230] * Thu Feb 22 2007 - mc@suse.de ++++++ 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 2007-02-23 15:41:39.000000000 +0100 +++ new/suseRegister-1.2/SRPrivate.pm 2007-03-02 19:17:17.000000000 +0100 @@ -6,6 +6,7 @@ use XML::Writer; use Data::Dumper; use File::Temp qw(tempfile); +use File::Copy; use Sys::Syslog; use IPC::Open3; use Fcntl qw(:DEFAULT); @@ -1386,24 +1387,13 @@ elsif($ctx->{zmdConfig}->{$service}->{type} eq "nu" || $ctx->{zmdConfig}->{$service}->{type} eq "rce") { - my $secret = ""; - open(SEC, "< $ctx->{SECRET_FILE}") or do { - logPrintExit("Cannot open file $ctx->{SECRET_FILE}: $!\n", 12); - }; - while(<SEC>) - { - $secret .= $_; - } - close SEC; - foreach my $u (keys %{$ctx->{zmdConfig}->{$service}->{catalog}}) { - my $curi = URI->new($ctx->{zmdConfig}->{$service}->{catalog}->{$u}->{url}); - print $curi->as_string."\n" if($ctx->{debug}); - $curi->userinfo($ctx->{guid}.":$secret"); - $curi->query_form(alias => $u); - - print XMLD $curi->as_string."\n"; + my $url = fillURL($ctx, $ctx->{zmdConfig}->{$service}->{catalog}->{$u}->{url}, + {alias => $u}); + print stripURL($ctx, $url)."\n" if($ctx->{debug}); + + print XMLD "$url\n"; syslog("info", "dumpfile write(nu):".$u); } } @@ -1438,6 +1428,12 @@ mkdir "/var/cache/SuseRegister/"; } + # make a backup of the old cache file + if(-e $ctx->{zmdcache}) + { + copy($ctx->{zmdcache}, $ctx->{zmdcache}.".old"); + } + open(OUT, "> ".$ctx->{zmdcache}) or return logPrintReturn($ctx, "Cannot open cache file '$ctx->{zmdcache}': $!", 12); print OUT $zmdconfig; close OUT; @@ -1705,6 +1701,13 @@ # try to drop the headline next if($num eq "#"); # the line --+------+------+... will not appear here + + my $strURL = stripURL($ctx, $uri); + if($strURL eq "") + { + return logPrintReturn($ctx, "Missing URL\n", 14); + } + $uri = $strURL; print STDERR "Found $num, $stat, $type, $name, $uri\n" if($ctx->{debug} >= 2); @@ -1938,7 +1941,8 @@ my $regcode = shift || undef; my $msg = ""; - + my $code = 0; + $ctx->{timeindent}++; my $t0 = [gettimeofday] if($ctx->{time}); print STDERR indent($ctx)."START: zyppServiceAdd\n" if($ctx->{time}); @@ -1956,54 +1960,108 @@ { return logPrintReturn($ctx, "Invalid type", 14); } - - my @rugArgs = ("sa"); - - push @rugArgs, "$url"; - - if(defined $id) + + # zypper is not ready for this; use the wrapper instead + if(0) { - push @rugArgs, $id; + my @rugArgs = ("sa"); + + push @rugArgs, "$url"; + + if(defined $id) + { + push @rugArgs, $id; + } + else + { + # zypper requires a alias name. Use the hostname as fallback + my $u = URI->new($url); + push @rugArgs, $u->host; + } + + print STDERR "zypper add service command: $ctx->{zypper} ".join(" ",@rugArgs)."\n" if($ctx->{debug} >= 1); + + my $pid = open3(\*IN, \*OUT, \*ERR, $ctx->{zypper}, @rugArgs) or do { + return logPrintReturn($ctx, "Cannot execute $ctx->{zypper} ".join(" ", @rugArgs).": $!\n",13); + }; + + while (<OUT>) + { + $msg .= "$_"; + } + #chomp($msg) if(defined $msg && $msg ne ""); + while (<ERR>) + { + $msg .= "$_"; + } + close OUT; + close ERR; + close IN; + waitpid $pid, 0; + + $code = ($?>>8); + if($code != 0) + { + $code += 30; + } + else + { + $msg = ""; + } } else { - # zypper requires a alias name. Use the url as fallback - my $u = URI->new($url); - push @rugArgs, $u->host; - } - - print STDERR "zypper add service command: $ctx->{zypper} ".join(" ",@rugArgs)."\n" if($ctx->{debug} >= 1); - - my $pid = open3(\*IN, \*OUT, \*ERR, $ctx->{zypper}, @rugArgs) or do { - return logPrintReturn($ctx, "Cannot execute $ctx->{zypper} ".join(" ", @rugArgs).": $!\n",13); - }; + if(! -x "/usr/lib/suseRegister/bin/zypp_sa") + { + return (0,""); + } - while (<OUT>) - { - $msg .= "$_"; - } - #chomp($msg) if(defined $msg && $msg ne ""); - while (<ERR>) - { - $msg .= "$_"; - } - close OUT; - close ERR; - close IN; - waitpid $pid, 0; + my @rugArgs = ("$url"); + + if(defined $id) + { + push @rugArgs, $id; + } + else + { + # zypper requires a alias name. Use the hostname as fallback + my $u = URI->new($url); + push @rugArgs, $u->host; + } - my $code = ($?>>8); - if($code != 0) - { - $code += 30; - } - else - { - $msg = ""; + print STDERR "zypper add service command: /usr/lib/suseRegister/bin/zypp_sa ".join(" ",@rugArgs)."\n" if($ctx->{debug} >= 1); + + my $pid = open3(\*IN, \*OUT, \*ERR, "/usr/lib/suseRegister/bin/zypp_sa", @rugArgs) or do { + return logPrintReturn($ctx, "Cannot execute /usr/lib/suseRegister/bin/zypp_sa ".join(" ", @rugArgs).": $!\n",13); + }; + + while (<OUT>) + { + $msg .= "$_"; + } + #chomp($msg) if(defined $msg && $msg ne ""); + while (<ERR>) + { + $msg .= "$_"; + } + close OUT; + close ERR; + close IN; + waitpid $pid, 0; + + $code = ($?>>8); + if($code != 0) + { + $code += 30; + } + else + { + $msg = ""; + } } print STDERR "Add service failed($code): $msg\n" if($ctx->{debug} && $code != 0); - + print STDERR indent($ctx)."END: zyppServiceAdd:".(tv_interval($t0))."\n" if($ctx->{time}); $ctx->{timeindent}--; @@ -2359,7 +2417,8 @@ my $ctx = shift; my $id = shift || undef; my $msg = ""; - + my $code = 0; + $ctx->{timeindent}++; my $t0 = [gettimeofday] if($ctx->{time}); print STDERR indent($ctx)."START: zyppServiceDelete\n" if($ctx->{time}); @@ -2369,43 +2428,87 @@ return logPrintReturn($ctx, "Missing Identifirer", 14); } - if($ctx->{nozypp} || !$ctx->{zypperInstalled} || $ctx->{nozypper}) + # zypper is not ready for this; we use a wrapper + if(0) { - return (0,""); - } - - my @rugArgs = ("sd", "$id"); - - print STDERR "zypp service delete command: $ctx->{zypper} ".join(" ",@rugArgs)."\n" if($ctx->{debug} >= 1); - - my $pid = open3(\*IN, \*OUT, \*ERR, $ctx->{zypper}, @rugArgs) or do { - logPrintReturn($ctx, "Cannot execute $ctx->{zypper} ".join(" ", @rugArgs).": $!\n",13); - }; + if($ctx->{nozypp} || !$ctx->{zypperInstalled} || $ctx->{nozypper}) + { + return (0,""); + } + + my @rugArgs = ("sd", "$id"); + + print STDERR "zypp service delete command: $ctx->{zypper} ".join(" ",@rugArgs)."\n" if($ctx->{debug} >= 1); + + my $pid = open3(\*IN, \*OUT, \*ERR, $ctx->{zypper}, @rugArgs) or do { + logPrintReturn($ctx, "Cannot execute $ctx->{zypper} ".join(" ", @rugArgs).": $!\n",13); + }; + + while (<OUT>) + { + $msg .= "$_"; + } + #chomp($msg) if(defined $msg && $msg ne ""); + while (<ERR>) + { + $msg .= "$_"; + } + close OUT; + close ERR; + close IN; + waitpid $pid, 0; + + $code = ($?>>8); + if($code != 0) + { + $code += 30; + } + else + { + $msg = ""; + } - while (<OUT>) - { - $msg .= "$_"; - } - #chomp($msg) if(defined $msg && $msg ne ""); - while (<ERR>) - { - $msg .= "$_"; - } - close OUT; - close ERR; - close IN; - waitpid $pid, 0; - - my $code = ($?>>8); - if($code != 0) - { - $code += 30; } else { - $msg = ""; + if($ctx->{nozypp} || ! -x "/usr/lib/suseRegister/bin/zypp_sd" || $ctx->{nozypper}) + { + return (0,""); + } + + my @rugArgs = ("--loose-auth", "--loose-query", "$id"); + + print STDERR "zypp service delete command: /usr/lib/suseRegister/bin/zypp_sd ".join(" ",@rugArgs)."\n" if($ctx->{debug} >= 1); + + my $pid = open3(\*IN, \*OUT, \*ERR, "/usr/lib/suseRegister/bin/zypp_sd", @rugArgs) or do { + logPrintReturn($ctx, "Cannot execute /usr/lib/suseRegister/bin/zypp_sd ".join(" ", @rugArgs).": $!\n",13); + }; + + while (<OUT>) + { + $msg .= "$_"; + } + #chomp($msg) if(defined $msg && $msg ne ""); + while (<ERR>) + { + $msg .= "$_"; + } + close OUT; + close ERR; + close IN; + waitpid $pid, 0; + + $code = ($?>>8); + if($code != 0) + { + $code += 30; + } + else + { + $msg = ""; + } } - + print STDERR "Delete service failed($code): $msg\n" if($ctx->{debug} && $code != 0); print STDERR indent($ctx)."END: zyppServiceDelete:".(tv_interval($t0))."\n" if($ctx->{time}); @@ -2541,4 +2644,75 @@ return $ind; } +sub stripURL +{ + my $ctx = shift; + my $url = shift || ""; + + if($url eq "") + { + return ""; + } + + my $uri = URI->new($url); + + if($uri->scheme eq "http" || + $uri->scheme eq "https" ) + { + # delete user/password from url + $uri->userinfo(undef); + } + + # delete all query parameter from the url + $uri->query(undef); + + return $uri->as_string; +} + +sub fillURL +{ + my $ctx = shift; + my $url = shift || ""; + my $queryparams = shift || undef; + + if($url eq "") + { + return ""; + } + + my $secret = ""; + open(SEC, "< $ctx->{SECRET_FILE}") or do { + logPrintReturn("Cannot open file $ctx->{SECRET_FILE}: $!\n", 12); + return ""; + }; + while(<SEC>) + { + $secret .= $_; + } + close SEC; + + my $uri = URI->new($url); + + if($uri->scheme eq "http" || + $uri->scheme eq "https" ) + { + # add user/password to url + $uri->userinfo($ctx->{guid}.":$secret"); + } + + if(! defined $queryparams || $queryparams eq "") + { + # delete the query paramter + $uri->query(undef); + } + else + { + # add query parameter + $uri->query_form($queryparams); + } + + return $uri->as_string; +} + + 1; 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 2007-02-23 15:41:39.000000000 +0100 +++ new/suseRegister-1.2/suse_register 2007-03-02 19:17:17.000000000 +0100 @@ -16,7 +16,7 @@ use Time::HiRes qw(gettimeofday tv_interval); use Sys::Syslog; use SUSE::SuseRegister; - +use File::Copy; my $time = 0; my $programStartTime = [gettimeofday]; @@ -429,6 +429,8 @@ SUSE::SuseRegister::configureZMD($ctx); if($ctx->{errorcode} != 0) { + # cache rollback + copy($ctx->{zmdcache}.".old", $ctx->{zmdcache}); logPrintExit($ctx, $ctx->{errormsg}, $ctx->{errorcode}); } 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 2007-02-23 15:41:39.000000000 +0100 +++ new/suseRegister-1.2/SuseRegister.pm 2007-03-02 19:17:17.000000000 +0100 @@ -1,4 +1,3 @@ - # # Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -1052,10 +1051,21 @@ deleteCatalog($ctx, $name, $taskList->{$service}->{catalog}->{$name}); if($ctx->{errorcode} != 0) { - $lastcode = $ctx->{errorcode}; - $lastmsg = $ctx->{errormsg}; - $ctx->{errorcode} = 0; - $ctx->{errormsg} = ""; + if(exists $ctx->{lastZmdConfig}->{$service}->{catalog}->{$name} && + ! exists $ctx->{zmdConfig}->{$service}->{catalog}->{$name} && + ! exists $ctx->{currentSources}->{$service}->{catalog}->{$name}) + { + # maybe the catalog is really not there; we do not set an error here + $ctx->{errorcode} = 0; + $ctx->{errormsg} = ""; + } + else + { + $lastcode = $ctx->{errorcode}; + $lastmsg = $ctx->{errormsg}; + $ctx->{errorcode} = 0; + $ctx->{errormsg} = ""; + } } } elsif($taskList->{$service}->{catalog}->{$name}->{task} eq "r") @@ -1710,22 +1720,10 @@ # first add it with zypp if url is available if(exists $catalog->{url}) { - # a rug catalog is from NU service and needs auth data - my $secret = ""; - open(SEC, "< $ctx->{SECRET_FILE}") or do { - logPrintExit("Cannot open file $ctx->{SECRET_FILE}: $!\n", 12); - }; - while(<SEC>) - { - $secret .= $_; - } - close SEC; - - my $curi = URI->new($catalog->{url}); - $curi->userinfo($ctx->{guid}.":$secret"); + my $url = SUSE::SRPrivate::fillURL($ctx, $catalog->{url}, undef); # A rug catalog is a zypp service - so call zyppServiceAdd - ($code, $msg) = SUSE::SRPrivate::zyppServiceAdd($ctx, $curi->as_string, "zypp", $name); + ($code, $msg) = SUSE::SRPrivate::zyppServiceAdd($ctx, $url, "zypp", $name); if($code != 0) { $lastcode = $code; @@ -1992,20 +1990,18 @@ return SUSE::SRPrivate::logPrintError($ctx, "Invalid Catalog", 14); return 14; } - - # first add it with zypp if url is available - if(exists $catalog->{url}) - { - # A rug catalog is a zypp service - so call zyppServiceDelete - ($code, $msg) = SUSE::SRPrivate::zyppServiceDelete($ctx, $catalog->{url}); - } + # first delete it with zypp if url is available + + # A rug catalog is a zypp service - so call zyppServiceDelete + ($code, $msg) = SUSE::SRPrivate::zyppServiceDelete($ctx, $name); - if($code != 0) + if($code != 0 && exists $catalog->{url}) { - # try again with the alias + # try with the URL # A rug catalog is a zypp service - so call zyppServiceDelete - ($code, $msg) = SUSE::SRPrivate::zyppServiceDelete($ctx, $name); + ($code, $msg) = SUSE::SRPrivate::zyppServiceDelete($ctx, $catalog->{url}); + if($code != 0) { $lastcode = $code; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org