Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/Build/Utils.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/testbot/lib/Build/Utils.pm b/testbot/lib/Build/Utils.pm index 8c263275e5..7d0739e5bd 100644 --- a/testbot/lib/Build/Utils.pm +++ b/testbot/lib/Build/Utils.pm @@ -416,7 +416,8 @@ sub _UpdateAddOn($$$) sub UpdateAddOns() { my %AddOns; - if (open(my $fh, "<", "$DataDir/wine/dlls/appwiz.cpl/addons.c")) + my $AddonSrc = "wine/dlls/appwiz.cpl/addons.c"; + if (open(my $fh, "<", "$DataDir/$AddonSrc")) { my $Arch = ""; while (my $Line= <$fh>) @@ -448,7 +449,7 @@ sub UpdateAddOns() } else { - LogMsg "Could not open 'wine/dlls/appwiz.cpl/addons.c': $!\n"; + LogMsg "Could not open '$AddonSrc': $!\n"; return 0; }
The new name makes it clearer that _IsAddOnBad() returns true (the error message) if the addon is bad and false otherwise.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/Build/Utils.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/testbot/lib/Build/Utils.pm b/testbot/lib/Build/Utils.pm index 7d0739e5bd..17addeede8 100644 --- a/testbot/lib/Build/Utils.pm +++ b/testbot/lib/Build/Utils.pm @@ -360,7 +360,7 @@ sub BuildWine($$$$;$) # Wine addons updates #
-sub _VerifyAddOn($$) +sub _IsAddOnBad($$) { my ($AddOn, $Arch) = @_;
@@ -395,7 +395,7 @@ sub _UpdateAddOn($$$)
$AddOn->{filename} = "wine-$Name-$AddOn->{version}". ($Arch eq "" ? "" : "-$Arch") .".msi"; - return 1 if (!_VerifyAddOn($AddOn, $Arch)); + return 1 if (!_IsAddOnBad($AddOn, $Arch));
InfoMsg "Downloading $AddOn->{filename}\n"; mkdir "$DataDir/$Name"; @@ -407,7 +407,7 @@ sub _UpdateAddOn($$$) "wget --no-verbose -O- '$Url' >'$AddOn->{filename}'"); last if ($? == 0); } - my $ErrMessage = _VerifyAddOn($AddOn, $Arch); + my $ErrMessage = _IsAddOnBad($AddOn, $Arch); return 1 if (!defined $ErrMessage); LogMsg "$ErrMessage\n"; return 0;
Check whether the addon needs to be updated before any update method is called. Since _IsAddOnBad() needs all the information required to locate the addon it now stores it in the architecture-specific structure for reuse by the update methods such as _UpdateMSIAddOn().
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/Build/Utils.pm | 77 +++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 30 deletions(-)
diff --git a/testbot/lib/Build/Utils.pm b/testbot/lib/Build/Utils.pm index 17addeede8..a6d38fc7f5 100644 --- a/testbot/lib/Build/Utils.pm +++ b/testbot/lib/Build/Utils.pm @@ -1,5 +1,5 @@ # -*- Mode: Perl; perl-indent-level: 2; indent-tabs-mode: nil -*- -# Copyright 2018 Francois Gouget +# Copyright 2018-2020 Francois Gouget # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -360,23 +360,56 @@ sub BuildWine($$$$;$) # Wine addons updates #
+my $ADDONS_URL = "http://dl.winehq.org/wine"; + sub _IsAddOnBad($$) { my ($AddOn, $Arch) = @_;
+ my $AddOnArch = $AddOn->{$Arch}; + if (!$AddOnArch->{msifile}) + { + $AddOn->{basedir} = "$DataDir/$AddOn->{name}"; + my $Basename = "wine-$AddOn->{name}-$AddOn->{version}"; + my $ArchSuffix = $Arch eq "" ? "" : "-$Arch"; + $AddOnArch->{msifile} = "$Basename$ArchSuffix.msi"; + mkdir "$AddOn->{basedir}"; + } + my $Sha256 = Digest::SHA->new(256); - eval { $Sha256->addfile("$DataDir/$AddOn->{name}/$AddOn->{filename}") }; + eval { $Sha256->addfile("$AddOn->{basedir}/$AddOnArch->{msifile}") }; return "$@" if ($@);
my $Checksum = $Sha256->hexdigest(); - return undef if ($Checksum eq $AddOn->{$Arch}); - return "Bad checksum for '$AddOn->{filename}'"; + return undef if ($Checksum eq $AddOnArch->{checksum}); + return "Bad checksum for '$AddOnArch->{msifile}'"; +} + +sub _UpdateMSIAddOn($$) +{ + my ($AddOn, $Arch) = @_; + + my $AddOnArch = $AddOn->{$Arch}; + InfoMsg "Downloading $AddOnArch->{msifile}\n"; + my $Url="$ADDONS_URL/wine-$AddOn->{name}/$AddOn->{version}/$AddOnArch->{msifile}"; + my $ErrMessage; + for (1..3) + { + system("cd '$AddOn->{basedir}' && set -x && ". + "wget --no-verbose -O- '$Url' >'$AddOnArch->{msifile}'"); + $ErrMessage = _IsAddOnBad($AddOn, $Arch); + return 1 if (!defined $ErrMessage); + unlink "$AddOn->{basedir}/$AddOnArch->{msifile}"; + } + LogMsg "$ErrMessage\n"; + return 0; }
sub _UpdateAddOn($$$) { - my ($AddOn, $Name, $Arch) = @_; + my ($AddOns, $Name, $Arch) = @_;
+ my $AddOn = $AddOns->{$Name}; if (!defined $AddOn) { LogMsg "Could not get information on the $Name addon\n"; @@ -389,33 +422,17 @@ sub _UpdateAddOn($$$) } if (!$AddOn->{$Arch}) { - LogMsg "Could not get the $Name $Arch checksum\n"; + LogMsg "Could not get the $Name $Arch MSI checksum\n"; return 0; }
- $AddOn->{filename} = "wine-$Name-$AddOn->{version}". - ($Arch eq "" ? "" : "-$Arch") .".msi"; return 1 if (!_IsAddOnBad($AddOn, $Arch)); - - InfoMsg "Downloading $AddOn->{filename}\n"; - mkdir "$DataDir/$Name"; - - my $Url="http://dl.winehq.org/wine/wine-$Name/$AddOn-%3E%7Bversion%7D/$AddOn-%3E%7Bfi..."; - for (1..3) - { - system("cd '$DataDir/$Name' && set -x && ". - "wget --no-verbose -O- '$Url' >'$AddOn->{filename}'"); - last if ($? == 0); - } - my $ErrMessage = _IsAddOnBad($AddOn, $Arch); - return 1 if (!defined $ErrMessage); - LogMsg "$ErrMessage\n"; - return 0; + return _UpdateMSIAddOn($AddOn, $Arch); }
sub UpdateAddOns() { - my %AddOns; + my $AddOns; my $AddonSrc = "wine/dlls/appwiz.cpl/addons.c"; if (open(my $fh, "<", "$DataDir/$AddonSrc")) { @@ -434,14 +451,14 @@ sub UpdateAddOns() { my ($AddOn, $Version) = ($1, $2); $AddOn =~ tr/A-Z/a-z/; - $AddOns{$AddOn}->{name} = $AddOn; - $AddOns{$AddOn}->{version} = $Version; + $AddOns->{$AddOn}->{name} = $AddOn; + $AddOns->{$AddOn}->{version} = $Version; } elsif ($Line =~ /^\s*#\s*define\s*(GECKO|MONO)_SHA\s*"([^"]+)"/) { my ($AddOn, $Checksum) = ($1, $2); $AddOn =~ tr/A-Z/a-z/; - $AddOns{$AddOn}->{$Arch} = $Checksum; + $AddOns->{$AddOn}->{$Arch}->{checksum} = $Checksum; $Arch = ""; } } @@ -453,9 +470,9 @@ sub UpdateAddOns() return 0; }
- return _UpdateAddOn($AddOns{gecko}, "gecko", "x86") && - _UpdateAddOn($AddOns{gecko}, "gecko", "x86_64") && - _UpdateAddOn($AddOns{mono}, "mono", "x86"); + return _UpdateAddOn($AddOns, "gecko", "x86") && + _UpdateAddOn($AddOns, "gecko", "x86_64") && + _UpdateAddOn($AddOns, "mono", "x86"); }
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()