File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ GIT_LFS_FILENAME="$(jq --raw-output ".\"git-lfs\".files[] | select(.arch == \"$D
3636
3737# shellcheck source=script/compute-checksum.sh
3838source " $CURRENT_DIR /compute-checksum.sh"
39+ # shellcheck source=script/verify-lfs-contents.sh
40+ source " $CURRENT_DIR /verify-lfs-contents.sh"
3941
4042echo " -- Building git at $SOURCE to $DESTINATION "
4143
@@ -84,6 +86,9 @@ if [[ "$GIT_LFS_VERSION" ]]; then
8486 if [ " $COMPUTED_SHA256 " = " $GIT_LFS_CHECKSUM " ]; then
8587 echo " Git LFS: checksums match"
8688 SUBFOLDER=" $DESTINATION /libexec/git-core"
89+
90+ verify_lfs_contents " $GIT_LFS_FILE "
91+
8792 unzip -j $GIT_LFS_FILE -d " $SUBFOLDER " " */git-lfs"
8893
8994 if [[ ! -f " $SUBFOLDER /git-lfs" ]]; then
Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ GCM_URL="$(jq --raw-output ".\"git-credential-manager\".files[] | select(.arch =
6363source " $CURRENT_DIR /compute-checksum.sh"
6464# shellcheck source=script/check-static-linking.sh
6565source " $CURRENT_DIR /check-static-linking.sh"
66+ # shellcheck source=script/verify-lfs-contents.sh
67+ source " $CURRENT_DIR /verify-lfs-contents.sh"
6668
6769echo " -- Building vanilla curl at $CURL_INSTALL_DIR instead of distro-specific version"
6870
@@ -108,7 +110,10 @@ if [[ "$GIT_LFS_VERSION" ]]; then
108110 if [ " $COMPUTED_SHA256 " = " $GIT_LFS_CHECKSUM " ]; then
109111 echo " Git LFS: checksums match"
110112 SUBFOLDER=" $DESTINATION /libexec/git-core"
111- tar -xvf $GIT_LFS_FILE -C " $SUBFOLDER " --strip-components=1 --exclude=' *.sh' --exclude=" *.md"
113+
114+ verify_lfs_contents " $GIT_LFS_FILE "
115+
116+ tar -zxvf " $GIT_LFS_FILE " --strip-components=1 -C " $SUBFOLDER " --wildcards " */git-lfs"
112117
113118 if [[ ! -f " $SUBFOLDER /git-lfs" ]]; then
114119 echo " After extracting Git LFS the file was not found under libexec/git-core/"
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ GIT_FOR_WINDOWS_CHECKSUM=$(jq --raw-output ".git.packages[] | select(.arch == \"
2727CURRENT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
2828# shellcheck source=script/compute-checksum.sh
2929source " $CURRENT_DIR /compute-checksum.sh"
30+ # shellcheck source=script/verify-lfs-contents.sh
31+ source " $CURRENT_DIR /verify-lfs-contents.sh"
3032
3133mkdir -p " $DESTINATION "
3234
@@ -55,7 +57,10 @@ if [[ "$GIT_LFS_VERSION" ]]; then
5557 if [ " $COMPUTED_SHA256 " = " $GIT_LFS_CHECKSUM " ]; then
5658 echo " Git LFS: checksums match"
5759 SUBFOLDER=" $DESTINATION /$MINGW_DIR /libexec/git-core"
58- unzip -j $GIT_LFS_FILE -x ' *.md' -d " $SUBFOLDER "
60+
61+ verify_lfs_contents " $GIT_LFS_FILE "
62+
63+ unzip -j $GIT_LFS_FILE -d " $SUBFOLDER " " */git-lfs.exe"
5964
6065 if [[ ! -f " $SUBFOLDER /git-lfs.exe" ]]; then
6166 echo " After extracting Git LFS the file was not found under /mingw64/libexec/git-core/"
Original file line number Diff line number Diff line change 1+ #! /bin/bash -e
2+
3+ verify_lfs_contents () {
4+
5+ CONTENTS=" "
6+
7+ if [[ " $1 " == * .zip ]]; then
8+ CONTENTS=$( unzip -qql " $1 " )
9+ elif [[ " $1 " == * .tar.gz ]]; then
10+ CONTENTS=$( tar -tzf " $1 " )
11+ else
12+ echo " Unknown file type for $1 "
13+ exit 1
14+ fi
15+
16+ test -z " $CONTENTS " && {
17+ echo " Git LFS: found no contents in LFS archive, aborting..."
18+ exit 1
19+ }
20+
21+ TOPLEVEL=$( echo " $CONTENTS " | cut -d/ -f2 | sort | uniq | grep .)
22+
23+ # Sanity check to make sure we react if git-lfs starts adding more stuff to
24+ # their release packages. Note that this only looks that the top
25+ # (technically second) level folder so new stuff in the man folder won't
26+ # get caught here.
27+ # shellcheck disable=SC2015
28+ grep -qvE " ^(CHANGELOG\.md|README\.md|git-lfs(\.exe)?|install\.sh|man)$" <<< " $TOPLEVEL" && {
29+ echo " Git LFS: unexpected files in the LFS archive, aborting..."
30+ exit 1
31+ } || true
32+ }
You can’t perform that action at this time.
0 commit comments