add git package (#63)
This commit is contained in:
179
git/build.sh
Executable file
179
git/build.sh
Executable file
@@ -0,0 +1,179 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="2.47.1"
|
||||||
|
OPENSSL_VERSION="openssl-3.4.1"
|
||||||
|
CURL_VERSION="curl-8_12_1"
|
||||||
|
ZLIB_VERSION="v1.3.1"
|
||||||
|
INSTALL_DIR="$DIR/git/install"
|
||||||
|
VERSION_FILE="$INSTALL_DIR/.version"
|
||||||
|
|
||||||
|
# Skip if already at correct version
|
||||||
|
if [ -f "$VERSION_FILE" ] && [ "$(cat "$VERSION_FILE")" = "$VERSION" ]; then
|
||||||
|
echo "git $VERSION already present, skipping."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
PLATFORM="$(uname -s)"
|
||||||
|
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||||
|
PREFIX="$DIR/build/prefix"
|
||||||
|
mkdir -p "$DIR/build"
|
||||||
|
|
||||||
|
# --- Build zlib (static) ---
|
||||||
|
if [ ! -d "zlib-src/.git" ]; then
|
||||||
|
rm -rf zlib-src
|
||||||
|
git clone --depth 1 https://github.com/madler/zlib.git zlib-src
|
||||||
|
fi
|
||||||
|
git -C zlib-src fetch --depth 1 origin "$ZLIB_VERSION"
|
||||||
|
git -C zlib-src checkout --force FETCH_HEAD
|
||||||
|
|
||||||
|
cd zlib-src
|
||||||
|
./configure --prefix="$PREFIX" --static
|
||||||
|
make -j"$NJOBS"
|
||||||
|
make install
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# --- Build OpenSSL (static) ---
|
||||||
|
if [ ! -d "openssl-src/.git" ]; then
|
||||||
|
rm -rf openssl-src
|
||||||
|
git clone --depth 1 https://github.com/openssl/openssl.git openssl-src
|
||||||
|
fi
|
||||||
|
git -C openssl-src fetch --depth 1 origin "$OPENSSL_VERSION"
|
||||||
|
git -C openssl-src checkout --force FETCH_HEAD
|
||||||
|
|
||||||
|
cd openssl-src
|
||||||
|
./Configure \
|
||||||
|
--prefix="$PREFIX" \
|
||||||
|
--libdir=lib \
|
||||||
|
no-shared \
|
||||||
|
no-tests \
|
||||||
|
no-docs
|
||||||
|
make -j"$NJOBS"
|
||||||
|
make install_sw
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# --- Build curl (static, with openssl+zlib) ---
|
||||||
|
if [ ! -d "curl-src/.git" ]; then
|
||||||
|
rm -rf curl-src
|
||||||
|
git clone --depth 1 https://github.com/curl/curl.git curl-src
|
||||||
|
fi
|
||||||
|
git -C curl-src fetch --depth 1 origin "$CURL_VERSION"
|
||||||
|
git -C curl-src checkout --force FETCH_HEAD
|
||||||
|
|
||||||
|
cd curl-src
|
||||||
|
autoreconf -fi
|
||||||
|
PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig" \
|
||||||
|
./configure \
|
||||||
|
--prefix="$PREFIX" \
|
||||||
|
--with-openssl="$PREFIX" \
|
||||||
|
--with-zlib="$PREFIX" \
|
||||||
|
--disable-shared \
|
||||||
|
--enable-static \
|
||||||
|
--disable-ldap \
|
||||||
|
--disable-rtsp \
|
||||||
|
--disable-dict \
|
||||||
|
--disable-telnet \
|
||||||
|
--disable-tftp \
|
||||||
|
--disable-pop3 \
|
||||||
|
--disable-imap \
|
||||||
|
--disable-smb \
|
||||||
|
--disable-smtp \
|
||||||
|
--disable-gopher \
|
||||||
|
--disable-mqtt \
|
||||||
|
--disable-manual \
|
||||||
|
--disable-docs \
|
||||||
|
--without-libpsl \
|
||||||
|
--without-brotli \
|
||||||
|
--without-zstd \
|
||||||
|
--without-libidn2 \
|
||||||
|
--without-nghttp2 \
|
||||||
|
--without-librtmp
|
||||||
|
make -j"$NJOBS"
|
||||||
|
make install
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# --- Build git (with static curl+openssl+zlib) ---
|
||||||
|
if [ ! -d "git-src/.git" ]; then
|
||||||
|
rm -rf git-src
|
||||||
|
git clone --depth 1 https://github.com/git/git.git git-src
|
||||||
|
fi
|
||||||
|
git -C git-src fetch --depth 1 origin "v${VERSION}"
|
||||||
|
git -C git-src checkout --force FETCH_HEAD
|
||||||
|
|
||||||
|
# Gather static link flags for curl's dependencies
|
||||||
|
CURL_LDFLAGS="-L$PREFIX/lib -lcurl -lssl -lcrypto -lz"
|
||||||
|
if [ "$PLATFORM" = "Linux" ]; then
|
||||||
|
CURL_LDFLAGS="$CURL_LDFLAGS -lpthread -ldl"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd git-src
|
||||||
|
make prefix="$PREFIX" \
|
||||||
|
RUNTIME_PREFIX=YesPlease \
|
||||||
|
NO_GETTEXT=YesPlease \
|
||||||
|
NO_TCLTK=YesPlease \
|
||||||
|
NO_PERL=YesPlease \
|
||||||
|
NO_PYTHON=YesPlease \
|
||||||
|
NO_EXPAT=YesPlease \
|
||||||
|
INSTALL_SYMLINKS=1 \
|
||||||
|
CURLDIR="$PREFIX" \
|
||||||
|
CURL_LDFLAGS="$CURL_LDFLAGS" \
|
||||||
|
ZLIB_PATH="$PREFIX" \
|
||||||
|
-j"$NJOBS" \
|
||||||
|
all
|
||||||
|
make prefix="$PREFIX" \
|
||||||
|
RUNTIME_PREFIX=YesPlease \
|
||||||
|
NO_GETTEXT=YesPlease \
|
||||||
|
NO_TCLTK=YesPlease \
|
||||||
|
NO_PERL=YesPlease \
|
||||||
|
NO_PYTHON=YesPlease \
|
||||||
|
NO_EXPAT=YesPlease \
|
||||||
|
INSTALL_SYMLINKS=1 \
|
||||||
|
CURLDIR="$PREFIX" \
|
||||||
|
CURL_LDFLAGS="$CURL_LDFLAGS" \
|
||||||
|
ZLIB_PATH="$PREFIX" \
|
||||||
|
install
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# Assemble the package install directory
|
||||||
|
# Only copy real files from libexec to avoid bloating the wheel with
|
||||||
|
# copies of the main git binary (builtin commands are symlinks to git)
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR/bin" "$INSTALL_DIR/libexec/git-core"
|
||||||
|
|
||||||
|
# Main binary
|
||||||
|
cp "$PREFIX/bin/git" "$INSTALL_DIR/bin/"
|
||||||
|
|
||||||
|
# libexec/git-core: copy real files, resolve non-git symlinks, skip git symlinks
|
||||||
|
cd "$PREFIX/libexec/git-core"
|
||||||
|
for f in *; do
|
||||||
|
if [ -L "$f" ]; then
|
||||||
|
target="$(readlink "$f")"
|
||||||
|
# Skip symlinks to the main git binary (these are builtins)
|
||||||
|
case "$target" in
|
||||||
|
git|../../bin/git) continue ;;
|
||||||
|
esac
|
||||||
|
# Resolve other symlinks (e.g., git-remote-https -> git-remote-http)
|
||||||
|
cp -L "$f" "$INSTALL_DIR/libexec/git-core/$f"
|
||||||
|
elif [ -f "$f" ]; then
|
||||||
|
cp "$f" "$INSTALL_DIR/libexec/git-core/$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# Copy git binary into libexec for builtin resolution
|
||||||
|
cp "$PREFIX/bin/git" "$INSTALL_DIR/libexec/git-core/git"
|
||||||
|
|
||||||
|
# Templates
|
||||||
|
cp -r "$PREFIX/share" "$INSTALL_DIR/"
|
||||||
|
|
||||||
|
# Strip binaries
|
||||||
|
strip "$INSTALL_DIR/bin/git" "$INSTALL_DIR/libexec/git-core/git" 2>/dev/null || true
|
||||||
|
find "$INSTALL_DIR/libexec/git-core" -maxdepth 1 -type f -perm /111 ! -name "*.sh" -exec strip {} \; 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "$VERSION" > "$VERSION_FILE"
|
||||||
|
|
||||||
|
echo "Installed git to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
17
git/git/__init__.py
Normal file
17
git/git/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
BIN_DIR = os.path.join(DIR, "bin")
|
||||||
|
|
||||||
|
|
||||||
|
def _run():
|
||||||
|
binary = os.path.join(BIN_DIR, "git")
|
||||||
|
os.execvp(binary, [binary] + sys.argv[1:])
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
import subprocess
|
||||||
|
binary = os.path.join(BIN_DIR, "git")
|
||||||
|
subprocess.run([binary, "--version"], check=True)
|
||||||
|
subprocess.run([binary, "ls-remote", "https://github.com/commaai/openpilot.git", "HEAD"], check=True)
|
||||||
18
git/pyproject.toml
Normal file
18
git/pyproject.toml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "git"
|
||||||
|
version = "2.47.1"
|
||||||
|
description = "Git distributed version control system"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
git = "git:_run"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["git*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
git = ["install/**/*"]
|
||||||
58
git/setup.py
Normal file
58
git/setup.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildGit(build_py):
|
||||||
|
"""Run build.sh to build git before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildGit}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
@@ -6,6 +6,7 @@ members = [
|
|||||||
"eigen",
|
"eigen",
|
||||||
"ffmpeg",
|
"ffmpeg",
|
||||||
"gcc-arm-none-eabi",
|
"gcc-arm-none-eabi",
|
||||||
|
"git",
|
||||||
"git-lfs",
|
"git-lfs",
|
||||||
"imgui",
|
"imgui",
|
||||||
"json11",
|
"json11",
|
||||||
|
|||||||
4
setup.sh
4
setup.sh
@@ -17,10 +17,10 @@ run_as_root() {
|
|||||||
if [ "$(uname)" = "Darwin" ]; then
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
brew install nasm pkg-config ccache
|
brew install nasm pkg-config ccache
|
||||||
elif command -v dnf &>/dev/null; then
|
elif command -v dnf &>/dev/null; then
|
||||||
dnf install -y nasm cmake gcc-c++ pkgconfig git perl-IPC-Cmd ccache
|
dnf install -y nasm cmake gcc-c++ pkgconfig git perl-IPC-Cmd ccache autoconf automake libtool
|
||||||
elif command -v apt-get &>/dev/null; then
|
elif command -v apt-get &>/dev/null; then
|
||||||
run_as_root apt-get update
|
run_as_root apt-get update
|
||||||
run_as_root apt-get install -y nasm cmake g++ pkg-config curl ccache
|
run_as_root apt-get install -y nasm cmake g++ pkg-config curl ccache autoconf automake libtool
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v uv &>/dev/null; then
|
if ! command -v uv &>/dev/null; then
|
||||||
|
|||||||
Reference in New Issue
Block a user