@@ -68,7 +68,7 @@ pre_fetch_cargo_deps() {
6868 local outLink=" --no-out-link"
6969 local cargoVendorMsg=" "
7070 if [ -n " $CARGO_VENDOR_DIR " ]; then
71- if [ " $( realpath -ms " $CARGO_VENDOR_DIR " ) " = " $( realpath -ms " $SCRIPT_DIR /.. " ) " ]; then
71+ if [ " $( realpath -ms " $CARGO_VENDOR_DIR " ) " = " ${PARENT_ROOT :- } " ]; then
7272 cargoVendorDir=" $CARGO_VENDOR_DIR /$GIT_BRANCH "
7373 else
7474 cargoVendorDir=" $CARGO_VENDOR_DIR /$project /$GIT_BRANCH "
@@ -235,6 +235,13 @@ parse_common_arg() {
235235 BUILD_TYPE=" debug"
236236 shift
237237 ;;
238+ --debug-slim)
239+ BUILD_TYPE=" debug"
240+ if [ -z " ${RUSTFLAGS:- } " ]; then
241+ RUSTFLAGS=" -C debuginfo=0 -C strip=debuginfo"
242+ fi
243+ shift
244+ ;;
238245 --incremental)
239246 INCREMENTAL=" true"
240247 shift
@@ -377,12 +384,12 @@ fetch_nix_bin() {
377384 local bin=" $2 "
378385
379386 if [ ! -f " $NIX_SOURCES " ]; then
380- log_fatal " $( binary_missing_msg " $HELM " ) or set NIX_SOURCES so we can pull it from nixpkgs"
387+ log_fatal " $( binary_missing_msg " $package " ) or set NIX_SOURCES so we can pull it from nixpkgs"
381388 fi
382389 NIX_SOURCES=$( realpath " $NIX_SOURCES " )
383390 binary_check_die " $NIX "
384391
385- $NIX shell --impure $( nix_experimental) --expr " (import (import $NIX_SOURCES ).nixpkgs {}).$package " -c which $bin
392+ $NIX shell --impure $( nix_experimental) --expr " (import (import $NIX_SOURCES ).nixpkgs {}).$package " -c bash -c " type -P $bin "
386393}
387394
388395build_helm_deps () {
@@ -535,6 +542,58 @@ build_bins() {
535542 fi
536543}
537544
545+ get_nix_src () {
546+ if [ -n " ${PARENT_ROOT} " ]; then
547+ echo " $( realpath " ${NIX_SOURCES:- ${PARENT_ROOT} / nix/ sources.nix} " ) "
548+ else
549+ echo " $( realpath " ${NIX_SOURCES} " ) "
550+ fi
551+ }
552+
553+ get_parent () {
554+ # Check if specified by parent
555+ if [ -n " ${PARENT_ROOT_DIR:- } " ]; then
556+ echo " $PARENT_ROOT_DIR "
557+ return 0
558+ fi
559+
560+ # Mayastor control-plane
561+ if [ -n " ${WORKSPACE_ROOT:- } " ]; then
562+ echo " $WORKSPACE_ROOT "
563+ return 0
564+ fi
565+
566+ # Mayastor extensions
567+ if [ -n " ${EXTENSIONS_SRC:- } " ]; then
568+ echo " $EXTENSIONS_SRC "
569+ return 0
570+ fi
571+
572+ # OpenEBS umbrella
573+ if [ -n " ${OPENEBS_SRC:- } " ]; then
574+ echo " $OPENEBS_SRC "
575+ return 0
576+ fi
577+
578+ # Figure it out using the git top-level
579+ if command -v git & > /dev/null; then
580+ git rev-parse --show-toplevel
581+ return 0
582+ fi
583+
584+ # From the current path
585+ if [ -d " ${PWD:- .} /nix" ]; then
586+ echo " ${PWD:- .} "
587+ return 0
588+ fi
589+
590+ # Using the io-engine
591+ if [ -n " ${SRCDIR:- } " ]; then
592+ echo " $SRCDIR "
593+ return 0
594+ fi
595+ }
596+
538597# Set up the container aliases, build the binaries, and build/upload the images
539598common_run () {
540599 parse_common_args $@
@@ -557,6 +616,7 @@ common_help() {
557616 --registry <host[:port]> Push the built images to the provided registry.
558617 To also replace the image org provide the full repository path, example: docker.io/org
559618 --debug Build debug version of images where possible.
619+ --debug-slim Build slim debug version of images where possible. (sets RUSTFLAGS="-C debuginfo=0 -C strip=debuginfo")
560620 --skip-build Don't perform nix-build.
561621 --skip-publish Don't publish built images.
562622 --image <image> Specify what image to build and/or upload.
@@ -594,6 +654,7 @@ ZCAT="zcat"
594654SEMVER=" semver"
595655YQ=" yq"
596656SCRIPT_DIR=$( dirname " $0 " )
657+ PARENT_ROOT=" $( realpath -es " $( get_parent) " 2> /dev/null || :) "
597658TAG=$( get_tag)
598659HASH=$( get_hash)
599660PRODUCT_PREFIX=${MAYASTOR_PRODUCT_PREFIX:- " " }
@@ -624,8 +685,7 @@ IMAGE_LOAD_TAR=
624685# Images which require helm chart dependency update
625686HELM_DEPS_IMAGES=${HELM_DEPS_IMAGES:- }
626687HELM_CHART_DIR=${HELM_CHART_DIR:- }
627- LOCAL_HELM=
628- NIX_SOURCES=$( realpath " ${NIX_SOURCES:- " $SCRIPT_DIR /../nix/sources.nix" } " )
688+ NIX_SOURCES=$( get_nix_src)
629689DEFAULT_COMMON_BINS=(" $CURL " " $DOCKER " " $TAR " " $RM " " $NIX_BUILD " " $ZCAT " " $NIX " )
630690COMMON_BINS=${COMMON_BINS:- " ${DEFAULT_COMMON_BINS[@]} " }
631691CONTAINER_LOAD=" yes"
0 commit comments