Compare commits

...

4 Commits

Author SHA1 Message Date
Bananymous 83e5cb81e8 ports: Cleanup projects using cmake
There is no need to use $BANAN_CMAKE because our own toolchain directory
is added to path.
2026-01-10 19:32:48 +02:00
Bananymous 7a49a0d986 BuildSystem: Install meson as part of the toolchain
Debian based distros have meson 0.6x in their repositories. These cause
some obscure error messages when building meson based ports.
2026-01-10 19:32:48 +02:00
Bananymous 78cd054d59 BuildSystem: Write my own disk image perm updater
If user's bash does not have bultin stat, updating image perms was
terribly slow. This patch adds a simple c program that does the job
without exec overhead
2026-01-10 17:57:21 +02:00
Bananymous d33a8eac9c ports/mesa: Download prebuilt llvm instead of building it
compiling llvm takes too long :D
2026-01-10 16:40:12 +02:00
20 changed files with 203 additions and 108 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
build/
base/
script/fakeroot-context
tools/update-image-perms

View File

@ -6,7 +6,7 @@ DOWNLOAD_URL="https://github.com/libsdl-org/SDL/releases/download/release-$VERSI
DEPENDENCIES=('mesa' 'libiconv')
configure() {
$BANAN_CMAKE --fresh -S . -B build -G Ninja \
cmake --fresh -S . -B build -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-DCMAKE_INSTALL_PREFIX='/usr' \
-DCMAKE_BUILD_TYPE=Release \
@ -16,9 +16,9 @@ configure() {
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
}

View File

@ -6,7 +6,7 @@ DOWNLOAD_URL="https://github.com/libsdl-org/SDL_image/releases/download/release-
DEPENDENCIES=('SDL2' 'libpng' 'libjpeg' 'libtiff' 'libwebp')
configure() {
$BANAN_CMAKE --fresh -S . -B build -G Ninja \
cmake --fresh -S . -B build -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-DCMAKE_INSTALL_PREFIX='/usr' \
-DCMAKE_BUILD_TYPE=Release \
@ -15,9 +15,9 @@ configure() {
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
}

View File

@ -6,7 +6,7 @@ DOWNLOAD_URL="https://github.com/libsdl-org/SDL_mixer/releases/download/release-
DEPENDENCIES=('SDL2' 'timidity')
configure() {
$BANAN_CMAKE --fresh -S . -B build -G Ninja \
cmake --fresh -S . -B build -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-DCMAKE_INSTALL_PREFIX='/usr' \
-DCMAKE_BUILD_TYPE=Release \
@ -19,9 +19,9 @@ configure() {
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
}

View File

@ -7,11 +7,8 @@ TAR_CONTENT="SuperTux-v$VERSION-Source"
DEPENDENCIES=('boost' 'SDL2' 'SDL2_image' 'curl' 'openal-soft' 'libvorbis' 'freetype' 'physfs' 'glm')
configure() {
mkdir -p build
pushd build
$BANAN_CMAKE \
cmake --fresh -B build -S . -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-G Ninja --fresh .. \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DINSTALL_SUBDIR_BIN=bin \
@ -19,14 +16,13 @@ configure() {
-DENABLE_OPENGL=OFF \
-DENABLE_BOOST_STATIC_LIBS=ON \
|| exit 1
popd
# crashes in `std::ostream::sentry::sentry(std::ostream&)` with shared boost
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
}

View File

@ -7,7 +7,7 @@ TAR_CONTENT="SuperTuxKart-$VERSION-src"
DEPENDENCIES=('SDL2' 'curl' 'openal-soft' 'freetype' 'harfbuzz' 'libvorbis' 'libjpeg' 'libpng' 'zlib')
configure() {
$BANAN_CMAKE -B build -S . -G Ninja --fresh \
cmake --fresh -B build -S . -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
@ -20,9 +20,9 @@ configure() {
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
}

View File

@ -6,9 +6,8 @@ DOWNLOAD_URL="https://github.com/Kitware/CMake/releases/download/v$VERSION/cmake
DEPENDENCIES=('openssl' 'libuv' 'make' 'bash')
configure() {
$BANAN_CMAKE \
cmake --fresh -B build -S . -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-B build -GNinja --fresh \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_USE_OPENSSL=ON \
-DCMAKE_USE_SYSTEM_LIBUV=ON \
@ -18,10 +17,10 @@ configure() {
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
cp $BANAN_TOOLCHAIN_DIR/cmake-platform/* $BANAN_SYSROOT/usr/share/cmake-3.26/Modules/Platform/
}

View File

@ -5,9 +5,8 @@ VERSION='1.0.2'
DOWNLOAD_URL="https://github.com/g-truc/glm/archive/refs/tags/$VERSION.tar.gz#19edf2e860297efab1c74950e6076bf4dad9de483826bc95e2e0f2c758a43f65"
configure() {
$BANAN_CMAKE \
cmake --fresh -B build -S . -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-B build -G Ninja --fresh . \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DGLM_BUILD_TESTS=OFF \
@ -15,9 +14,9 @@ configure() {
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
}

View File

@ -6,18 +6,17 @@ DOWNLOAD_URL="https://dist.libuv.org/dist/v$VERSION/libuv-v$VERSION.tar.gz#5f055
TAR_CONTENT="libuv-v$VERSION"
configure() {
$BANAN_CMAKE \
cmake --fresh -B build -S . -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-B build -GNinja --fresh \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_TESTING=OFF \
. || exit 1
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
}

View File

@ -9,7 +9,7 @@ DEPENDENCIES=('zlib' 'zstd')
configure() {
unset CC CXX LD
$BANAN_CMAKE -B build -S llvm -G Ninja \
cmake --fresh -B build -S llvm -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
@ -24,7 +24,7 @@ configure() {
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {

View File

@ -16,15 +16,24 @@ CONFIGURE_OPTIONS=(
pre_configure() {
llvm_version='20.1.8'
llvm_root="$(realpath ../../llvm)/llvm-$llvm_version-$BANAN_ARCH"
llvm_lib="$llvm_root/build/lib"
llvm_dir_name="llvm-banan_os-$llvm_version-$BANAN_ARCH"
if [ ! -d "$llvm_lib" ]; then
pushd ../../llvm >/dev/null || exit 1
./build.sh || exit 1
popd >/dev/null
if [ ! -d "../$llvm_dir_name" ]; then
pushd ..
if [ ! -f "$llvm_dir_name.tar.gz" ]; then
wget "https://bananymous.com/files/$llvm_dir_name.tar.gz" || exit 1
fi
tar xf "$llvm_dir_name.tar.gz" || exit 1
popd
fi
llvm_abs_path=$(realpath ../$llvm_dir_name || exit 1)
llvm_abs_lib="$llvm_abs_path/lib"
llvm_abs_inc="$llvm_abs_path/include"
mkdir -p subprojects/llvm
wrap_file='subprojects/llvm/meson.build'
@ -33,9 +42,9 @@ pre_configure() {
echo "cpp = meson.get_compiler('cpp')" >>$wrap_file
echo "" >>$wrap_file
echo "_deps = []" >>$wrap_file
echo "_search = '$llvm_lib'" >>$wrap_file
echo "_search = '$llvm_abs_lib'" >>$wrap_file
echo "foreach d : [" >>$wrap_file
for path in $llvm_lib/libLLVM*.a; do
for path in $llvm_abs_lib/libLLVM*.a; do
name=$(basename $path)
echo " '${name:3:-2}'," >>$wrap_file
done
@ -45,8 +54,7 @@ pre_configure() {
echo "" >>$wrap_file
echo "dep_llvm = declare_dependency(" >>$wrap_file
echo " include_directories : include_directories(" >>$wrap_file
echo " '$llvm_root/llvm/include'," >>$wrap_file
echo " '$llvm_root/build/include'," >>$wrap_file
echo " '$llvm_abs_inc'," >>$wrap_file
echo " )," >>$wrap_file
echo " dependencies : _deps," >>$wrap_file
echo " version : '$llvm_version'," >>$wrap_file

View File

@ -6,7 +6,7 @@ DOWNLOAD_URL="https://github.com/kcat/openal-soft/archive/refs/tags/$VERSION.tar
DEPENDENCIES=('SDL2' 'zlib' 'libsndfile')
configure() {
$BANAN_CMAKE -B build -S . -G Ninja --fresh \
cmake --fresh -B build -S . -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
@ -17,9 +17,9 @@ configure() {
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
}

View File

@ -6,9 +6,8 @@ DOWNLOAD_URL="https://github.com/icculus/physfs/archive/refs/tags/release-$VERSI
TAR_CONTENT="physfs-release-$VERSION"
configure() {
$BANAN_CMAKE \
cmake --fresh -B build -S . -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-B build -G Ninja --fresh . \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DPHYSFS_BUILD_TEST=ON \
@ -17,9 +16,9 @@ configure() {
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
}

View File

@ -9,17 +9,16 @@ DEPENDENCIES=('SDL2' 'glu')
configure() {
sed -i 's/CMAKE_INSTALL_FULL_DATAROOTDIR/CMAKE_INSTALL_FULL_DATADIR/' CMakeLists.txt
$BANAN_CMAKE \
cmake --fresh -B build -S . -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
--fresh -GNinja -S . -B build \
-DCMAKE_INSTALL_PREFIX="$BANAN_SYSROOT/usr" \
-DSDL2_INCLUDE_DIR="$BANAN_SYSROOT/usr/include/SDL2"
}
build() {
$BANAN_CMAKE --build build || exit 1
cmake --build build || exit 1
}
install() {
$BANAN_CMAKE --install build || exit 1
cmake --install build || exit 1
}

View File

@ -5,16 +5,16 @@ VERSION='1.5.7'
DOWNLOAD_URL="https://github.com/facebook/zstd/releases/download/v$VERSION/zstd-$VERSION.tar.gz#eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3"
configure() {
$BANAN_CMAKE -B _build -S build/cmake -G Ninja \
cmake --fresh -B _build -S build/cmake -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-DCMAKE_INSTALL_PREFIX=/usr \
|| exit 1
}
build() {
$BANAN_CMAKE --build _build ||exit 1
cmake --build _build ||exit 1
}
install() {
$BANAN_CMAKE --install _build ||exit 1
cmake --install _build ||exit 1
}

View File

@ -42,9 +42,17 @@ build_toolchain () {
$BANAN_TOOLCHAIN_DIR/build.sh
}
build_tools() {
perm_tool="$BANAN_TOOLS_DIR/update-image-perms"
if [ ! -f "$perm_tool" ] || [ "$perm_tool" -ot "$perm_tool.c" ]; then
gcc -O2 -Wall -Wextra -Werror -o "$perm_tool" "$perm_tool.c" || exit 1
fi
}
create_image () {
build_target all
build_target install
build_tools
$BANAN_SCRIPT_DIR/image.sh "$1"
}

View File

@ -19,6 +19,8 @@ export BANAN_BUILD_DIR="$BANAN_ROOT_DIR/build"
export BANAN_PORT_DIR="$BANAN_ROOT_DIR/ports"
export BANAN_TOOLS_DIR="$BANAN_ROOT_DIR/tools"
export BANAN_SYSROOT="$BANAN_BUILD_DIR/sysroot"
export BANAN_FAKEROOT="$BANAN_BUILD_DIR/fakeroot-context"

View File

@ -20,57 +20,38 @@ if [ -z $BANAN_BUILD_DIR ]; then
exit 1
fi
if [ "$1" == "full" ] || [ ! -f $BANAN_DISK_IMAGE_PATH ]; then
$BANAN_SCRIPT_DIR/image-create.sh || exit 1
if [ "$1" == "full" ] || [ ! -f "$BANAN_DISK_IMAGE_PATH" ]; then
"$BANAN_SCRIPT_DIR/image-create.sh" || exit 1
fi
set -u
MOUNT_DIR="$BANAN_BUILD_DIR/mount"
mkdir -p $MOUNT_DIR
mkdir -p "$MOUNT_DIR"
LOOP_DEV="$(sudo losetup --show -Pf $BANAN_DISK_IMAGE_PATH || exit 1)"
LOOP_DEV="$(sudo losetup --show -Pf "$BANAN_DISK_IMAGE_PATH" || exit 1)"
ROOT_PARTITION="${LOOP_DEV}p2"
if [ ! -b $ROOT_PARTITION ]; then
if [ ! -b "$ROOT_PARTITION" ]; then
echo "Failed to probe partitions for banan disk image." >&2
sudo losetup -d $LOOP_DEV
sudo losetup -d "$LOOP_DEV"
exit 1
fi
if sudo mount $ROOT_PARTITION $MOUNT_DIR; then
if sudo mount "$ROOT_PARTITION" "$MOUNT_DIR"; then
if (($BANAN_INITRD)); then
fakeroot -i $BANAN_FAKEROOT tar -C $BANAN_SYSROOT -cf $BANAN_SYSROOT.initrd .
fakeroot -i "$BANAN_FAKEROOT" tar -C "$BANAN_SYSROOT" -cf "$BANAN_SYSROOT.initrd" .
sudo mkdir -p $MOUNT_DIR/boot
sudo cp $BANAN_BUILD_DIR/kernel/banan-os.kernel $MOUNT_DIR/boot/banan-os.kernel
sudo mv $BANAN_SYSROOT.initrd $MOUNT_DIR/boot/banan-os.initrd
sudo mkdir -p "$MOUNT_DIR/boot"
sudo cp "$BANAN_BUILD_DIR/kernel/banan-os.kernel" "$MOUNT_DIR/boot/banan-os.kernel"
sudo mv "$BANAN_SYSROOT.initrd" "$MOUNT_DIR/boot/banan-os.initrd"
else
sudo rsync -rulHpt $BANAN_SYSROOT/ $MOUNT_DIR
sudo rsync -rulHpt "$BANAN_SYSROOT/" "$MOUNT_DIR"
fakeroot -i $BANAN_FAKEROOT find $BANAN_SYSROOT -printf './%P|%U|%G|%04m\n' >$BANAN_BUILD_DIR/sysroot-perms.txt
sudo bash -c "
if enable stat &>/dev/null; then
while IFS='|' read -r path uid gid mode; do
full=\"$MOUNT_DIR/\$path\"
stat \"\$full\"
if [[ \${STAT[uid]} != \$uid ]] || [[ \${STAT[gid]} != \$gid ]] || [[ \${STAT[perms]} != \$mode ]]; then
chown -h \"\$uid:\$gid\" \"\$full\"
test ! -h \"\$full\" && chmod \"\$mode\" \"\$full\"
fi
done <$BANAN_BUILD_DIR/sysroot-perms.txt
else
while IFS='|' read -r path uid gid mode; do
full=\"$MOUNT_DIR/\$path\"
if [[ \$(stat -c '%u %g %a' \"\$full\") != \"\$uid \$gid \$mode\" ]]; then
chown -h \"\$uid:\$gid\" \"\$full\"
test ! -h \"\$full\" && chmod \"\$mode\" \"\$full\"
fi
done <$BANAN_BUILD_DIR/sysroot-perms.txt
fi
"
fakeroot -i "$BANAN_FAKEROOT" find "$BANAN_SYSROOT" -printf '%P|%U|%G|%04m\n' >"$BANAN_BUILD_DIR/sysroot-perms.txt"
sudo "$BANAN_TOOLS_DIR/update-image-perms" "$MOUNT_DIR" "$BANAN_BUILD_DIR/sysroot-perms.txt"
fi
sudo umount $MOUNT_DIR
sudo umount "$MOUNT_DIR"
fi
sudo losetup -d $LOOP_DEV
sudo losetup -d "$LOOP_DEV"

View File

@ -17,6 +17,10 @@ CMAKE_VERSION="cmake-3.26.6-linux-x86_64"
CMAKE_TAR="$CMAKE_VERSION.tar.gz"
CMAKE_URL="https://cmake.org/files/v3.26/$CMAKE_TAR"
MESON_VERSION="meson-1.10.0"
MESON_TAR="$MESON_VERSION.tar.gz"
MESON_URL="https://github.com/mesonbuild/meson/releases/download/1.10.0/$MESON_TAR"
if [[ -z $BANAN_SYSROOT ]]; then
echo "You must set the BANAN_SYSROOT environment variable" >&2
exit 1
@ -68,14 +72,14 @@ enter_clean_build () {
}
build_binutils () {
echo "Building ${BINUTILS_VERSION}"
cd $BANAN_BUILD_DIR/toolchain
if [ ! -d $BINUTILS_VERSION ]; then
if [ ! -f $BINUTILS_TAR ]; then
echo "Downloading ${BINUTILS_TAR}"
wget $BINUTILS_URL
fi
echo "Unpacking ${BINUTILS_TAR}"
tar xf $BINUTILS_TAR
patch -ruN -p1 -d "$BINUTILS_VERSION" < "$BANAN_TOOLCHAIN_DIR/$BINUTILS_VERSION.patch"
fi
@ -83,6 +87,8 @@ build_binutils () {
cd $BANAN_BUILD_DIR/toolchain/$BINUTILS_VERSION
enter_clean_build
echo "Building ${BINUTILS_VERSION}"
../configure \
--target="$BANAN_TOOLCHAIN_TRIPLE" \
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
@ -98,14 +104,14 @@ build_binutils () {
}
build_gcc () {
echo "Building ${GCC_VERSION}"
cd $BANAN_BUILD_DIR/toolchain
if [ ! -d $GCC_VERSION ]; then
if [ ! -f $GCC_TAR ]; then
echo "Downloading ${GCC_TAR}"
wget $GCC_URL
fi
echo "Unpacking ${GCC_TAR}"
tar xf $GCC_TAR
patch -ruN -p1 -d "$GCC_VERSION" < "$BANAN_TOOLCHAIN_DIR/$GCC_VERSION.patch"
fi
@ -113,6 +119,8 @@ build_gcc () {
cd $BANAN_BUILD_DIR/toolchain/$GCC_VERSION
enter_clean_build
echo "Building ${GCC_VERSION}"
../configure \
--target="$BANAN_TOOLCHAIN_TRIPLE" \
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
@ -147,21 +155,22 @@ build_libstdcpp () {
}
build_grub () {
echo "Building ${GRUB_VERSION}"
cd $BANAN_BUILD_DIR/toolchain
if [ ! -f $GRUB_TAR ]; then
wget $GRUB_URL
fi
if [ ! -d $GRUB_VERSION ]; then
if [ ! -f $GRUB_TAR ]; then
echo "Downloading ${GRUB_TAR}"
wget $GRUB_URL
fi
echo "Unpacking ${GRUB_TAR}"
tar xvf $GRUB_TAR
fi
cd $GRUB_VERSION
enter_clean_build
echo "Building ${GRUB_VERSION}"
../configure \
--target="$BANAN_ARCH" \
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
@ -174,20 +183,21 @@ build_grub () {
}
build_cmake() {
echo "Downloading ${CMAKE_VERSION}"
cd $BANAN_BUILD_DIR/toolchain
if [ ! -f $CMAKE_TAR ]; then
wget $CMAKE_URL
fi
if [ ! -d $CMAKE_VERSION ]; then
if [ ! -f $CMAKE_TAR ]; then
echo "Downloading ${CMAKE_TAR}"
wget $CMAKE_URL
fi
echo "Unpacking ${CMAKE_TAR}"
tar xvf $CMAKE_TAR
fi
cd $CMAKE_VERSION
echo "Building ${CMAKE_VERSION}"
mkdir -p $BANAN_TOOLCHAIN_PREFIX/bin
mkdir -p $BANAN_TOOLCHAIN_PREFIX/share
@ -197,6 +207,27 @@ build_cmake() {
cp $BANAN_TOOLCHAIN_DIR/cmake-platform/* $BANAN_TOOLCHAIN_PREFIX/share/cmake-3.26/Modules/Platform/
}
build_meson() {
cd "$BANAN_BUILD_DIR/toolchain"
if [ ! -d $MESON_VERSION ]; then
if [ ! -f $MESON_TAR ]; then
echo "Downloading ${MESON_TAR}"
wget $MESON_URL
fi
echo "Unpacking ${MESON_TAR}"
tar xvf $MESON_TAR
fi
cd $MESON_VERSION
echo "Building ${MESON_VERSION}"
mkdir -p "$BANAN_TOOLCHAIN_PREFIX/bin"
./packaging/create_zipapp.py --outfile "$BANAN_TOOLCHAIN_PREFIX/bin/meson" --interpreter '/usr/bin/env python3'
}
BUILD_BINUTILS=1
if [[ -f $BANAN_TOOLCHAIN_PREFIX/bin/$BANAN_TOOLCHAIN_TRIPLE-ld ]]; then
echo "You already seem to have a binutils installed."
@ -241,6 +272,15 @@ if [[ -f $BANAN_TOOLCHAIN_PREFIX/bin/cmake ]]; then
fi
fi
BUILD_MESON=1
if [[ -f $BANAN_TOOLCHAIN_PREFIX/bin/meson ]]; then
echo "You already seem to have a meson installed."
read -e -p "Do you want to rebuild it [y/N]? " choice
if ! [[ "$choice" == [Yy]* ]]; then
BUILD_MESON=0
fi
fi
# delete everything but toolchain
mkdir -p $BANAN_BUILD_DIR
find $BANAN_BUILD_DIR -mindepth 1 -maxdepth 1 ! -name toolchain -exec rm -r {} +
@ -268,6 +308,10 @@ if (($BUILD_CMAKE)); then
build_cmake
fi
if (($BUILD_MESON)); then
build_meson
fi
if (($BUILD_LIBSTDCPP)); then
# delete sysroot and install libc
rm -r $BANAN_SYSROOT

View File

@ -0,0 +1,60 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
int main(int argc, char** argv)
{
if (argc != 3)
{
fprintf(stderr, "usage: %s MOUNT_POINT PERMS_FILE\n", argv[0]);
return 1;
}
int mount_fd = open(argv[1], O_RDONLY | O_DIRECTORY);
if (mount_fd == -1)
{
fprintf(stderr, "could not open %s: %s\n", argv[1], strerror(errno));
return 1;
}
FILE* perm_fp = fopen(argv[2], "r");
if (perm_fp == NULL)
{
fprintf(stderr, "could not open %s: %s\n", argv[2], strerror(errno));
return 1;
}
char buffer[1024];
while (fgets(buffer, sizeof(buffer), perm_fp))
{
char path[PATH_MAX];
uid_t uid;
gid_t gid;
mode_t mode;
if (sscanf(buffer, "%[^|\n]|%d|%d|%o\n", path, &uid, &gid, &mode) != 4)
continue;
struct stat st;
if (fstatat(mount_fd, path, &st, AT_SYMLINK_NOFOLLOW) != 0)
continue;
if (st.st_uid != uid || st.st_gid != gid)
if (fchownat(mount_fd, path, uid, gid, AT_SYMLINK_NOFOLLOW) != 0)
fprintf(stderr, "fchownat: %s: %s\n", path, strerror(errno));
const mode_t mode_mask = S_ISUID | S_ISGID | S_ISVTX | 0777;
if (mode != (st.st_mode & mode_mask))
if (fchmodat(mount_fd, path, mode, AT_SYMLINK_NOFOLLOW) != 0)
fprintf(stderr, "fchmodat: %s: %s\n", path, strerror(errno));
}
fclose(perm_fp);
close(mount_fd);
return 0;
}