Clean up the builder script to replace functionalities with nix
This commit is contained in:
parent
2e230b9474
commit
b238c69288
170
builder
170
builder
|
@ -114,10 +114,8 @@ function popd_build() {
|
||||||
|
|
||||||
function build-gen() {
|
function build-gen() {
|
||||||
local args
|
local args
|
||||||
#setup_toolchain
|
|
||||||
args=(
|
args=(
|
||||||
# "-C"
|
|
||||||
# "$ME/cmake/caches/$1.cmake"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
pushed_build
|
pushed_build
|
||||||
|
@ -232,74 +230,6 @@ function build-tests() { ## Generates and build the project including the test c
|
||||||
popd_build
|
popd_build
|
||||||
}
|
}
|
||||||
|
|
||||||
function build-llvm-image() { ## Build thh LLVM images of Serene for all platforms
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
if [ "$1" ]; then
|
|
||||||
cleanup_builder || setup_builder
|
|
||||||
podman login "$REGISTRY" -u "$SERENE_REGISTERY_USER" -p "$SERENE_REGISTERY_PASS"
|
|
||||||
build_llvm "$1" "$ME"
|
|
||||||
build_ci "$1" "$ME"
|
|
||||||
cleanup_builder
|
|
||||||
else
|
|
||||||
error "Pass the llvm version as input"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function push-images() { ## Pushes all the related image to the registery
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
if [ "$1" ]; then
|
|
||||||
push_images "$1" "$ME"
|
|
||||||
else
|
|
||||||
error "Pass the llvm version as input"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function build-serene-image-arm64() { ## Build the Serene docker image for the current HEAD (on ARM64)
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
|
|
||||||
docker buildx build --platform linux/arm64 --builder multiarch --load \
|
|
||||||
-f "$ME/resources/docker/serene/Dockerfile" \
|
|
||||||
-t "$REGISTRY/serene:$VERSION-$(git rev-parse HEAD)" \
|
|
||||||
.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function build-serene-image() { ## Build the Serene docker image for the current HEAD
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
|
|
||||||
docker build \
|
|
||||||
-f "$ME/resources/docker/serene/Dockerfile" \
|
|
||||||
-t "$REGISTRY/serene:$VERSION-$(git rev-parse HEAD)" \
|
|
||||||
.
|
|
||||||
}
|
|
||||||
|
|
||||||
function release-serene-image() { ## Build and push the Serene docker image for the current HEAD in Release mode
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
docker build \
|
|
||||||
-f "$ME/resources/docker/serene/Dockerfile" \
|
|
||||||
-t "$REGISTRY/serene:$VERSION" \
|
|
||||||
--build-arg TASK=build-release \
|
|
||||||
.
|
|
||||||
docker login "$REGISTRY" -u "$SERENE_REGISTERY_USER" -p "$SERENE_REGISTERY_PASS"
|
|
||||||
docker push "$REGISTRY/serene:$VERSION"
|
|
||||||
}
|
|
||||||
|
|
||||||
function create-devfs-image() { ## Create the devfs images locally (requires sudo)
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
|
|
||||||
local output_dir
|
|
||||||
|
|
||||||
output_dir="$DEV_FS_DIR/image"
|
|
||||||
mkdir -p "$output_dir"
|
|
||||||
|
|
||||||
create_and_initialize_devfs_image "$output_dir" "$ME" "$LLVM_VERSION"
|
|
||||||
}
|
|
||||||
|
|
||||||
function setup() { ## Setup the working directory and make it ready for development
|
function setup() { ## Setup the working directory and make it ready for development
|
||||||
local args
|
local args
|
||||||
|
@ -314,104 +244,6 @@ function setup() { ## Setup the working directory and make it ready for developm
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup-dev() { ## Setup the container like env to build/develop Serene (requires sudo access)
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
|
|
||||||
local fs_tarball
|
|
||||||
local rootfs
|
|
||||||
|
|
||||||
fs_tarball="$DEV_FS_DIR/fs.tar.xz"
|
|
||||||
rootfs="$DEV_FS_DIR/fs"
|
|
||||||
|
|
||||||
mkdir -p "$DEV_FS_DIR"
|
|
||||||
|
|
||||||
if [[ -f "$rootfs/etc/shadow" ]]; then
|
|
||||||
info "RootFS already exits. Skipping..."
|
|
||||||
else
|
|
||||||
info "RootFS is missing."
|
|
||||||
if [ ! -f "$fs_tarball" ]; then
|
|
||||||
download_devfs "$SERENE_FS_REPO" "$fs_tarball"
|
|
||||||
else
|
|
||||||
info "FS tarball exists at '$fs_tarball'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
extract_devfs "$fs_tarball" "$rootfs"
|
|
||||||
fi
|
|
||||||
|
|
||||||
init_devfs "$rootfs" "$ME"
|
|
||||||
|
|
||||||
info "The 'devfs' setup is finished!"
|
|
||||||
echo
|
|
||||||
echo "===================================================================="
|
|
||||||
echo "DO NOT MANUALLY REMOVE THE DIRECTORY!!!"
|
|
||||||
echo "Instead use the builder command 'destroy-devfs' ro remove it"
|
|
||||||
echo "===================================================================="
|
|
||||||
}
|
|
||||||
|
|
||||||
function push_devfs_imagse() { ## Push the created devfs image to the "registry" (air quote)
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
|
|
||||||
local image_dir
|
|
||||||
|
|
||||||
image_dir="$DEV_FS_DIR/image"
|
|
||||||
|
|
||||||
sync_devfs_image "$image_dir"
|
|
||||||
mark_devfs_image_as_latest "$image_dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy-devfs() { ## Destroy the 'devfs' by unmounting the volumes and deleting the files
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
|
|
||||||
local rootfs
|
|
||||||
rootfs="$DEV_FS_DIR/fs"
|
|
||||||
|
|
||||||
yes_or_no "Do you really want to remove the 'devfs'?" && \
|
|
||||||
unmount_and_destroy_devfs "$rootfs"
|
|
||||||
}
|
|
||||||
|
|
||||||
function build-in-devfs() { ## Destroy the 'devfs' by unmounting the volumes and deleting the files
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
|
|
||||||
local rootfs
|
|
||||||
rootfs="$DEV_FS_DIR/fs"
|
|
||||||
|
|
||||||
rootless "$rootfs" ./builder build
|
|
||||||
}
|
|
||||||
|
|
||||||
function devfs_root_shell() { ## Get a bash shell as root on the devfs
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
|
|
||||||
local rootfs
|
|
||||||
|
|
||||||
rootfs="$DEV_FS_DIR/fs"
|
|
||||||
|
|
||||||
if [[ -f "$rootfs/etc/shadow" ]]; then
|
|
||||||
as_root "$rootfs" bash
|
|
||||||
else
|
|
||||||
error "DevFS does not exist run './builder setup-dev' first"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function devfs_shell() { ## Get a bash shell on the devfs
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source .env
|
|
||||||
|
|
||||||
local rootfs
|
|
||||||
|
|
||||||
rootfs="$DEV_FS_DIR/fs"
|
|
||||||
|
|
||||||
if [[ -f "$rootfs/etc/shadow" ]]; then
|
|
||||||
rootless "$rootfs" bash
|
|
||||||
else
|
|
||||||
error "DevFS does not exist run './builder setup-dev' first"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function scan-build() { ## Runs the `scan-build` utility to analyze the build process
|
function scan-build() { ## Runs the `scan-build` utility to analyze the build process
|
||||||
rm -rf "$BUILD_DIR"
|
rm -rf "$BUILD_DIR"
|
||||||
build-gen
|
build-gen
|
||||||
|
|
Loading…
Reference in New Issue