Skip to content

Commit 48bed08

Browse files
committed
initial sysroot implementation
1 parent 2f58bfa commit 48bed08

File tree

3 files changed

+22
-36
lines changed

3 files changed

+22
-36
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,10 @@ jobs:
6666
run: npm run prettier
6767
- name: Build tools
6868
run: npm run check
69-
- name: Install extra dependencies for building Git on Ubuntu (x64)
70-
if: matrix.targetPlatform == 'ubuntu' && matrix.arch == 'x64'
69+
- name: Install ubuntu dependencies
70+
if: matrix.targetPlatform == 'ubuntu'
7171
run: |
72-
sudo apt-get update
73-
sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext
74-
- name: Install extra dependencies for building Git on Ubuntu (arm64)
75-
if: matrix.targetPlatform == 'ubuntu' && matrix.arch == 'arm64'
76-
run: |
77-
sudo sed -i "s/^deb/deb [arch=amd64,i386]/g" /etc/apt/sources.list
78-
echo "deb [arch=arm64,armhf] http://azure.ports.ubuntu.com/ $(lsb_release -s -c) main universe multiverse restricted" | sudo tee -a /etc/apt/sources.list
79-
echo "deb [arch=arm64,armhf] http://azure.ports.ubuntu.com/ $(lsb_release -s -c)-updates main universe multiverse restricted" | sudo tee -a /etc/apt/sources.list
80-
sudo dpkg --add-architecture arm64
81-
sudo apt-get update
82-
sudo apt-get install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu libcurl4-gnutls-dev:arm64 zlib1g-dev:arm64 libbrotli-dev:arm64 gettext
72+
sudo apt-get install -y debootstrap
8373
- name: Build
8474
shell: bash
8575
run: script/build.sh

script/build-ubuntu.sh

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,24 @@ if [[ -z "${CURL_INSTALL_DIR}" ]]; then
2020
exit 1
2121
fi
2222

23+
if [[ -z "${SYSROOT_DIR}" ]]; then
24+
echo "Required environment variable SYSROOT_DIR was not set"
25+
exit 1
26+
fi
27+
2328
case "$TARGET_ARCH" in
2429
"x64")
25-
# __GLIBC_MINOR__ is used as a feature test macro. Replace it with the
26-
# earliest supported version of glibc 2.17 as was previously the case when building on ubuntu-18.04
27-
sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "/usr/include/features.h"
28-
# fcntl64() was introduced in glibc 2.28. Make sure to use fcntl() instead.
29-
sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "/usr/include/fcntl.h"
3030
DEPENDENCY_ARCH="amd64"
31-
export CC="gcc"
31+
export CC="gcc --sysroot=$SYSROOT_DIR"
3232
STRIP="strip"
3333
HOST=""
3434
TARGET="" ;;
35-
"x86")
36-
DEPENDENCY_ARCH="x86"
37-
export CC="i686-linux-gnu-gcc"
38-
STRIP="i686-gnu-strip"
39-
HOST="--host=i686-linux-gnu"
40-
TARGET="--target=i686-linux-gnu" ;;
4135
"arm64")
42-
# __GLIBC_MINOR__ is used as a feature test macro. Replace it with the
43-
# earliest supported version of glibc 2.17 as was previously the case when building on ubuntu-18.04
44-
sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "/usr/aarch64-linux-gnu/include/features.h"
45-
# fcntl64() was introduced in glibc 2.28. Make sure to use fcntl() instead.
46-
sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "/usr/aarch64-linux-gnu/include/fcntl.h"
4736
DEPENDENCY_ARCH="arm64"
4837
export CC="aarch64-linux-gnu-gcc"
4938
STRIP="aarch64-linux-gnu-strip"
5039
HOST="--host=aarch64-linux-gnu"
5140
TARGET="--target=aarch64-linux-gnu" ;;
52-
"arm")
53-
DEPENDENCY_ARCH="arm"
54-
export CC="arm-linux-gnueabihf-gcc"
55-
STRIP="arm-linux-gnueabihf-strip"
56-
HOST="--host=arm-linux-gnueabihf"
57-
TARGET="--target=arm-linux-gnueabihf" ;;
5841
*)
5942
exit 1 ;;
6043
esac
@@ -70,11 +53,20 @@ source "$CURRENT_DIR/compute-checksum.sh"
7053
# shellcheck source=script/check-static-linking.sh
7154
source "$CURRENT_DIR/check-static-linking.sh"
7255

56+
echo " -- Setting up sysroot at $SYSROOT_DIR "
57+
sudo mkdir -p "$SYSROOT_DIR"
58+
sudo debootstrap --variant=buildd --arch amd64 \
59+
--include=libx11-dev,libxkbfile-dev,libfontconfig1-dev,libcurl4-gnutls-dev,libexpat1-dev,gettext \
60+
focal "$SYSROOT_DIR" http://archive.ubuntu.com/ubuntu/
61+
7362
echo " -- Building vanilla curl at $CURL_INSTALL_DIR instead of distro-specific version"
7463

7564
CURL_FILE_NAME="curl-7.68.0"
7665
CURL_FILE="$CURL_FILE_NAME.tar.gz"
7766

67+
sudo mkdir -p "$CURL_INSTALL_DIR" || exit 1
68+
sudo chown -R "$USER" "$CURL_INSTALL_DIR" || exit 1
69+
7870
cd /tmp || exit 1
7971
curl -LO "https://curl.haxx.se/download/$CURL_FILE"
8072
tar -xf $CURL_FILE
@@ -84,6 +76,9 @@ cd $CURL_FILE_NAME || exit 1
8476
./configure --prefix="$CURL_INSTALL_DIR" "$HOST" "$TARGET"
8577
make install
8678
)
79+
80+
CURL_CONFIG="$CURL_INSTALL_DIR/bin/curl-config"
81+
8782
echo " -- Building git at $SOURCE to $DESTINATION"
8883

8984
(

script/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ BASEDIR=$ROOT \
2323
SOURCE="$ROOT/git" \
2424
DESTINATION="/tmp/build/git" \
2525
CURL_INSTALL_DIR="/tmp/build/curl" \
26+
SYSROOT_DIR="/tmp/build/sysroot" \
2627
bash "$SCRIPT"

0 commit comments

Comments
 (0)