build git binary

This commit is contained in:
Nikita Galaiko 2023-02-02 18:21:55 +01:00
parent b42db79501
commit ab7f39353f
No known key found for this signature in database
GPG Key ID: EBAB54E845BA519D
4 changed files with 99 additions and 0 deletions

View File

@ -5,6 +5,7 @@
## setup
```bash
$ cd src-tauri/binaries && make
$ pnpm install
```

1
src-tauri/binaries/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
git-aarch64-apple-darwin

View File

@ -0,0 +1,7 @@
VERSION=2.39.1
ARCH=$(shell rustc -Vv | grep host | cut -f2 -d' ')
git-$(ARCH):
./build.sh --dist "$(shell pwd)/git-$(ARCH)" --version "$(VERSION)"
all: git-$(ARCH)

90
src-tauri/binaries/build.sh Executable file
View File

@ -0,0 +1,90 @@
#!/bin/bash
set -o errexit
set -o pipefail
PWD="$(dirname $(readlink -f -- $0))"
DIST="$PWD/git"
VERSION="2.39.1"
function help() {
echo "Usage: $0 <flags>"
echo
echo "flags:"
echo " --version git version to install. (default: $VERSION)"
echo " --dist directory to install binaries to. (default: $DIST)"
echo " --help display this message."
}
function error() {
echo "error: $@"
echo
help
exit 1
}
function info() {
echo "$@"
}
while [[ $# -gt 0 ]]; do
case "$1" in
--help)
help
exit 1
;;
--version)
VERSION="$2"
shift
shift
;;
--dist)
DIST="$2"
shift
shift
;;
*)
error "unknown flag $1"
;;
esac
done
function install_dependencies() {
case "$(uname -s)" in
Darwin)
if [[ -z "$(brew ls --versions gettext)" ]]; then
brew install gettext
fi
if [[ -z "$(brew ls --versions automake)" ]]; then
brew install automake
fi
;;
esac
}
function configure() {
case "$(uname -s)" in
Darwin)
make configure
./configure --prefix=/opt/homebrew
;;
esac
}
TMP_DIR=$(mktemp -d -t ci-XXXXXXXXXX)
pushd "$TMP_DIR"
install_dependencies
curl --location --remote-name "https://www.kernel.org/pub/software/scm/git/git-$VERSION.tar.gz"
tar -xzf "git-$VERSION.tar.gz"
cd "git-$VERSION"
configure
make
mv 'git' "$DIST"
popd
rm -rf $TMP_DIR