Skip to content

Commit

Permalink
Merge pull request #767 from lnussel/fix_build_as_user
Browse files Browse the repository at this point in the history
Fix build as user
  • Loading branch information
adrianschroeter committed Jan 25, 2022
2 parents 7525411 + 247fbc5 commit f7b1d23
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ BUILD_FLAVOR=
OBS_PACKAGE=
OBSURL=
NO_TIMESTAMPS=
CACHE_DIR=/var/cache/build
BUILD_DIST_TMP=
BUILD_SUCCEEDED=
COPY_SOURCES_ASIS=
Expand Down Expand Up @@ -991,6 +990,8 @@ trap fail_exit EXIT

. $BUILD_DIR/common_functions || exit 1

detect_cache_dir

shopt -s nullglob

export PATH=$BUILD_DIR:/sbin:/usr/sbin:/bin:/usr/bin:$PATH
Expand Down
7 changes: 5 additions & 2 deletions build-vm
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,13 @@ vm_setup() {
if test -n "$VM_USE_MKFS_COPYIN" ; then
echo "Using mkfs copyin mode to populate the root filesystem"
mkdir_build_root
rm -rf "$BUILD_ROOT"/* "$BUILD_ROOT"/.[^.]*
if test ! -w /root ; then
find "$BUILD_ROOT" -type d -not -perm /200 -print0 | xargs -0 --no-run-if-empty chmod +w
fi
find "$BUILD_ROOT" -mindepth 1 -maxdepth 1 -print0 | xargs -0 --no-run-if-empty rm -rf
if test -z "$CLEAN_BUILD" -a -e "$VM_ROOT" ; then
echo "Recovering former build root"
debugfs -f <(echo rdump / "$BUILD_ROOT") "$VM_ROOT"
debugfs -f <(echo rdump / "$BUILD_ROOT") "$VM_ROOT" 2>/dev/null
fi
fi
local clean_build="$CLEAN_BUILD"
Expand Down
8 changes: 8 additions & 0 deletions common_functions
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,11 @@ assert_dir_path() {
test "$1" != "${1%/*}" && assert_dir_path "${1%/*}"
assert_dirs "$1"
}

detect_cache_dir() {
if test -w /; then
CACHE_DIR=/var/cache/build
else
CACHE_DIR=${XDG_CACHE_HOME:-~/.cache}/opensuse.org/build/cache
fi
}
3 changes: 2 additions & 1 deletion init_buildsystem
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ repos=()

. $BUILD_DIR/common_functions || exit 1

detect_cache_dir

# should RPMs be installed with --force ?
USE_FORCE=false
PREPARE_VM=
Expand All @@ -58,7 +60,6 @@ RPMLIST=
CLEAN_BUILD=
CREATE_BUILD_BINARIES=
DLNOSIGNATURE=
CACHE_DIR=/var/cache/build
OBSURL=
BUILD_SYSROOT=
test -z "$CONFIG_DIR" && CONFIG_DIR="$BUILD_DIR/configs"
Expand Down

0 comments on commit f7b1d23

Please sign in to comment.