Skip to content

Commit

Permalink
fix line endings for reproducible SHAs
Browse files Browse the repository at this point in the history
  • Loading branch information
artoonie committed Feb 23, 2024
1 parent 24313bd commit 36733a8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
31 changes: 0 additions & 31 deletions .github/actions/Sha-Of-Directory.ps1

This file was deleted.

27 changes: 12 additions & 15 deletions .github/actions/sha-of-zip.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ setlocal EnableExtensions EnableDelayedExpansion

:: All paths relative to pwd -- where this script is called from
set "EXTRACTIONDIR=.\rcv\zip_extracted"
set "MODULESFILE=.\rcv\zip_extracted\rcv\lib\modules"
set "MODULESDIR=.\rcv\zip_extracted\rcv\lib\modules_extracted"
set "HASHFILE_UNSORTED=all_hashes_unsorted.txt"
set "HASHFILE_PATH_STRIPPED=all_hashes_path_stripped.txt"
set "HASHFILE_SORTED=all_hashes_sorted.txt"
Expand All @@ -21,24 +19,19 @@ if exist %HASHFILE_UNSORTED% (
del %HASHFILE_UNSORTED%
)

if exist %EXTRACTIONDIR% (
rmdir /s /q %EXTRACTIONDIR%
if exist %HASHFILE_PATH_STRIPPED% (
del %HASHFILE_PATH_STRIPPED%
)

if exist %MODULESDIR% (
rmdir /s /q %EXTRACTIONDIR%
if exist %HASHFILE_SORTED% (
del %HASHFILE_SORTED%
)

powershell -command Expand-Archive -Path %ZIP_FILEPATH% -Destination %EXTRACTIONDIR%

:: Extract modules, get the SHA-512 of it, and add it to the top of the hashfile
jimage extract --dir %MODULESDIR% %MODULESFILE%

powershell .github\actions\Sha-Of-Directory.ps1 %MODULESDIR% 512 > %HASHFILE_UNSORTED%
if exist %EXTRACTIONDIR% (
rmdir /s /q %EXTRACTIONDIR%
)

:: Delete both modules and the extracted dir
del %MODULESFILE%
rmdir /s /q %MODULESDIR%
powershell -command Expand-Archive -Path %ZIP_FILEPATH% -Destination %EXTRACTIONDIR%

:: Calculate the hash for every file here and in all subdirectories, appending to the file (format "(filename) = (hash)")
(
Expand All @@ -59,6 +52,10 @@ for /f "delims=" %%A in ('type "%HASHFILE_UNSORTED%"') do (

sort "%HASHFILE_PATH_STRIPPED%" > "%HASHFILE_SORTED%"

:: dos2unix on the file to ensure consistent SHAs
powershell -Command "& {[IO.File]::WriteAllText(\"%HASHFILE_SORTED%\", $([IO.File]::ReadAllText(\"%HASHFILE_SORTED%\") -replace \"`r`n", "`n\"))}"

:: echo the final hash
C:\Windows\System32\certutil.exe -hashfile %HASHFILE_SORTED% SHA%SHA_A% | findstr /v ":"

:: For debugging, enable printing the file-by-file hash
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,13 @@ jobs:
name: Package
if-no-files-found: error
path: |
${{ github.workspace }}/all_hashes_sorted.txt
${{ github.workspace }}/${{ steps.zipfn.outputs.FILEPATH }}
${{ github.workspace }}/${{ steps.zipfn.outputs.FILEPATH }}.sha512
${{ github.workspace }}/${{ steps.zipfn.outputs.FILEPATH }}.golden.sha512
${{ github.workspace }}/${{ steps.exefn.outputs.FILEPATH }}
${{ github.workspace }}/${{ steps.exefn.outputs.FILEPATH }}.sha512
${{ github.workspace }}/${{ steps.cachefn.outputs.FILEPATH }}
${{ github.workspace }}/${{ steps.cachefn.outputs.FILEPATH }}.sha512
${{ github.workspace }}/${{ steps.cachefn.outputs.FILEPATH }}.golden.sha512
${{ github.workspace }}/${{ steps.checksumsfn.outputs.FILEPATH }}
${{ github.workspace }}/${{ steps.checksumsfn.outputs.FILEPATH }}.sha512
retention-days: 1
Expand Down

0 comments on commit 36733a8

Please sign in to comment.