Meta: Improve build compatibility with non-GNU userspaces
We depend on GNU-specific du switch `--apparent-size`. Busybox has this implemented, but as `-b` instead. Another part of the build system uses `cp --preserve=timestamps`. This can be replaced by `rsync -t`, and rsync is already used through the file. Thanks to those changes, Serenity can be built on a Busybox system, without GNU coreutils.
This commit is contained in:
parent
fddbd11baa
commit
d7644d1d86
Notes:
sideshowbarker
2024-07-17 05:19:06 +09:00
Author: https://github.com/sdomi Commit: https://github.com/SerenityOS/serenity/commit/d7644d1d86 Pull-request: https://github.com/SerenityOS/serenity/pull/19877 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/fdellwing Reviewed-by: https://github.com/linusg ✅
6 changed files with 23 additions and 56 deletions
|
@ -35,14 +35,6 @@ if [ -z $syslinux_dir ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
disk_usage() {
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
du -sm "$1" | cut -f1
|
||||
else
|
||||
du -sm --apparent-size "$1" | cut -f1
|
||||
fi
|
||||
}
|
||||
|
||||
DISK_SIZE=$(($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + 300))
|
||||
|
||||
echo "setting up disk image..."
|
||||
|
|
|
@ -34,14 +34,6 @@ if [ -z "$grub" ]; then
|
|||
fi
|
||||
echo "using grub-install at ${grub}"
|
||||
|
||||
disk_usage() {
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
du -sm "$1" | cut -f1
|
||||
else
|
||||
du -sm --apparent-size "$1" | cut -f1
|
||||
fi
|
||||
}
|
||||
|
||||
DISK_SIZE=$(($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + 300))
|
||||
|
||||
echo "setting up disk image..."
|
||||
|
|
|
@ -33,14 +33,6 @@ else
|
|||
: "${SUDO_UID:=0}" "${SUDO_GID:=0}"
|
||||
fi
|
||||
|
||||
disk_usage() {
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
du -sm "$1" | cut -f1
|
||||
else
|
||||
du -sm --apparent-size "$1" | cut -f1
|
||||
fi
|
||||
}
|
||||
|
||||
DISK_SIZE=$(($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + 300))
|
||||
|
||||
echo "setting up disk image..."
|
||||
|
|
|
@ -32,27 +32,10 @@ fi
|
|||
# Prepend the toolchain qemu directory so we pick up QEMU from there
|
||||
PATH="$SCRIPT_DIR/../Toolchain/Local/qemu/bin:$PATH"
|
||||
|
||||
# We depend on GNU coreutils du for the --apparent-size extension.
|
||||
# GNU coreutils is a build dependency.
|
||||
if command -v gdu > /dev/null 2>&1 && gdu --version | grep -q "GNU coreutils"; then
|
||||
GNUDU="gdu"
|
||||
else
|
||||
GNUDU="du"
|
||||
fi
|
||||
|
||||
disk_usage() {
|
||||
# shellcheck disable=SC2003,SC2307
|
||||
expr "$(${GNUDU} -sk --apparent-size "$1" | cut -f1)"
|
||||
}
|
||||
|
||||
inode_usage() {
|
||||
find "$1" | wc -l
|
||||
}
|
||||
|
||||
INODE_SIZE=128
|
||||
INODE_COUNT=$(($(inode_usage "$SERENITY_SOURCE_DIR/Base") + $(inode_usage Root)))
|
||||
INODE_COUNT=$((INODE_COUNT + 2000)) # Some additional inodes for toolchain files, could probably also be calculated
|
||||
DISK_SIZE_BYTES=$((($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root)) * 1024))
|
||||
DISK_SIZE_BYTES=$((($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) ) * 1024 * 1024))
|
||||
DISK_SIZE_BYTES=$((DISK_SIZE_BYTES + (INODE_COUNT * INODE_SIZE)))
|
||||
|
||||
if [ -z "$SERENITY_DISK_SIZE_BYTES" ]; then
|
||||
|
|
|
@ -8,15 +8,6 @@ utmp_gid=5
|
|||
window_uid=13
|
||||
window_gid=13
|
||||
|
||||
CP="cp"
|
||||
|
||||
# cp on macOS and BSD systems do not support the --preserve= option.
|
||||
# gcp comes with coreutils, which is already a dependency.
|
||||
OS="$(uname -s)"
|
||||
if [ "$OS" = "Darwin" ] || echo "$OS" | grep -qe 'BSD$'; then
|
||||
CP="gcp"
|
||||
fi
|
||||
|
||||
die() {
|
||||
echo "die: $*"
|
||||
exit 1
|
||||
|
@ -45,13 +36,13 @@ SERENITY_ARCH="${SERENITY_ARCH:-x86_64}"
|
|||
|
||||
if [ "$SERENITY_TOOLCHAIN" = "Clang" ]; then
|
||||
TOOLCHAIN_DIR="$SERENITY_SOURCE_DIR"/Toolchain/Local/clang/
|
||||
$CP --preserve=timestamps "$TOOLCHAIN_DIR"/lib/"$SERENITY_ARCH"-pc-serenity/* mnt/usr/lib
|
||||
rsync -aH --update -t "$TOOLCHAIN_DIR"/lib/"$SERENITY_ARCH"-pc-serenity/* mnt/usr/lib
|
||||
mkdir -p mnt/usr/include/"$SERENITY_ARCH"-pc-serenity
|
||||
$CP --preserve=timestamps -r "$TOOLCHAIN_DIR"/include/c++ mnt/usr/include
|
||||
$CP --preserve=timestamps -r "$TOOLCHAIN_DIR"/include/"$SERENITY_ARCH"-pc-serenity/c++ mnt/usr/include/"$SERENITY_ARCH"-pc-serenity
|
||||
rsync -aH --update -t -r "$TOOLCHAIN_DIR"/include/c++ mnt/usr/include
|
||||
rsync -aH --update -t -r "$TOOLCHAIN_DIR"/include/"$SERENITY_ARCH"-pc-serenity/c++ mnt/usr/include/"$SERENITY_ARCH"-pc-serenity
|
||||
else
|
||||
$CP --preserve=timestamps -r "$SERENITY_SOURCE_DIR"/Toolchain/Local/"$SERENITY_ARCH"/"$SERENITY_ARCH"-pc-serenity/lib/* mnt/usr/lib
|
||||
$CP --preserve=timestamps -r "$SERENITY_SOURCE_DIR"/Toolchain/Local/"$SERENITY_ARCH"/"$SERENITY_ARCH"-pc-serenity/include/c++ mnt/usr/include
|
||||
rsync -aH --update -t -r "$SERENITY_SOURCE_DIR"/Toolchain/Local/"$SERENITY_ARCH"/"$SERENITY_ARCH"-pc-serenity/lib/* mnt/usr/lib
|
||||
rsync -aH --update -t -r "$SERENITY_SOURCE_DIR"/Toolchain/Local/"$SERENITY_ARCH"/"$SERENITY_ARCH"-pc-serenity/include/c++ mnt/usr/include
|
||||
fi
|
||||
|
||||
# If umask was 027 or similar when the repo was cloned,
|
||||
|
|
|
@ -82,3 +82,20 @@ get_number_of_processing_units() {
|
|||
|
||||
($number_of_processing_units)
|
||||
}
|
||||
|
||||
# We depend on GNU coreutils du for the --apparent-size extension.
|
||||
# GNU coreutils is a build dependency.
|
||||
if command -v gdu > /dev/null 2>&1 && gdu --version | grep -q "GNU coreutils"; then
|
||||
GNUDU="gdu"
|
||||
else
|
||||
GNUDU="du"
|
||||
fi
|
||||
|
||||
disk_usage() {
|
||||
# shellcheck disable=SC2003,SC2307
|
||||
expr "$(${GNUDU} -sbm "$1" | cut -f1)"
|
||||
}
|
||||
|
||||
inode_usage() {
|
||||
find "$1" | wc -l
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue