Skip to content
Open
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
109 changes: 57 additions & 52 deletions build

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build-pkg-rpm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


pkg_initdb_rpm() {
echo "initializing rpm db..."
log_info "initializing rpm db..."
mkdir -p $BUILD_ROOT/var/lib/rpm
# rpm v5 does not have initdb
if ! test -e $BUILD_ROOT/usr/lib/rpm/cpuinfo.yaml ; then
Expand Down Expand Up @@ -174,7 +174,7 @@ pkg_sysrootinstall_rpm() {

pkg_finalize_rpm() {
if test -n "${CUMULATED_LIST[*]}" ; then
echo "now installing cumulated packages"
log_info "now installing cumulated packages"
for ((num=0; num<=cumulate; num++)) ; do
echo ${CUMULATED_LIST[$num]}
PKG=${CUMULATED_LIST[$num]##*/}
Expand Down
2 changes: 1 addition & 1 deletion build-recipe
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ recipe_create_changelog() {
if [ "$(queryconfig --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" buildflags changelogfulltimestamps)" = 1 ] ; then
changelog2specargs="--fulltimestamps $changelog2specargs"
fi
echo "running changelog2spec $changelog2specargs --file $1"
log_info "running changelog2spec $changelog2specargs --file $1"
if ! $BUILD_DIR/changelog2spec $changelog2specargs --timestampfile "$BUILD_ROOT/.build-changelog-timestamp" --file "$1" > $BUILD_ROOT/.build-changelog ; then
rm -f $BUILD_ROOT/.build-changelog $BUILD_ROOT/.build-changelog-timestamp
fi
Expand Down
6 changes: 3 additions & 3 deletions build-recipe-spec
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ recipe_run_rpmlint() {
-o -name "*-x86-*" -o -name "*-ia32-*" \) -prune \
-o -type f -name '*.rpm' -print))
SRPM_FILE_LIST=($(find $BUILD_ROOT/$TOPDIR/SRPMS -type f -name "*.rpm"))
echo
echo "RPMLINT report:"
echo "==============="
echo
log_info "RPMLINT report:"
log_info "==============="
rpmlint_logfile=$TOPDIR/OTHER/rpmlint.log
rm -f "$BUILD_ROOT$rpmlint_logfile"
ret=0
Expand Down
15 changes: 8 additions & 7 deletions build-vm
Original file line number Diff line number Diff line change
Expand Up @@ -612,22 +612,23 @@ vm_detect_2nd_stage() {
fi

test -n "$VM_WATCHDOG" -a -z "$PERSONALITY_SET" && echo "### VM INTERACTION END ###"
echo "2nd stage started in virtual machine"
log_info "2nd stage started in virtual machine"
# fedora packages sometimes do not have the needed links
ldconfig
BUILD_ROOT=/
BUILD_DIR=/.build
echo "machine type: `uname -m`"
echo "Linux version: `uname -rv`"
echo "Time: `date`"
log_info "machine type: `uname -m`"
log_info "Linux version: `uname -rv`"
log_info "Time: `date`"

if test -z "$VM_TYPE_CONTAINER"; then
echo "Increasing log level from now on..."
log_info "Increasing log level from now on..."
echo 4 > /proc/sysrq-trigger
echo "Enable sysrq operations"
log_info "Enable sysrq operations"
echo 1 > /proc/sys/kernel/sysrq
if test "$PERSONALITY" != 0 -a -z "$PERSONALITY_SET" ; then
export PERSONALITY_SET=true
echo "switching personality to $PERSONALITY..."
log_info "switching personality to $PERSONALITY..."
# this is 32bit perl/glibc, thus the 32bit syscall number
exec perl -e 'syscall(136, '$PERSONALITY') == -1 && warn("personality: $!\n");exec "/.build/build" || die("/.build/build: $!\n")'
fi
Expand Down
2 changes: 1 addition & 1 deletion build-vm-podman
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ vm_wipe_podman() {
local name="build_${RECIPEFILE//:/-}"
podman rm "$name" >/dev/null 2>&1 || true

echo "Wiping build root: '$BUILD_ROOT'"
log_info "Wiping build root: '$BUILD_ROOT'"
unmount_build_root
# calling 'podman unshare' is required because podman creates the files with SubUIDs/SubGIDs
# that differ from user's UID/GID and removing them would normally end up with
Expand Down
85 changes: 78 additions & 7 deletions common_functions
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ set_build_arch() {
BUILD_ARCH="$BUILD_HOST_ARCH"
fi
extend_build_arch
if test "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then
cpuflags=`grep ^flags /proc/cpuinfo`
cpuflags="$cpuflags "
if test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}"; then
echo "Your cpu doesn't support i686 rpms. Exit."
cleanup_and_exit 1
fi
if test "$BUILD_ARCH" != "${BUILD_ARCH#i686}"; then
cpuflags=$(grep ^flags /proc/cpuinfo)
cpuflags="$cpuflags "
if test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}"; then
log_error "Your cpu doesn't support i686 rpms. Exit."
cleanup_and_exit 1
fi
fi
}

Expand Down Expand Up @@ -202,3 +202,74 @@ detect_cache_dir() {
CACHE_DIR=${XDG_CACHE_HOME:-~/.cache}/opensuse.org/build/cache
fi
}

COLORS_ENABLED=${COLORS_ENABLED:-auto}

setup_color_vars() {

# https://no-color.org/
if test -n "$NO_COLOR"; then
COLORS_ENABLED=false
else
if test "$COLORS_ENABLED" = auto; then
if test -t 1; then
COLORS_ENABLED=true
else
COLORS_ENABLED=false
fi
fi
fi

if [ "$COLORS_ENABLED" = true ]; then
ESC="$(printf '\033')"
RED="${ESC}[0;31m"
GREEN="${ESC}[0;32m"
YELLOW="${ESC}[0;33m"
BLUE="${ESC}[0;34m"
BOLD="${ESC}[1m"
RESET="${ESC}[0m"
else
RED=''
GREEN=''
YELLOW=''
BLUE=''
BOLD=''
RESET=''
fi
}

export COLORS_ENABLED
export -f setup_color_vars >/dev/null 2>&1 || true

##################
# Logging helpers
##################

_log_print() {
prefix="$1"
shift
color="$1"
shift || true
if [ -n "${color}" ]; then
printf "%s%s%s %s\n" "${color}" "${prefix}" "${RESET}" "$*"
else
printf "%s%s\n" "${prefix}" "$*"
fi
}

log_info() { _log_print "build:" "${BOLD-}" "$*"; }
log_warn() { _log_print "build: WARN:" "${YELLOW-}" "$*"; }
log_ok() { _log_print "build: OK:" "${GREEN-}" "$*"; }
log_error() { _log_print "error:" "${BOLD-}${RED-}" "$*" >&2; }

stage_name="unknown"
stage_start() {
stage_name="$1"
shift
log_info "${BOLD-}==> Starting ${stage_name}${RESET-}"
}

stage_end() {
log_info "${BOLD-}<== Finished ${stage_name}${RESET-}"
stage_name="unknown"
}
27 changes: 14 additions & 13 deletions init_buildsystem
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ repos_baseurl=()
repos_cachedir=()

. $BUILD_DIR/common_functions || exit 1
setup_color_vars || echo "Failed to setup colored output"

# should RPMs be installed with --force ?
USE_FORCE=false
Expand Down Expand Up @@ -140,7 +141,7 @@ done
PKGS=("$@")

if test -z "$BUILD_ROOT" ; then
echo "Please specify a build root!"
log_error "Please specify a build root!"
exit 1
fi
test -z "$CACHE_DIR" && detect_cache_dir
Expand Down Expand Up @@ -218,10 +219,10 @@ clean_build_root() {
unsafe_preinstall_check() {
# cpio isn't safe so we require bsdtar for VMs. chroot is
# unsafe anyways so it's ok for that.
if test -n "$PREPARE_VM" ; then
echo "Error: setting up a VM requires bsdtar for security reasons."
echo "Please install bsdtar."
cleanup_and_exit 1
if test -n "$PREPARE_VM"; then
log_error "setting up a VM requires bsdtar for security reasons."
log_error "Please install bsdtar."
cleanup_and_exit 1
fi
}

Expand Down Expand Up @@ -282,7 +283,7 @@ preinstall_integrate() {

preinstall_image() {
check_exit
echo "unpacking preinstall image${2:+ $2}"
info "Unpacking preinstall image${2:+ $2}"
preinstall_setup

TAR_EXCLUDES="--exclude .build --exclude .init_b_cache"
Expand All @@ -298,11 +299,11 @@ preinstall_image() {
unsafe_preinstall_check
TAR="tar $TAR_EXCLUDES -x"
fi
if ! $TAR -f "$BUILD_INIT_CACHE/rpms/$1" ; then
echo "ERROR: unpack failed."
if test "x$(od -t x4 -A n -N 4 "$BUILD_INIT_CACHE/rpms/$1")" = "x fd2fb528" ; then
echo "ERROR: This is a .zst compressed preinstallimage and $TAR failed to unpack."
echo "Try to enable zst in $TAR or disable preinstallimage."
if ! $TAR -f "$BUILD_INIT_CACHE/rpms/$1"; then
log_error "Unpack failed!"
if test "x$(od -t x4 -A n -N 4 "$BUILD_INIT_CACHE/rpms/$1")" = "x fd2fb528"; then
log_error "This is a .zst compressed preinstallimage and $TAR failed to unpack."
log_error "Try to enable zst in $TAR or disable preinstallimage."
fi
cleanup_and_exit 1
fi
Expand Down Expand Up @@ -454,7 +455,7 @@ create_cache_file() {
fi

# nope, generate a new cache file
test -z "$LIST_STATE" && echo initializing $CACHE_FILE ...
test -z "$LIST_STATE" && info "Initializing $CACHE_FILE..."

# figure out a repository type default
find_default_repotype
Expand Down Expand Up @@ -520,7 +521,7 @@ downloadpkg() {
SRC=${SRC/%.pkg.tar.?z/.arch}
local destdir="$cachedir/tmp"
mkdir -p "$destdir"
echo "downloading $url ... ";
info "Downloading $url..."
$BUILD_DIR/download "$destdir" "$url" || cleanup_and_exit 1
local destfile="$destdir/${url##*/}"
if test ! -e "$destfile" ; then
Expand Down