From f6c312a6b3e58044360a82eb70f30d06051fc4ab Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 4 Nov 2023 17:50:43 +0200 Subject: [PATCH] BuildSystem: using sysroot doesn't need root privileges anymore! Sysroot is now created with fakeroot. This allows root access to be only needed for disk image creation, since it uses loopback devices. --- .gitignore | 2 +- BAN/CMakeLists.txt | 6 ++-- CMakeLists.txt | 5 ++- LibELF/CMakeLists.txt | 3 +- README.md | 6 ++-- kernel/CMakeLists.txt | 8 ++--- libc/CMakeLists.txt | 13 +++---- script/build.sh | 16 +++++---- script/config.sh | 1 + script/{image-full.sh => image-create.sh} | 2 +- script/image.sh | 44 ++++++++++------------- toolchain/Toolchain.txt | 12 ++++++- userspace/Shell/CMakeLists.txt | 3 +- userspace/cat-mmap/CMakeLists.txt | 3 +- userspace/cat/CMakeLists.txt | 3 +- userspace/chmod/CMakeLists.txt | 3 +- userspace/cp/CMakeLists.txt | 3 +- userspace/create_program.sh | 3 +- userspace/dd/CMakeLists.txt | 3 +- userspace/echo/CMakeLists.txt | 3 +- userspace/id/CMakeLists.txt | 3 +- userspace/init/CMakeLists.txt | 3 +- userspace/ls/CMakeLists.txt | 3 +- userspace/meminfo/CMakeLists.txt | 3 +- userspace/mkdir/CMakeLists.txt | 3 +- userspace/mmap-shared-test/CMakeLists.txt | 3 +- userspace/poweroff/CMakeLists.txt | 3 +- userspace/rm/CMakeLists.txt | 3 +- userspace/snake/CMakeLists.txt | 3 +- userspace/stat/CMakeLists.txt | 3 +- userspace/sync/CMakeLists.txt | 3 +- userspace/tee/CMakeLists.txt | 3 +- userspace/test-globals/CMakeLists.txt | 3 +- userspace/test/CMakeLists.txt | 3 +- userspace/touch/CMakeLists.txt | 3 +- userspace/u8sum/CMakeLists.txt | 3 +- userspace/whoami/CMakeLists.txt | 3 +- userspace/yes/CMakeLists.txt | 3 +- 38 files changed, 83 insertions(+), 113 deletions(-) rename script/{image-full.sh => image-create.sh} (98%) diff --git a/.gitignore b/.gitignore index a9328e85..6f2b0700 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ .idea/ build/ base/ - +script/fakeroot-context diff --git a/BAN/CMakeLists.txt b/BAN/CMakeLists.txt index f48b5393..30aa004c 100644 --- a/BAN/CMakeLists.txt +++ b/BAN/CMakeLists.txt @@ -10,17 +10,15 @@ set(BAN_SOURCES ) add_custom_target(ban-headers - COMMAND sudo rsync -a ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ + COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ DEPENDS sysroot - USES_TERMINAL ) add_library(ban ${BAN_SOURCES}) add_dependencies(ban headers libc-install) add_custom_target(ban-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/libban.a ${BANAN_LIB}/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/libban.a ${BANAN_LIB}/ DEPENDS ban BYPRODUCTS ${BANAN_LIB}/libban.a - USES_TERMINAL ) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6533eba..ad304de9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,6 @@ add_compile_definitions(__enable_sse=0) project(banan-os CXX C ASM) set(BANAN_BASE_SYSROOT ${CMAKE_SOURCE_DIR}/base-sysroot.tar.gz) -set(BANAN_SYSROOT ${CMAKE_BINARY_DIR}/sysroot) set(BANAN_INCLUDE ${BANAN_SYSROOT}/usr/include) set(BANAN_LIB ${BANAN_SYSROOT}/usr/lib) set(BANAN_BIN ${BANAN_SYSROOT}/usr/bin) @@ -24,8 +23,7 @@ add_subdirectory(userspace) add_custom_target(sysroot COMMAND ${CMAKE_COMMAND} -E make_directory ${BANAN_SYSROOT} - COMMAND cd ${BANAN_SYSROOT} && sudo tar xf ${BANAN_BASE_SYSROOT} - USES_TERMINAL + COMMAND cd ${BANAN_SYSROOT} && tar xf ${BANAN_BASE_SYSROOT} ) add_custom_target(headers @@ -36,6 +34,7 @@ add_custom_target(headers ) add_custom_target(install-sysroot + COMMAND cd ${BANAN_SYSROOT} && tar cf ${BANAN_SYSROOT_TAR} * DEPENDS kernel-install DEPENDS ban-install DEPENDS libc-install diff --git a/LibELF/CMakeLists.txt b/LibELF/CMakeLists.txt index 57006114..b9ce4fd1 100644 --- a/LibELF/CMakeLists.txt +++ b/LibELF/CMakeLists.txt @@ -3,9 +3,8 @@ cmake_minimum_required(VERSION 3.26) project(LibELF CXX) add_custom_target(libelf-headers - COMMAND sudo rsync -a ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ + COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ DEPENDS sysroot - USES_TERMINAL ) add_custom_target(libelf-install diff --git a/README.md b/README.md index 959f09a4..9b315c21 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # banan-os -This is my hobby operating system written in C++. Currently supports only x86_64 architecture. We have a ext2 filesystem, basic ramfs, IDE disk drivers in ATA PIO mode, ATA AHCI drivers, userspace processes, executable loading from ELF format, linear VBE graphics and multithreaded processing on single core. +This is my hobby operating system written in C++. Currently supports only x86\_64 architecture. We have a ext2 filesystem, basic ramfs, IDE disk drivers in ATA PIO mode, ATA AHCI drivers, userspace processes, executable loading from ELF format, linear VBE graphics and multithreaded processing on single core. ![screenshot from qemu running banan-os](assets/banan-os.png) @@ -20,7 +20,7 @@ To build the toolchain for this os. You can run the following command. ./script/build.sh toolchain ``` -To build the os itself you can run one of the following commands. You will need root access since the sysroot has "proper" permissions. +To build the os itself you can run one of the following commands. You will need root access for disk image creation/modification. ```sh ./script/build.sh qemu ./script/build.sh qemu-nographic @@ -39,8 +39,6 @@ If you have corrupted your disk image or want to create new one, you can either ./script/build.sh image-full ``` -> ***NOTE*** ```ninja clean``` has to be ran with root permissions, since it deletes from the banan-so sysroot. - If you feel like ```./script/build.sh``` is too verbose, there exists a symlink _bos_ in this projects root directory. All build commands can be used with ```./bos args...``` instead. I have also created shell completion script for zsh. You can either copy the file in _script/shell-completion/zsh/\_bos_ to _/usr/share/zsh/site-functions/_ or add the _script/shell-completion/zsh_ to your fpath in _.zshrc_. diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index a61cc1a4..770c57b0 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -165,16 +165,14 @@ endif() target_link_options(kernel PUBLIC -ffreestanding -nostdlib) add_custom_target(kernel-headers - COMMAND sudo rsync -a ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ - COMMAND sudo rsync -a ${CMAKE_CURRENT_SOURCE_DIR}/lai/include/ ${BANAN_INCLUDE}/ + COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ + COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/lai/include/ ${BANAN_INCLUDE}/ DEPENDS sysroot - USES_TERMINAL ) add_custom_target(kernel-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/kernel ${BANAN_BOOT}/banan-os.kernel + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/kernel ${BANAN_BOOT}/banan-os.kernel DEPENDS kernel - USES_TERMINAL ) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=crtbegin.o OUTPUT_VARIABLE CRTBEGIN OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 5432b6f0..82081493 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -26,9 +26,8 @@ set(LIBC_SOURCES ) add_custom_target(libc-headers - COMMAND sudo rsync -a ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ + COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ DEPENDS sysroot - USES_TERMINAL ) add_custom_target(crtx @@ -38,11 +37,10 @@ add_custom_target(crtx ) add_custom_target(crtx-install - COMMAND sudo cp crt0.o ${BANAN_LIB}/ - COMMAND sudo cp crti.o ${BANAN_LIB}/ - COMMAND sudo cp crtn.o ${BANAN_LIB}/ + COMMAND ${CMAKE_COMMAND} -E copy crt0.o ${BANAN_LIB}/ + COMMAND ${CMAKE_COMMAND} -E copy crti.o ${BANAN_LIB}/ + COMMAND ${CMAKE_COMMAND} -E copy crtn.o ${BANAN_LIB}/ DEPENDS crtx - USES_TERMINAL ) add_library(libc ${LIBC_SOURCES}) @@ -51,10 +49,9 @@ add_dependencies(libc headers crtx-install) target_compile_options(libc PRIVATE -g -Wstack-usage=512) add_custom_target(libc-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/libc.a ${BANAN_LIB}/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/libc.a ${BANAN_LIB}/ DEPENDS libc BYPRODUCTS ${BANAN_LIB}/libc.a - USES_TERMINAL ) set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/script/build.sh b/script/build.sh index c8399d7c..3bfedc21 100755 --- a/script/build.sh +++ b/script/build.sh @@ -4,6 +4,12 @@ set -e export BANAN_SCRIPT_DIR=$(dirname $(realpath $0)) source $BANAN_SCRIPT_DIR/config.sh +FAKEROOT_FILE="$BANAN_BUILD_DIR/fakeroot-context" + +run_fakeroot() { + fakeroot -i $FAKEROOT_FILE -s $FAKEROOT_FILE -- /bin/bash -c '$@' bash $@ +} + make_build_dir () { mkdir -p $BANAN_BUILD_DIR cd $BANAN_BUILD_DIR @@ -19,7 +25,7 @@ build_target () { exit 1 fi cd $BANAN_BUILD_DIR - ninja $1 + run_fakeroot ninja $1 } build_toolchain () { @@ -39,11 +45,7 @@ build_toolchain () { create_image () { build_target install-sysroot - if [[ "$1" == "full" ]]; then - $BANAN_SCRIPT_DIR/image-full.sh - else - $BANAN_SCRIPT_DIR/image.sh - fi + $BANAN_SCRIPT_DIR/image.sh "$1" } run_qemu () { @@ -56,7 +58,7 @@ run_bochs () { $BANAN_SCRIPT_DIR/bochs.sh $@ } -if [[ "$(uname)" == "Linux" ]]; then +if [[ -c /dev/kvm ]]; then QEMU_ACCEL="-accel kvm" fi diff --git a/script/config.sh b/script/config.sh index ebdfc1f7..a42f8a51 100644 --- a/script/config.sh +++ b/script/config.sh @@ -18,6 +18,7 @@ export BANAN_TOOLCHAIN_TRIPLE_PREFIX=$BANAN_ARCH-banan_os export BANAN_BUILD_DIR=$BANAN_ROOT_DIR/build export BANAN_SYSROOT=$BANAN_BUILD_DIR/sysroot +export BANAN_SYSROOT_TAR=$BANAN_SYSROOT.tar export BANAN_DISK_IMAGE_PATH=$BANAN_BUILD_DIR/banan-os.img diff --git a/script/image-full.sh b/script/image-create.sh similarity index 98% rename from script/image-full.sh rename to script/image-create.sh index 061dd10d..bce3e001 100755 --- a/script/image-full.sh +++ b/script/image-create.sh @@ -72,7 +72,7 @@ sudo partprobe $LOOP_DEV PARTITION1=${LOOP_DEV}p1 PARTITION2=${LOOP_DEV}p2 -sudo mkfs.ext2 -d $BANAN_SYSROOT -b 1024 -q $PARTITION2 +sudo mkfs.ext2 -b 1024 -q $PARTITION2 if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then sudo mkfs.fat $PARTITION1 > /dev/null diff --git a/script/image.sh b/script/image.sh index 26061b47..ae39bdfb 100755 --- a/script/image.sh +++ b/script/image.sh @@ -1,44 +1,38 @@ #!/bin/bash -if [[ -z $BANAN_ROOT_DIR ]]; then - echo "You must set the BANAN_ROOT_DIR environment variable" >&2 - exit 1 -fi - if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then echo "You must set the BANAN_DISK_IMAGE_PATH environment variable" >&2 exit 1 fi -if [[ -z $BANAN_SYSROOT ]]; then - echo "You must set the BANAN_SYSROOT environment variable" >&2 +if [[ -z $BANAN_SYSROOT_TAR ]]; then + echo "You must set the BANAN_SYSROOT_TAR environment variable" >&2 exit 1 fi -if [[ ! -f $BANAN_DISK_IMAGE_PATH ]]; then - $BANAN_SCRIPT_DIR/image-full.sh - exit 0 +if [[ "$1" == "full" ]] || [[ ! -f $BANAN_DISK_IMAGE_PATH ]]; then + $BANAN_SCRIPT_DIR/image-create.sh +else + fdisk -l $BANAN_DISK_IMAGE_PATH | grep -q 'EFI System'; IMAGE_IS_UEFI=$? + [[ $BANAN_UEFI_BOOT == 1 ]]; CREATE_IS_UEFI=$? + + if [[ $IMAGE_IS_UEFI -ne $CREATE_IS_UEFI ]]; then + echo Converting disk image to/from UEFI + $BANAN_SCRIPT_DIR/image-create.sh + fi fi -fdisk -l $BANAN_DISK_IMAGE_PATH | grep -q 'EFI System'; IMAGE_IS_UEFI=$? -[[ $BANAN_UEFI_BOOT == 1 ]]; CREATE_IS_UEFI=$? - -if [[ $IMAGE_IS_UEFI -ne $CREATE_IS_UEFI ]]; then - echo Converting disk image to/from UEFI - $BANAN_SCRIPT_DIR/image-full.sh - exit 0 -fi - -MOUNT_DIR=/mnt - -LOOP_DEV=$(sudo losetup -f --show $BANAN_DISK_IMAGE_PATH) +LOOP_DEV=$(sudo losetup --show -f "$BANAN_DISK_IMAGE_PATH") sudo partprobe $LOOP_DEV -ROOT_PARTITON=${LOOP_DEV}p2 +ROOT_PARTITION=${LOOP_DEV}p2 +MOUNT_DIR=/mnt -sudo mount $ROOT_PARTITON $MOUNT_DIR +sudo mount $ROOT_PARTITION $MOUNT_DIR -sudo rsync -a ${BANAN_SYSROOT}/* ${MOUNT_DIR}/ +cd $MOUNT_DIR +sudo tar xf $BANAN_SYSROOT_TAR +cd sudo umount $MOUNT_DIR diff --git a/toolchain/Toolchain.txt b/toolchain/Toolchain.txt index c208fd94..8acce806 100644 --- a/toolchain/Toolchain.txt +++ b/toolchain/Toolchain.txt @@ -1,9 +1,19 @@ if (NOT DEFINED ENV{BANAN_ARCH}) message(FATAL_ERROR "environment variable BANAN_ARCH not defined") endif () - set(BANAN_ARCH $ENV{BANAN_ARCH}) +if (NOT DEFINED ENV{BANAN_SYSROOT}) + message(FATAL_ERROR "environment variable BANAN_SYSROOT not defined") +endif () +set(BANAN_SYSROOT $ENV{BANAN_SYSROOT}) + +if (NOT DEFINED ENV{BANAN_SYSROOT_TAR}) + message(FATAL_ERROR "environment variable BANAN_SYSROOT_TAR not defined") +endif () +set(BANAN_SYSROOT_TAR $ENV{BANAN_SYSROOT_TAR}) + + set(TOOLCHAIN_PREFIX ${CMAKE_SOURCE_DIR}/toolchain/local) set(CMAKE_SYSTEM_NAME banan-os) diff --git a/userspace/Shell/CMakeLists.txt b/userspace/Shell/CMakeLists.txt index f77316e6..ac2e606a 100644 --- a/userspace/Shell/CMakeLists.txt +++ b/userspace/Shell/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(Shell PUBLIC -O2 -g) target_link_libraries(Shell PUBLIC libc ban) add_custom_target(Shell-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/Shell ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/Shell ${BANAN_BIN}/ DEPENDS Shell - USES_TERMINAL ) diff --git a/userspace/cat-mmap/CMakeLists.txt b/userspace/cat-mmap/CMakeLists.txt index 54562be3..b5d06b7c 100644 --- a/userspace/cat-mmap/CMakeLists.txt +++ b/userspace/cat-mmap/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(cat-mmap PUBLIC -O2 -g) target_link_libraries(cat-mmap PUBLIC libc) add_custom_target(cat-mmap-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/cat-mmap ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/cat-mmap ${BANAN_BIN}/ DEPENDS cat-mmap - USES_TERMINAL ) diff --git a/userspace/cat/CMakeLists.txt b/userspace/cat/CMakeLists.txt index 9008d7b2..999d539c 100644 --- a/userspace/cat/CMakeLists.txt +++ b/userspace/cat/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(cat PUBLIC -O2 -g) target_link_libraries(cat PUBLIC libc) add_custom_target(cat-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/cat ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/cat ${BANAN_BIN}/ DEPENDS cat - USES_TERMINAL ) diff --git a/userspace/chmod/CMakeLists.txt b/userspace/chmod/CMakeLists.txt index 29b3c28d..076db1d1 100644 --- a/userspace/chmod/CMakeLists.txt +++ b/userspace/chmod/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(chmod PUBLIC -O2 -g) target_link_libraries(chmod PUBLIC libc) add_custom_target(chmod-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/chmod ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/chmod ${BANAN_BIN}/ DEPENDS chmod - USES_TERMINAL ) diff --git a/userspace/cp/CMakeLists.txt b/userspace/cp/CMakeLists.txt index 89f6e2af..cd68633c 100644 --- a/userspace/cp/CMakeLists.txt +++ b/userspace/cp/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(cp PUBLIC -O2 -g) target_link_libraries(cp PUBLIC libc ban) add_custom_target(cp-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/cp ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/cp ${BANAN_BIN}/ DEPENDS cp - USES_TERMINAL ) diff --git a/userspace/create_program.sh b/userspace/create_program.sh index 3fc45f0f..0f770cfb 100755 --- a/userspace/create_program.sh +++ b/userspace/create_program.sh @@ -20,9 +20,8 @@ target_compile_options($PROGRAM_NAME PUBLIC -O2 -g) target_link_libraries($PROGRAM_NAME PUBLIC libc) add_custom_target($PROGRAM_NAME-install - COMMAND sudo cp \${CMAKE_CURRENT_BINARY_DIR}/$PROGRAM_NAME \${BANAN_BIN}/ + COMMAND \${CMAKE_COMMAND} -E copy \${CMAKE_CURRENT_BINARY_DIR}/$PROGRAM_NAME \${BANAN_BIN}/ DEPENDS $PROGRAM_NAME - USES_TERMINAL ) EOF diff --git a/userspace/dd/CMakeLists.txt b/userspace/dd/CMakeLists.txt index 5e88c869..b86d31ff 100644 --- a/userspace/dd/CMakeLists.txt +++ b/userspace/dd/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(dd PUBLIC -O2 -g) target_link_libraries(dd PUBLIC libc) add_custom_target(dd-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/dd ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/dd ${BANAN_BIN}/ DEPENDS dd - USES_TERMINAL ) diff --git a/userspace/echo/CMakeLists.txt b/userspace/echo/CMakeLists.txt index bd7e2d9a..bb2f607d 100644 --- a/userspace/echo/CMakeLists.txt +++ b/userspace/echo/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(echo PUBLIC -O2 -g) target_link_libraries(echo PUBLIC libc) add_custom_target(echo-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/echo ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/echo ${BANAN_BIN}/ DEPENDS echo - USES_TERMINAL ) diff --git a/userspace/id/CMakeLists.txt b/userspace/id/CMakeLists.txt index 0b23db13..3d4e37b8 100644 --- a/userspace/id/CMakeLists.txt +++ b/userspace/id/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(id PUBLIC -O2 -g) target_link_libraries(id PUBLIC libc ban) add_custom_target(id-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/id ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/id ${BANAN_BIN}/ DEPENDS id - USES_TERMINAL ) diff --git a/userspace/init/CMakeLists.txt b/userspace/init/CMakeLists.txt index 325d076a..71227f56 100644 --- a/userspace/init/CMakeLists.txt +++ b/userspace/init/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(init PUBLIC -O2 -g) target_link_libraries(init PUBLIC libc ban) add_custom_target(init-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/init ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/init ${BANAN_BIN}/ DEPENDS init - USES_TERMINAL ) diff --git a/userspace/ls/CMakeLists.txt b/userspace/ls/CMakeLists.txt index bbf2c3c6..4f0bcbef 100644 --- a/userspace/ls/CMakeLists.txt +++ b/userspace/ls/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(ls PUBLIC -O2 -g) target_link_libraries(ls PUBLIC libc) add_custom_target(ls-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/ls ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/ls ${BANAN_BIN}/ DEPENDS ls - USES_TERMINAL ) diff --git a/userspace/meminfo/CMakeLists.txt b/userspace/meminfo/CMakeLists.txt index 0094e797..1fa350b9 100644 --- a/userspace/meminfo/CMakeLists.txt +++ b/userspace/meminfo/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(meminfo PUBLIC -O2 -g) target_link_libraries(meminfo PUBLIC libc) add_custom_target(meminfo-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/meminfo ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/meminfo ${BANAN_BIN}/ DEPENDS meminfo - USES_TERMINAL ) diff --git a/userspace/mkdir/CMakeLists.txt b/userspace/mkdir/CMakeLists.txt index 9568f08f..8111b649 100644 --- a/userspace/mkdir/CMakeLists.txt +++ b/userspace/mkdir/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(mkdir PUBLIC -O2 -g) target_link_libraries(mkdir PUBLIC libc) add_custom_target(mkdir-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/mkdir ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/mkdir ${BANAN_BIN}/ DEPENDS mkdir - USES_TERMINAL ) diff --git a/userspace/mmap-shared-test/CMakeLists.txt b/userspace/mmap-shared-test/CMakeLists.txt index b44dabf9..59981ab6 100644 --- a/userspace/mmap-shared-test/CMakeLists.txt +++ b/userspace/mmap-shared-test/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(mmap-shared-test PUBLIC -O2 -g) target_link_libraries(mmap-shared-test PUBLIC libc) add_custom_target(mmap-shared-test-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/mmap-shared-test ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/mmap-shared-test ${BANAN_BIN}/ DEPENDS mmap-shared-test - USES_TERMINAL ) diff --git a/userspace/poweroff/CMakeLists.txt b/userspace/poweroff/CMakeLists.txt index a9e65e2d..d2ada922 100644 --- a/userspace/poweroff/CMakeLists.txt +++ b/userspace/poweroff/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(poweroff PUBLIC -O2 -g) target_link_libraries(poweroff PUBLIC libc) add_custom_target(poweroff-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/poweroff ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/poweroff ${BANAN_BIN}/ DEPENDS poweroff - USES_TERMINAL ) diff --git a/userspace/rm/CMakeLists.txt b/userspace/rm/CMakeLists.txt index 2cf60338..c7ed5335 100644 --- a/userspace/rm/CMakeLists.txt +++ b/userspace/rm/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(rm PUBLIC -O2 -g) target_link_libraries(rm PUBLIC libc ban) add_custom_target(rm-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/rm ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/rm ${BANAN_BIN}/ DEPENDS rm - USES_TERMINAL ) diff --git a/userspace/snake/CMakeLists.txt b/userspace/snake/CMakeLists.txt index a5b7066c..59dc04a8 100644 --- a/userspace/snake/CMakeLists.txt +++ b/userspace/snake/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(snake PUBLIC -O2 -g) target_link_libraries(snake PUBLIC libc) add_custom_target(snake-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/snake ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/snake ${BANAN_BIN}/ DEPENDS snake - USES_TERMINAL ) diff --git a/userspace/stat/CMakeLists.txt b/userspace/stat/CMakeLists.txt index 2e6c6d30..fb690eca 100644 --- a/userspace/stat/CMakeLists.txt +++ b/userspace/stat/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(stat PUBLIC -O2 -g) target_link_libraries(stat PUBLIC libc ban) add_custom_target(stat-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/stat ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/stat ${BANAN_BIN}/ DEPENDS stat - USES_TERMINAL ) diff --git a/userspace/sync/CMakeLists.txt b/userspace/sync/CMakeLists.txt index 236e313a..611e7f55 100644 --- a/userspace/sync/CMakeLists.txt +++ b/userspace/sync/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(sync PUBLIC -O2 -g) target_link_libraries(sync PUBLIC libc) add_custom_target(sync-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/sync ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/sync ${BANAN_BIN}/ DEPENDS sync - USES_TERMINAL ) diff --git a/userspace/tee/CMakeLists.txt b/userspace/tee/CMakeLists.txt index 84225e62..4697ff52 100644 --- a/userspace/tee/CMakeLists.txt +++ b/userspace/tee/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(tee PUBLIC -O2 -g) target_link_libraries(tee PUBLIC libc) add_custom_target(tee-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/tee ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/tee ${BANAN_BIN}/ DEPENDS tee - USES_TERMINAL ) diff --git a/userspace/test-globals/CMakeLists.txt b/userspace/test-globals/CMakeLists.txt index 8fe4151a..6c7aa366 100644 --- a/userspace/test-globals/CMakeLists.txt +++ b/userspace/test-globals/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(test-globals PUBLIC -O2 -g) target_link_libraries(test-globals PUBLIC libc) add_custom_target(test-globals-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/test-globals ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test-globals ${BANAN_BIN}/ DEPENDS test-globals - USES_TERMINAL ) diff --git a/userspace/test/CMakeLists.txt b/userspace/test/CMakeLists.txt index 963278c7..0de2c685 100644 --- a/userspace/test/CMakeLists.txt +++ b/userspace/test/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(test PUBLIC -O2 -g) target_link_libraries(test PUBLIC libc) add_custom_target(test-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/test ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test ${BANAN_BIN}/ DEPENDS test - USES_TERMINAL ) diff --git a/userspace/touch/CMakeLists.txt b/userspace/touch/CMakeLists.txt index 6504f14f..c4542c64 100644 --- a/userspace/touch/CMakeLists.txt +++ b/userspace/touch/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(touch PUBLIC -O2 -g) target_link_libraries(touch PUBLIC libc) add_custom_target(touch-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/touch ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/touch ${BANAN_BIN}/ DEPENDS touch - USES_TERMINAL ) diff --git a/userspace/u8sum/CMakeLists.txt b/userspace/u8sum/CMakeLists.txt index c19849dc..249d160d 100644 --- a/userspace/u8sum/CMakeLists.txt +++ b/userspace/u8sum/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(u8sum PUBLIC -O2 -g) target_link_libraries(u8sum PUBLIC libc) add_custom_target(u8sum-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/u8sum ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/u8sum ${BANAN_BIN}/ DEPENDS u8sum - USES_TERMINAL ) diff --git a/userspace/whoami/CMakeLists.txt b/userspace/whoami/CMakeLists.txt index 81308242..1a9a3aac 100644 --- a/userspace/whoami/CMakeLists.txt +++ b/userspace/whoami/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(whoami PUBLIC -O2 -g) target_link_libraries(whoami PUBLIC libc ban) add_custom_target(whoami-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/whoami ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/whoami ${BANAN_BIN}/ DEPENDS whoami - USES_TERMINAL ) diff --git a/userspace/yes/CMakeLists.txt b/userspace/yes/CMakeLists.txt index bf217e44..6ef982bd 100644 --- a/userspace/yes/CMakeLists.txt +++ b/userspace/yes/CMakeLists.txt @@ -11,7 +11,6 @@ target_compile_options(yes PUBLIC -O2 -g) target_link_libraries(yes PUBLIC libc) add_custom_target(yes-install - COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/yes ${BANAN_BIN}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/yes ${BANAN_BIN}/ DEPENDS yes - USES_TERMINAL )