diff --git a/build-scripts/autogen b/build-scripts/autogen index 7037b0dee..fe3d664e7 100755 --- a/build-scripts/autogen +++ b/build-scripts/autogen @@ -32,9 +32,9 @@ nova) ;; *) if [ -z "${PROJECT}" ]; then - echo "$(basename "$0"): Error: Expected environment variable PROJECT=[community|nova]" + log_error "Expected environment variable PROJECT=[community|nova]" else - echo "$(basename "$0"): Error: Unknown project '$PROJECT', expected 'community' or 'nova'" + log_error "Unknown project '$PROJECT', expected 'community' or 'nova'" fi echo "Usage: PROJECT=[community|nova] $0" exit 42 @@ -51,15 +51,14 @@ fi # running the autogen.sh. for proj in $projects; do if [ ! -d "$BASEDIR/$proj" ]; then - echo "$(basename "$0"): Error: Expected to find the '$proj' repository in '$BASEDIR', but it's not there" - exit 1 + fatal "Expected to find the '$proj' repository in '$BASEDIR', but it's not there" fi done # Run autogen.sh on each repository for proj in $projects; do # autogen.sh is quite verbose, so only print the output in case of failure - echo "$(basename "$0"): Debug: Running autogen.sh for project $proj..." + log_debug "Running autogen.sh for project $proj..." ( cd "$BASEDIR/$proj" NO_CONFIGURE=1 run_and_print_on_failure ./autogen.sh diff --git a/build-scripts/bootstrap-tarballs b/build-scripts/bootstrap-tarballs index 89da8dd75..bf3b12c9d 100755 --- a/build-scripts/bootstrap-tarballs +++ b/build-scripts/bootstrap-tarballs @@ -94,12 +94,12 @@ cd "$BASEDIR"/core rm -f cfengine-3.*.tar.gz git rev-parse HEAD >"$BASEDIR"/output/core-commitID # Configure in order to run "make dist", deleted later. -echo "$(basename "$0"): Debug: Running configure on core repository..." +log_debug "Running configure on core repository..." run_and_print_on_failure ./configure -C -echo "$(basename "$0"): Debug: Running make dist on core repository..." +log_debug "Running make dist on core repository..." run_and_print_on_failure make dist mv cfengine-3.*.tar.gz "$BASEDIR"/output/tarballs/ -echo "$(basename "$0"): Debug: Running make distclean on core repository..." +log_debug "Running make distclean on core repository..." run_and_print_on_failure make distclean # Build tarballs from masterfiles repository @@ -107,14 +107,14 @@ cd "$BASEDIR"/masterfiles rm -f cfengine-masterfiles*.tar.gz git rev-parse HEAD >"$BASEDIR"/output/masterfiles-commitID # Configure in order to run "make dist", deleted later. -echo "$(basename "$0"): Debug: Running configure on masterfiles repository..." +log_debug "Running configure on masterfiles repository..." run_and_print_on_failure ./configure -echo "$(basename "$0"): Debug: Running make dist on masterfiles repository..." +log_debug "Running make dist on masterfiles repository..." run_and_print_on_failure make dist # source tarball -echo "$(basename "$0"): Debug: Running make tar-package on masterfiles repository..." +log_debug "Running make tar-package on masterfiles repository..." run_and_print_on_failure make tar-package # package tarball (containing all files as if they were installed under "prefix".) mv cfengine-masterfiles*.tar.gz "$BASEDIR"/output/tarballs/ -echo "$(basename "$0"): Debug: Running make distclean on masterfiles repository..." +log_debug "Running make distclean on masterfiles repository..." run_and_print_on_failure make distclean # Compute a checksum list that can be used to verify the integrity of the @@ -126,7 +126,7 @@ sha256sum -- *.tar.gz >sha256sums.txt CKSUM=$(sum sha256sums.txt | cut -d ' ' -f 1) mv sha256sums.txt sha256sums."$CKSUM".txt -echo "$(basename "$0"): Debug: Installing javascript npm dependencies..." +log_debug "Installing javascript npm dependencies..." ( if test -f "$BASEDIR"/mission-portal/public/scripts/package.json; then cd "$BASEDIR"/mission-portal/public/scripts @@ -142,7 +142,7 @@ echo "$(basename "$0"): Debug: Installing javascript npm dependencies..." fi ) -echo "$(basename "$0"): Debug: Installing PHP composer dependencies from mission-portal repository..." +log_debug "Installing PHP composer dependencies from mission-portal repository..." ( if test -f "$BASEDIR"/mission-portal/composer.json; then cd "$BASEDIR"/mission-portal @@ -151,7 +151,7 @@ echo "$(basename "$0"): Debug: Installing PHP composer dependencies from mission fi ) -echo "$(basename "$0"): Debug: Installing PHP composer dependencies from nova repository..." +log_debug "Installing PHP composer dependencies from nova repository..." ( if test -f "$BASEDIR"/nova/api/http/composer.json; then cd "$BASEDIR"/nova/api/http @@ -160,7 +160,7 @@ echo "$(basename "$0"): Debug: Installing PHP composer dependencies from nova re fi ) -echo "$(basename "$0"): Debug: Compiling Mission Portal styles..." +log_debug "Compiling Mission Portal styles..." ( if test -f "$BASEDIR"/mission-portal/public/themes/default/bootstrap/cfengine_theme.less; then cd "$BASEDIR"/mission-portal/public/themes/default/bootstrap @@ -168,7 +168,7 @@ echo "$(basename "$0"): Debug: Compiling Mission Portal styles..." fi ) -echo "$(basename "$0"): Debug: Installing LDAP API PHP composer dependencies..." +log_debug "Installing LDAP API PHP composer dependencies..." ( if test -f "$BASEDIR"/mission-portal/ldap/composer.json; then cd "$BASEDIR"/mission-portal/ldap diff --git a/build-scripts/clean-buildmachine b/build-scripts/clean-buildmachine index 93f0c6e5c..6ea134c57 100755 --- a/build-scripts/clean-buildmachine +++ b/build-scripts/clean-buildmachine @@ -12,11 +12,10 @@ uninstall_cfbuild if [ -z "$PREFIX" ] || [ "$PREFIX" = "/" ]; then - echo "$(basename "$0"): Error: \$PREFIX is not defined, is empty, or is set to the root directory. Aborting to prevent accidental deletion." - exit 1 + fatal "\$PREFIX is not defined, is empty, or is set to the root directory. Aborting to prevent accidental deletion." fi -echo "$(basename "$0"): Debug: Cleaning build host by deleting $PREFIX" +log_debug "Cleaning build host by deleting $PREFIX" case $OS in aix) sudo rm -rf "$PREFIX"/* diff --git a/build-scripts/compare-versions b/build-scripts/compare-versions index a567ee73f..1e9f66aef 100755 --- a/build-scripts/compare-versions +++ b/build-scripts/compare-versions @@ -32,9 +32,9 @@ nova) ;; *) if [ -z "${PROJECT}" ]; then - echo "$(basename "$0"): Error: Expected environment variable PROJECT=[community|nova]" + log_error "Expected environment variable PROJECT=[community|nova]" else - echo "$(basename "$0"): Error: Unknown project '$PROJECT', expected 'community' or 'nova'" + log_error "Unknown project '$PROJECT', expected 'community' or 'nova'" fi echo "Usage: PROJECT=[community|nova] $0" exit 42 @@ -59,7 +59,7 @@ for proj_i in $projects; do version_j=$(<"$BASEDIR/$proj_j/CFVERSION" tr ' ' '\n' | sed -e 's/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/') if [ "$version_i" != "$version_j" ]; then - echo "$(basename "$0"): Error: Detected version mismatch: $proj_i $version_i != $proj_j $version_j" + log_error "Detected version mismatch: $proj_i $version_i != $proj_j $version_j" exit 33 fi done diff --git a/build-scripts/compile b/build-scripts/compile index 75746cf6a..c9c5aafa4 100755 --- a/build-scripts/compile +++ b/build-scripts/compile @@ -28,30 +28,30 @@ nova) NOVA=yes ;; *) - echo "$(basename "$0"): Error: Unknown project '$PROJECT'" + log_error "Unknown project '$PROJECT'" exit 42 ;; esac -echo "$(basename "$0"): Debug: Running make in core repo..." +log_debug "Running make in core repo..." run_and_print_on_failure "$MAKE" -C "$BASEDIR"/core -k -echo "$(basename "$0"): Debug: Running make install in core repo..." +log_debug "Running make install in core repo..." run_and_print_on_failure "$MAKE" -C "$BASEDIR"/core install DESTDIR="$BASEDIR"/cfengine/dist if [ "$NOVA" = yes ]; then - echo "$(basename "$0"): Debug: Running make in enterprise repo..." + log_debug "Running make in enterprise repo..." run_and_print_on_failure "$MAKE" -C "$BASEDIR"/enterprise -k - echo "$(basename "$0"): Debug: Running make install in enterprise repo..." + log_debug "Running make install in enterprise repo..." run_and_print_on_failure "$MAKE" -C "$BASEDIR"/enterprise install DESTDIR="$BASEDIR"/cfengine/dist if [ "$ROLE" = hub ]; then - echo "$(basename "$0"): Debug: Running make in nova repo..." + log_debug "Running make in nova repo..." run_and_print_on_failure "$MAKE" -C "$BASEDIR"/nova -k - echo "$(basename "$0"): Debug: Running make install in nova repo..." + log_debug "Running make install in nova repo..." run_and_print_on_failure "$MAKE" -C "$BASEDIR"/nova install DESTDIR="$BASEDIR"/cfengine/dist - echo "$(basename "$0"): Debug: Running make install in masterfiles repo..." + log_debug "Running make install in masterfiles repo..." run_and_print_on_failure "$MAKE" -C "$BASEDIR"/masterfiles install DESTDIR="$BASEDIR"/cfengine/dist fi else - echo "$(basename "$0"): Debug: Running make install in masterfiles repo..." + log_debug "Running make install in masterfiles repo..." run_and_print_on_failure "$MAKE" -C "$BASEDIR"/masterfiles install DESTDIR="$BASEDIR"/cfengine/dist fi diff --git a/build-scripts/detect-environment b/build-scripts/detect-environment index 2dea044c6..5c6db9d42 100644 --- a/build-scripts/detect-environment +++ b/build-scripts/detect-environment @@ -32,9 +32,9 @@ detect_cross_target() { esac if [ -n "$CROSS_TARGET" ]; then - echo "Detected cross target $CROSS_TARGET" + log_debug "Detected cross target $CROSS_TARGET" else - echo "No cross target detected" + log_debug "No cross target detected" fi } @@ -91,7 +91,7 @@ detect_os() { OS_VERSION=$UNAME_R ;; *) - echo "Unable to detect operating system: $UNAME_S" + log_error "Unable to detect operating system: $UNAME_S" exit 42 ;; esac @@ -101,12 +101,12 @@ detect_os() { OS=mingw ;; *) - echo "Unknown cross-compilation target: $CROSS_TARGET" + log_error "Unknown cross-compilation target: $CROSS_TARGET" exit 42 ;; esac - echo "Detected OS $OS $OS_VERSION" + log_debug "Detected OS $OS $OS_VERSION" export OS OS_VERSION } @@ -129,7 +129,7 @@ detect_distribution() { OS=rhel ;; *) - echo "Error: Could not determine Linux distro from /etc/redhat-release: $REL" + log_error "Could not determine Linux distro from /etc/redhat-release: $REL" exit 42 ;; esac @@ -141,7 +141,7 @@ detect_distribution() { # Make sure we actually found a match if [ -z "$version_string" ]; then - echo "Error: Could not determine version number from /etc/redhat-release: $REL" + log_error "Could not determine version number from /etc/redhat-release: $REL" exit 42 fi OS_VERSION=$version_string @@ -173,7 +173,7 @@ detect_distribution() { case "$REL" in [0-9][0-9].[0-9][0-9]) ;; *) - echo "Unknown Ubuntu release: $REL" + log_error "Unknown Ubuntu release: $REL" exit 42 ;; esac @@ -188,7 +188,7 @@ detect_distribution() { REL=$(cat /etc/debian_version) if ! echo "$REL" | grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' >/dev/null; then - echo "Unable to detect version of Debian: $REL" + log_error "Unable to detect version of Debian: $REL" exit 42 fi @@ -222,12 +222,12 @@ detect_distribution() { fi if [ -z "$OS" ]; then - echo "Failed to detect Linux distribution" + log_error "Failed to detect Linux distribution" exit 42 fi if [ -z "$OS_VERSION" ]; then - echo "Failed to detect Linux distribution version" + log_error "Failed to detect Linux distribution version" exit 42 fi } @@ -252,7 +252,7 @@ detect_packaging() { elif [ -f /usr/sbin/swinstall ]; then DEP_PACKAGING=hpux else - echo "Unknown packaging system" + log_error "Unknown packaging system" exit 42 fi @@ -268,8 +268,8 @@ detect_packaging() { ;; esac - echo "Detected dependency packaging $DEP_PACKAGING" - echo "Detected packaging $PACKAGING" + log_debug "Detected dependency packaging $DEP_PACKAGING" + log_debug "Detected packaging $PACKAGING" export DEP_PACKAGING PACKAGING } @@ -293,7 +293,8 @@ detect_arch() { ARCH=i86pc ;; *) - echo "Unknown Solaris architecture: $UNAME_M" + log_error "Unknown Solaris architecture: $UNAME_M" + exit 42 ;; esac ;; @@ -305,7 +306,7 @@ detect_arch() { ARCH=$UNAME_M ;; *) - echo "Unknown packaging system" + log_error "Unknown packaging system" exit 42 ;; esac @@ -322,12 +323,12 @@ detect_arch() { ARCH=x64 ;; *) - echo "Unknown cross-compilation target: $CROSS_TARGET" + log_error "Unknown cross-compilation target: $CROSS_TARGET" exit 42 ;; esac - echo "Detected architecture $ARCH" + log_debug "Detected architecture $ARCH" export ARCH } @@ -341,9 +342,9 @@ detect_tools() { if $MAKE -v | grep GNU; then export MAKE - echo "Detected make path $MAKE" + log_debug "Detected make path $MAKE" else - echo "Error: GNU Make not found" + log_error "GNU Make not found" exit 42 fi @@ -353,12 +354,12 @@ detect_tools() { # systems. We use it to kill processes that can mess with the build process. FUSER=$(func_whereis fuser) export FUSER - echo "Detected fuser path $FUSER" + log_debug "Detected fuser path $FUSER" # We use patch to apply patches to the dependencies. PATCH=$(func_whereis gpatch patch) export PATCH - echo "Detected patch path $PATCH" + log_debug "Detected patch path $PATCH" } # This function appends the -j/--jobs option to the MAKEFLAGS environment @@ -368,29 +369,29 @@ detect_tools() { detect_cores() { case "$OS_FAMILY" in aix) - echo "Detected OS family is aix" + log_debug "Detected OS family is aix" NUM_CORES="$(lscfg | grep -c proc)" ;; solaris) - echo "Detected OS family is solaris" + log_debug "Detected OS family is solaris" NUM_CORES="$(psrinfo | wc -l)" ;; linux) - echo "Detected OS family is linux" + log_debug "Detected OS family is linux" NUM_CORES="$(grep -c '^processor' /proc/cpuinfo)" ;; hpux) - echo "Detected OS family is hpux" + log_debug "Detected OS family is hpux" NUM_CORES="$(ioscan -k -C processor | grep -c processor)" ;; *) - echo "Detected OS family is UNKNOWN, defaulting amount of CPU cores to 1" + log_debug "Detected OS family is UNKNOWN, defaulting amount of CPU cores to 1" NUM_CORES=1 ;; esac # Make number of jobs one higher than core count, to account for I/O, network, etc. - echo "Detected amount of CPU cores is $NUM_CORES" + log_debug "Detected amount of CPU cores is $NUM_CORES" MAKEFLAGS="${MAKEFLAGS:--j$((NUM_CORES + 1))}" export MAKEFLAGS }