This adds the _UpdateSharedAddOn() method and only calls _UpdateMSIAddOn() as a fallback. This also updates _IsAddOnBad() to check for the presence of the shared install so the addon is not updated if it is present in either the shared install or MSI form. _IsAddOnBad() also stores the information needed to locate and update the addon for use by the update methods.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/Build/Utils.pm | 53 +++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/testbot/lib/Build/Utils.pm b/testbot/lib/Build/Utils.pm index a6d38fc7f5..aa786183b5 100644 --- a/testbot/lib/Build/Utils.pm +++ b/testbot/lib/Build/Utils.pm @@ -373,9 +373,14 @@ sub _IsAddOnBad($$) my $Basename = "wine-$AddOn->{name}-$AddOn->{version}"; my $ArchSuffix = $Arch eq "" ? "" : "-$Arch"; $AddOnArch->{msifile} = "$Basename$ArchSuffix.msi"; + $AddOnArch->{shareddir} = $Basename; + $AddOnArch->{shareddir} .= $ArchSuffix if ($AddOn->{name} ne "mono"); + $AddOnArch->{basetar} = "$Basename$ArchSuffix"; mkdir "$AddOn->{basedir}"; }
+ return undef if (-d "$AddOn->{basedir}/$AddOnArch->{shareddir}"); + my $Sha256 = Digest::SHA->new(256); eval { $Sha256->addfile("$AddOn->{basedir}/$AddOnArch->{msifile}") }; return "$@" if ($@); @@ -405,6 +410,52 @@ sub _UpdateMSIAddOn($$) return 0; }
+sub _UpdateSharedAddOn($$) +{ + my ($AddOn, $Arch) = @_; + + my $AddOnArch = $AddOn->{$Arch}; + InfoMsg "Downloading $AddOnArch->{basetar}\n"; + my $ErrMessage; + for (1..3) + { + foreach my $Suffix (".tar.xz", ".tar.bz2") + { + my $Tarfile = "$AddOnArch->{basetar}$Suffix"; + my $Url="$ADDONS_URL/wine-$AddOn->{name}/$AddOn->{version}/$Tarfile"; + system("cd '$AddOn->{basedir}' && set -x && ". + "wget --no-verbose -O- '$Url' >'$Tarfile'"); + if ($?) + { + unlink "$AddOn->{basedir}/$Tarfile"; + $ErrMessage ||= "Could not download the $AddOnArch->{basetar}* archive"; + } + else + { + my $Decompress = $Suffix eq ".tar.xz" ? "xz" : "bzip2"; + system("cd '$AddOn->{basedir}' && set -x && ". + "$Decompress -c -d '$Tarfile' | tar xf -"); + unlink "$AddOn->{basedir}/$Tarfile"; + if ($?) + { + $ErrMessage = "Could not decompress '$Tarfile'"; + } + elsif (!-d "$AddOn->{basedir}/$AddOnArch->{shareddir}") + { + $ErrMessage = "$Tarfile did not contain $AddOnArch->{shareddir}"; + } + else + { + return 1; # Success! + } + } + } + } + + LogMsg "$ErrMessage\n"; + return 0; +} + sub _UpdateAddOn($$$) { my ($AddOns, $Name, $Arch) = @_; @@ -427,7 +478,7 @@ sub _UpdateAddOn($$$) }
return 1 if (!_IsAddOnBad($AddOn, $Arch)); - return _UpdateMSIAddOn($AddOn, $Arch); + return _UpdateSharedAddOn($AddOn, $Arch) || _UpdateMSIAddOn($AddOn, $Arch); }
sub UpdateAddOns()