-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild-git.sh
More file actions
44 lines (34 loc) · 1.06 KB
/
build-git.sh
File metadata and controls
44 lines (34 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
set -xeuo pipefail
# Build git from source using official kernel.org tarballs
# Usage: ./build-git.sh [version]
# If version is not specified, fetches the latest release
GIT_VERSION=${1:-}
GIT_MIRROR=${GIT_MIRROR:-https://mirrors.edge.kernel.org/pub/software/scm/git}
# Install build dependencies
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
gettext \
libcurl4-gnutls-dev \
libexpat1-dev \
libssl-dev \
zlib1g-dev
# Determine version to install
if [ -z "${GIT_VERSION}" ]; then
echo "Fetching latest git version..."
GIT_VERSION=$(curl -fsSL "${GIT_MIRROR}/" | \
grep -oP 'git-\K[0-9]+\.[0-9]+\.[0-9]+(?=\.tar\.gz)' | \
sort -V | tail -1)
fi
echo "Building git version: ${GIT_VERSION}"
WORKDIR=$(mktemp -d)
cd "${WORKDIR}"
curl -fsSL "${GIT_MIRROR}/git-${GIT_VERSION}.tar.gz" | tar xz
cd "git-${GIT_VERSION}"
make prefix=/usr/local -j$(nproc) all
sudo make prefix=/usr/local DESTDIR=/opt/git-staging install
cd /
rm -rf "${WORKDIR}"