Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only package the bits from LFS that we really need #519

Merged
merged 12 commits into from
Jan 20, 2025
Merged
5 changes: 5 additions & 0 deletions script/build-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ GIT_LFS_FILENAME="$(jq --raw-output ".\"git-lfs\".files[] | select(.arch == \"$D

# shellcheck source=script/compute-checksum.sh
source "$CURRENT_DIR/compute-checksum.sh"
# shellcheck source=script/verify-lfs-contents.sh
source "$CURRENT_DIR/verify-lfs-contents.sh"

echo "-- Building git at $SOURCE to $DESTINATION"

Expand Down Expand Up @@ -84,6 +86,9 @@ if [[ "$GIT_LFS_VERSION" ]]; then
if [ "$COMPUTED_SHA256" = "$GIT_LFS_CHECKSUM" ]; then
echo "Git LFS: checksums match"
SUBFOLDER="$DESTINATION/libexec/git-core"

verify_lfs_contents "$GIT_LFS_FILE"

unzip -j $GIT_LFS_FILE -d "$SUBFOLDER" "*/git-lfs"

if [[ ! -f "$SUBFOLDER/git-lfs" ]]; then
Expand Down
7 changes: 6 additions & 1 deletion script/build-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ GCM_URL="$(jq --raw-output ".\"git-credential-manager\".files[] | select(.arch =
source "$CURRENT_DIR/compute-checksum.sh"
# shellcheck source=script/check-static-linking.sh
source "$CURRENT_DIR/check-static-linking.sh"
# shellcheck source=script/verify-lfs-contents.sh
source "$CURRENT_DIR/verify-lfs-contents.sh"

echo " -- Building vanilla curl at $CURL_INSTALL_DIR instead of distro-specific version"

Expand Down Expand Up @@ -108,7 +110,10 @@ if [[ "$GIT_LFS_VERSION" ]]; then
if [ "$COMPUTED_SHA256" = "$GIT_LFS_CHECKSUM" ]; then
echo "Git LFS: checksums match"
SUBFOLDER="$DESTINATION/libexec/git-core"
tar -xvf $GIT_LFS_FILE -C "$SUBFOLDER" --strip-components=1 --exclude='*.sh' --exclude="*.md"

verify_lfs_contents "$GIT_LFS_FILE"

tar -zxvf "$GIT_LFS_FILE" --strip-components=1 -C "$SUBFOLDER" --wildcards "*/git-lfs"

if [[ ! -f "$SUBFOLDER/git-lfs" ]]; then
echo "After extracting Git LFS the file was not found under libexec/git-core/"
Expand Down
7 changes: 6 additions & 1 deletion script/build-win32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ GIT_FOR_WINDOWS_CHECKSUM=$(jq --raw-output ".git.packages[] | select(.arch == \"
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# shellcheck source=script/compute-checksum.sh
source "$CURRENT_DIR/compute-checksum.sh"
# shellcheck source=script/verify-lfs-contents.sh
source "$CURRENT_DIR/verify-lfs-contents.sh"

mkdir -p "$DESTINATION"

Expand Down Expand Up @@ -55,7 +57,10 @@ if [[ "$GIT_LFS_VERSION" ]]; then
if [ "$COMPUTED_SHA256" = "$GIT_LFS_CHECKSUM" ]; then
echo "Git LFS: checksums match"
SUBFOLDER="$DESTINATION/$MINGW_DIR/libexec/git-core"
unzip -j $GIT_LFS_FILE -x '*.md' -d "$SUBFOLDER"

verify_lfs_contents "$GIT_LFS_FILE"

unzip -j $GIT_LFS_FILE -d "$SUBFOLDER" "*/git-lfs.exe"

if [[ ! -f "$SUBFOLDER/git-lfs.exe" ]]; then
echo "After extracting Git LFS the file was not found under /mingw64/libexec/git-core/"
Expand Down
32 changes: 32 additions & 0 deletions script/verify-lfs-contents.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash -e

verify_lfs_contents() {

CONTENTS=""

if [[ "$1" == *.zip ]]; then
CONTENTS=$(unzip -qql "$1")
elif [[ "$1" == *.tar.gz ]]; then
CONTENTS=$(tar -tzf "$1")
else
echo "Unknown file type for $1"
exit 1
fi

test -z "$CONTENTS" && {
echo "Git LFS: found no contents in LFS archive, aborting..."
exit 1
}

TOPLEVEL=$(echo "$CONTENTS" | cut -d/ -f2 | sort | uniq | grep .)

# Sanity check to make sure we react if git-lfs starts adding more stuff to
# their release packages. Note that this only looks that the top
# (technically second) level folder so new stuff in the man folder won't
# get caught here.
# shellcheck disable=SC2015
grep -qvE "^(CHANGELOG\.md|README\.md|git-lfs(\.exe)?|install\.sh|man)$" <<< "$TOPLEVEL" && {
echo "Git LFS: unexpected files in the LFS archive, aborting..."
exit 1
} || true
}
Loading