Updates Windows release scripts to generate and upload GPG signatures.

This commit is contained in:
Steve Dower 2015-04-05 18:42:37 -07:00
parent 79a6ccad53
commit 7b8c5f58aa
3 changed files with 56 additions and 1 deletions

27
Tools/msi/generate_md5.py Normal file
View File

@ -0,0 +1,27 @@
import hashlib
import os
import sys
def main():
filenames, hashes, sizes = [], [], []
for file in sys.argv[1:]:
if not os.path.isfile(file):
continue
with open(file, 'rb') as f:
data = f.read()
md5 = hashlib.md5()
md5.update(data)
filenames.append(os.path.split(file)[1])
hashes.append(md5.hexdigest())
sizes.append(str(len(data)))
print('{:40s} {:<32s} {:<9s}'.format('File', 'MD5', 'Size'))
for f, h, s in zip(filenames, hashes, sizes):
print('{:40s} {:>32s} {:>9s}'.format(f, h, s))
if __name__ == "__main__":
sys.exit(int(main() or 0))

View File

@ -20,19 +20,28 @@ if "%1" EQU "--target" (set TARGET=%~2) && shift && shift && goto CheckOpts
if "%1" EQU "--dry-run" (set DRYRUN=true) && shift && goto CheckOpts if "%1" EQU "--dry-run" (set DRYRUN=true) && shift && goto CheckOpts
if not defined PLINK where plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" if not defined PLINK where plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc"
if not defined PLINK where /R "%ProgramFiles(x86)%\PuTTY" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc"
if not defined PLINK where /R "%ProgramFiles(x86)%" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" if not defined PLINK where /R "%ProgramFiles(x86)%" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc"
if not defined PLINK echo Cannot locate plink.exe & exit /B 1 if not defined PLINK echo Cannot locate plink.exe & exit /B 1
echo Found plink.exe at %PLINK% echo Found plink.exe at %PLINK%
if not defined PSCP where pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" if not defined PSCP where pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc"
if not defined PSCP where /R "%ProgramFiles(x86)%\PuTTY" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc"
if not defined PSCP where /R "%ProgramFiles(x86)%" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" if not defined PSCP where /R "%ProgramFiles(x86)%" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc"
if not defined PSCP echo Cannot locate pscp.exe & exit /B 1 if not defined PSCP echo Cannot locate pscp.exe & exit /B 1
echo Found pscp.exe at %PSCP% echo Found pscp.exe at %PSCP%
if not defined GPG where gpg2 > "%TEMP%\gpg.loc" 2> nul && set /P GPG= < "%TEMP%\gpg.loc" & del "%TEMP%\gpg.loc"
if not defined GPG where /R "%PCBUILD%..\externals" gpg2 > "%TEMP%\gpg.loc" 2> nul && set /P GPG= < "%TEMP%\gpg.loc" & del "%TEMP%\gpg.loc"
if not defined GPG echo Cannot locate gpg2.exe. Signatures will not be uploaded & pause
echo Found gpg2.exe at %GPG%
call "%PCBUILD%env.bat" > nul 2> nul call "%PCBUILD%env.bat" > nul 2> nul
pushd "%D%" pushd "%D%"
msbuild /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x86 msbuild /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x86
msbuild /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x64 /p:IncludeDoc=false msbuild /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x64 /p:IncludeDoc=false
msbuild /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x86
msbuild /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x64 /p:IncludeDoc=false
popd popd
exit /B 0 exit /B 0

View File

@ -38,6 +38,17 @@
<Error Text="No path for PLINK provided" Condition="'$(PLINK)' == ''" /> <Error Text="No path for PLINK provided" Condition="'$(PLINK)' == ''" />
</Target> </Target>
<Target Name="_RunGpg" Condition="'$(GPG)' != ''" Inputs="@(File)" Outputs="$(IntermediateOutputPath)\gpg\%(FileName)%(Extension).asc">
<MakeDir Directories="$(IntermediateOutputPath)gpg" />
<Delete Files="$(IntermediateOutputPath)\gpg\%(File.FileName)%(File.Extension).asc" Condition="Exists('$(IntermediateOutputPath)\gpg\%(File.FileName)%(File.Extension).asc')" />
<Exec Command="&quot;$(GPG)&quot; -ba -o &quot;$(IntermediateOutputPath)\gpg\%(File.FileName)%(File.Extension).asc&quot; &quot;%(File.FullPath)&quot;" />
<ItemGroup>
<File Include="$(IntermediateOutputPath)\gpg\%(File.FileName)%(File.Extension).asc">
<CopyTo>%(File.CopyTo)</CopyTo>
</File>
</ItemGroup>
</Target>
<Target Name="_Upload" Condition="!$(DryRun)"> <Target Name="_Upload" Condition="!$(DryRun)">
<Exec Command="&quot;$(PLINK)&quot; $(User)@$(Host) mkdir %(File.CopyTo) ^&amp;^&amp; chgrp downloads %(File.CopyTo) ^&amp;^&amp; chmod g-w,o+rx %(File.CopyTo) <Exec Command="&quot;$(PLINK)&quot; $(User)@$(Host) mkdir %(File.CopyTo) ^&amp;^&amp; chgrp downloads %(File.CopyTo) ^&amp;^&amp; chmod g-w,o+rx %(File.CopyTo)
&quot;$(PSCP)&quot; @(File,' ') $(User)@$(Host):%(File.CopyTo) &quot;$(PSCP)&quot; @(File,' ') $(User)@$(Host):%(File.CopyTo)
@ -53,7 +64,15 @@ echo.
echo." /> echo." />
</Target> </Target>
<Target Name="Upload" DependsOnTargets="_ValidateProperties;_PrintNames;_Upload" /> <Target Name="Upload" DependsOnTargets="_ValidateProperties;_RunGpg;_PrintNames;_Upload" />
<Target Name="ShowHashes">
<ItemGroup>
<UserFiles Include="@(File)" Condition="'%(File.CopyTo)' == '$(EXETarget)'" />
</ItemGroup>
<Exec Command="&quot;$(PythonExe)&quot; generate_md5.py @(UserFiles->'&quot;%(FullPath)&quot;',' ')" />
</Target>
<Target Name="Build"> <Target Name="Build">
<Error Text="This script should be invoked using uploadrelease.bat." /> <Error Text="This script should be invoked using uploadrelease.bat." />