Skip to content

Commit b007a38

Browse files
committed
fix: Verify tarball before build
- Use sha256sum file to determine version and integrity - Verify hash before build (and inside, for local usage)
1 parent b8fccb1 commit b007a38

File tree

5 files changed

+32
-20
lines changed

5 files changed

+32
-20
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ jobs:
1010
container: registry.fedoraproject.org/fedora:37
1111
steps:
1212
- name: Install Dependencies
13-
run: dnf install -y mingw64-gcc zip make wget tar
13+
run: dnf install -y -q mingw64-gcc make wget tar
1414

1515
- uses: actions/checkout@v3
1616

1717
- name: Download make release tar.gz file
18-
run: wget "https://ftpmirror.gnu.org/make/make-$(cat build_version.txt).tar.gz"
18+
run: wget "https://ftpmirror.gnu.org/make/$(cat build_version.sha256sum | cut -d ' ' -f3)"
1919

20-
- name: Print out hash of tar.gz file
21-
run: sha256sum "make-$(cat build_version.txt).tar.gz"
20+
- name: Verify the hash of the tar.gz file
21+
run: sha256sum -c build_version.sha256sum
2222

2323
- name: Run the build process
2424
run: ./cross_build_w64.sh
2525

2626
- name: Hash the built binaries
27-
run: sha256sum make-$(cat build_version.txt)/dist/*
27+
run: sha256sum make-*/dist/*
2828

2929
- uses: actions/upload-artifact@v3
3030
with:

build_version.sha256sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
581f4d4e872da74b3941c874215898a7d35802f03732bdccee1d4a7979105d18 make-4.4.tar.gz

build_version.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

cross_build_w64.sh

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,51 @@ copy_dependent_dlls(){
88
do
99
echo "Searching $dll_name" in $dll_source_dir
1010
find "$dll_source_dir" -name "$dll_name" -exec cp "{}" ./dist \;
11-
if [[ $? -eq 0 ]]
11+
dist_dll_path="./dist/$dll_name"
12+
if [[ -f "$dist_dll_path" ]]
1213
then
13-
dist_dll_path="./dist/$dll_name"
14-
if [[ -f "$dist_dll_path" ]]
15-
then
16-
copy_dependent_dlls "$dist_dll_path"
17-
fi
18-
else
19-
echo "WARNING: Could not find $dll_name"
14+
copy_dependent_dlls "$dist_dll_path"
2015
fi
2116
done
2217
}
2318

24-
make_version="$(cat build_version.txt)"
19+
20+
21+
# Verify tarball integrity first
22+
echo "##############################"
23+
echo "Verifying integrity of tarball"
24+
echo "##############################"
25+
sha256sum -c build_version.sha256sum
26+
27+
tarball=$(cat build_version.sha256sum | cut -d " " -f3)
28+
make_version=${tarball%.tar.gz}
2529
host_triplet="x86_64-w64-mingw32"
26-
rm -rf "make-$make_version" || echo "No existing make directory"
30+
rm -rf "$make_version" || echo "No existing make directory"
2731

28-
tar -xzvf "make-$make_version.tar.gz"
29-
cd "make-$make_version"
32+
tar -xzf "$tarball"
33+
cd "$make_version"
3034

3135
# Cleanup target directory
3236
rm -rf ./dist
3337
mkdir -p ./dist
3438
mkdir -p install_target
3539

40+
echo "##########################################"
41+
echo "Building $make_version for $host_triplet"
42+
echo "##########################################"
3643
# By default, --export-dynamic is used which is not supported for PE binaries.
3744
# Therefore override the LDFLAGS accordingly
3845
LDFLAGS='-Wl,--export-all-symbols -fstack-protector -lssp' mingw64-configure --without-guile
3946
mingw64-make && mv make.exe ./dist
4047
if [[ $? -eq 0 ]]
4148
then
49+
echo "#######################################"
50+
echo "Copying needed shared libraries to dist"
51+
echo "#######################################"
52+
4253
copy_dependent_dlls ./dist/make.exe
43-
zip -r "make-$make_version-w64.zip" dist/*
54+
55+
echo "################################"
4456
echo "Build complete. Result in ./dist"
57+
echo "################################"
4558
fi
46-

make-4.4.tar.gz.sig

-566 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)