Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build-scripts/clean-buildmachine
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
. "$(dirname "$0")"/functions
. detect-environment

uninstall_cfbuild
log_debug "Removing all cfbuild packages..."
run_and_print_on_failure uninstall_cfbuild

if [ -z "$PREFIX" ] || [ "$PREFIX" = "/" ]; then
fatal "\$PREFIX is not defined, is empty, or is set to the root directory. Aborting to prevent accidental deletion."
Expand Down
41 changes: 11 additions & 30 deletions build-scripts/detect-environment
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ detect_cross_target() {
export CROSS_TARGET
;;
esac

if [ -n "$CROSS_TARGET" ]; then
log_debug "Detected cross target $CROSS_TARGET"
else
log_debug "No cross target detected"
fi
}

# This function exports operating system specific variables:
Expand Down Expand Up @@ -112,7 +106,6 @@ detect_os() {
OS_VERSION_MAJOR="${OS_VERSION%%.*}"
fi

log_debug "Detected OS $OS $OS_VERSION"
export OS OS_VERSION OS_VERSION_MAJOR
}

Expand Down Expand Up @@ -274,8 +267,6 @@ detect_packaging() {
;;
esac

log_debug "Detected dependency packaging $DEP_PACKAGING"
log_debug "Detected packaging $PACKAGING"
export DEP_PACKAGING PACKAGING
}

Expand Down Expand Up @@ -334,7 +325,6 @@ detect_arch() {
;;
esac

log_debug "Detected architecture $ARCH"
export ARCH
}

Expand All @@ -346,9 +336,8 @@ detect_tools() {
# various dependencies have various requirements
MAKE=$(func_whereis gmake make)

if $MAKE -v | grep GNU; then
if $MAKE -v | grep -q GNU; then
export MAKE
log_debug "Detected make path $MAKE"
else
log_error "GNU Make not found"
exit 42
Expand All @@ -360,12 +349,10 @@ detect_tools() {
# systems. We use it to kill processes that can mess with the build process.
FUSER=$(func_whereis fuser)
export FUSER
log_debug "Detected fuser path $FUSER"

# We use patch to apply patches to the dependencies.
PATCH=$(func_whereis gpatch patch)
export PATCH
log_debug "Detected patch path $PATCH"
}

# This function appends the -j/--jobs option to the MAKEFLAGS environment
Expand All @@ -375,19 +362,15 @@ detect_tools() {
detect_cores() {
case "$OS_FAMILY" in
aix)
log_debug "Detected OS family is aix"
NUM_CORES="$(lscfg | grep -c proc)"
;;
solaris)
log_debug "Detected OS family is solaris"
NUM_CORES="$(psrinfo | wc -l)"
;;
linux)
log_debug "Detected OS family is linux"
NUM_CORES="$(grep -c '^processor' /proc/cpuinfo)"
;;
hpux)
log_debug "Detected OS family is hpux"
NUM_CORES="$(ioscan -k -C processor | grep -c processor)"
;;
*)
Expand All @@ -397,7 +380,6 @@ detect_cores() {
esac

# Make number of jobs one higher than core count, to account for I/O, network, etc.
log_debug "Detected amount of CPU cores is $NUM_CORES"
MAKEFLAGS="${MAKEFLAGS:--j$((NUM_CORES + 1))}"
export MAKEFLAGS
}
Expand Down Expand Up @@ -425,15 +407,14 @@ detect_environment

# Print the environment variables so that the log can be used to debug problems
# stemming from wrong environment.
echo
echo
echo "==================== Current environment ========================"
# Print only what changed in the environment after sourcing this script
# - Lines staring with + are kept (these are things added to env)
# - Lines staring with +++ is filtered out (removes the "new file" header)
# - The + character is removed
env | sort | diff -u env_before - | grep '^\+' | grep -v '^+++' | sed 's/+//'
env_diff="$(env | sort | diff env_before - | grep '^>' | sed 's/^> //')"
unlink env_before
echo "================================================================="
echo
echo
if [ -n "$env_diff" ]; then
echo
echo
echo "======= Changes to environment after sourcing this script ======="
echo "$env_diff"
echo "================================================================="
echo
echo
fi
18 changes: 14 additions & 4 deletions build-scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,20 @@ run_and_print_on_failure() {
# Filter output on Warnings/Errors and add two lines of context
regex='([Ww]arning:|[Ee]rror:)'
if grep_q -E "$regex" "$temp_output_file"; then
log_debug "Found warnings/errors in output from command:" "$@"
echo "--- Start of Warnings/Errors ---"
grep_c 2 -E "$regex" "$temp_output_file"
echo "--- End of Warnings/Errors ---"
# Known-benign patterns that are not actionable and should be suppressed:
# - automake subdir-objects: forward-compatibility notice, harmless
# - libtool install warnings: normal when using DESTDIR
# shellcheck disable=SC3043
local benign='subdir-objects|libtool: warning: remember to run|libtool: warning:.*has not been installed|libtool: install:'
# shellcheck disable=SC3043
local filtered
filtered=$(grep_c 2 -E "$regex" "$temp_output_file" | grep -v -E "$benign") || true
if [ -n "$filtered" ]; then
log_debug "Found warnings/errors in output from command:" "$@"
echo "--- Start of Warnings/Errors ---"
printf '%s\n' "$filtered"
echo "--- End of Warnings/Errors ---"
fi
fi
else
# Print all output
Expand Down
4 changes: 2 additions & 2 deletions build-scripts/prepare-testmachine-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ CHROOT_ROOT=$HOME/testmachine-chroot/
sudo mkdir -p "$CHROOT_ROOT"

# Clean up previous chroot state by killing any processes that are using the CHROOT_ROOT directory.
sudo "$FUSER" -k "$CHROOT_ROOT" || true
sudo "$FUSER" -k "$CHROOT_ROOT" >/dev/null 2>&1 || true
# Unmount the /proc filesystem if it was previously mounted inside the chroot.
sudo umount "${CHROOT_ROOT}proc" || true
sudo umount "${CHROOT_ROOT}proc" >/dev/null 2>&1 || true

# Tell rsync not to touch the BASEDIR and PREFIX directories
echo "P $BASEDIR" >"$TRANSFER_SCRIPT"
Expand Down
6 changes: 3 additions & 3 deletions build-scripts/test-on-testmachine
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,23 @@ chroot)
# Minilogd may sometimes launch on RedHat without any user
# intervention. Ignore that.
# shellcheck disable=SC2009
if ps -ef | grep -E "^ *[^ ]+ +$pid" | grep minilogd; then
if ps -ef 2>/dev/null | grep -E "^ *[^ ]+ +$pid" | grep -q minilogd; then
continue
fi
;;
suse)

# gpg-agent sometimes is spawned on suse during our tests.
# This happens only in chroot. Ignore that.
if ps -o command --pid "$pid" | grep "gpg-agent --homedir /var/tmp/zypp.*zypp-trusted.*--daemon"; then
if ps -o command --pid "$pid" 2>/dev/null | grep -q "gpg-agent --homedir /var/tmp/zypp.*zypp-trusted.*--daemon"; then
continue
fi
;;
ubuntu)
# gpg-agent sometimes is spawned on Ubuntu 24 during our tests.
# This happens only in chroot. Ignore that.
if [ "$OS_VERSION_MAJOR" = "24" ]; then
if ps -o command --pid "$pid" | grep "gpg-agent --homedir /etc/apt/sources.list.d/.gnupg-temp --use-standard-socket --daemon"; then
if ps -o command --pid "$pid" 2>/dev/null | grep -q "gpg-agent --homedir /etc/apt/sources.list.d/.gnupg-temp --use-standard-socket --daemon"; then
continue
fi
fi
Expand Down
24 changes: 24 additions & 0 deletions ci/create_swap_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# bash is needed in order to use the "time" built-in and avoid needing
# an external utility.

set -e # exit on error

# Argument $1 is the size in megabytes
if [ x"$1" = x ] || echo "$1" | grep -q '[^0-9]'
then
exit 2
fi
SIZE="$1"

if swapon | grep /swapfile >/dev/null; then
echo "/swapfile already configured and setup. Exiting."
exit 0
fi

time dd if=/dev/zero of=/swapfile bs=1M count=$SIZE
chmod 0600 /swapfile

PATH=$PATH:/sbin:/usr/sbin
mkswap /swapfile
swapon /swapfile
Loading