Skip to content

Commit

Permalink
build-in-place marker
Browse files Browse the repository at this point in the history
  • Loading branch information
lnussel committed Sep 19, 2022
1 parent db0bf8d commit 1275793
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
27 changes: 13 additions & 14 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export BUILD_DIST ABUILD_UID ABUILD_GID

icecream=0
definesnstuff=()
initbuildsys_recipeargs=()
repos=()
old_packages=()

Expand Down Expand Up @@ -849,7 +850,7 @@ copy_sources() {
fi
if test -n "$NO_SOURCE_COPY"; then
mount --bind "$MYSRCDIR" "$BUILD_ROOT$TOPDIR/SOURCES/"
elif test -n "$RUNNING_IN_VM" -o -n "$COPY_SOURCES_ASIS" -o -n "$RPM_BUILD_IN_PLACE" ; then
elif test -n "$RUNNING_IN_VM" -o -n "$COPY_SOURCES_ASIS" -o -n "$RECIPE_RPM_BUILD_IN_PLACE" ; then
( shopt -s nullglob ; cp -pRd "$1/".[^.]* "$1/"..?* "$1"/* "$2" )
elif test -n "$include_directories" ; then
cp -pRL "$1"/* "$2"
Expand All @@ -875,7 +876,7 @@ copy_sources() {
else
cp -p "$1"/* "$2"
fi
if test -n "$RPM_BUILD_IN_PLACE" -a -z "$RUNNING_IN_VM" -a -z "$NO_SOURCE_COPY"; then
if test -n "$RECIPE_RPM_BUILD_IN_PLACE" -a -z "$RUNNING_IN_VM" -a -z "$NO_SOURCE_COPY"; then
cp -f "$RECIPEPATH" "$2"
fi
}
Expand Down Expand Up @@ -1400,10 +1401,6 @@ if test -n "$OBSURL" ; then
initbuildsysstuff[${#initbuildsysstuff[@]}]="--obs"
initbuildsysstuff[${#initbuildsysstuff[@]}]="$OBSURL"
fi
if test -n "$RPM_BUILD_IN_PLACE"; then
initbuildsysstuff[${#initbuildsysstuff[@]}]="--define"
initbuildsysstuff[${#initbuildsysstuff[@]}]="_build_in_place 1"
fi

if test -n "$DO_WIPE" ; then
wipe_build_environment
Expand Down Expand Up @@ -1469,7 +1466,9 @@ if test -n "$LIST_STATE" ; then
test -d "$BUILD_ROOT" || cleanup_and_exit 3
RECIPEPATH=$RECIPEFILES # only one specified anyways
test "$RECIPEPATH" != "${RECIPEPATH%.src.rpm}" && recipe_unpack_srcrpm "$RECIPEPATH"
init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" --list-state "${initbuildsysstuff[@]}" "${definesnstuff[@]}" "${repos[@]}" $DLNOSIGNATURE $USEUSEDFORBUILD $RECIPEPATH $BUILD_EXTRA_PACKS
recipe_set_build_in_place "$RECIPEPATH"
compute_recipe_args "$RECIPEPATH"
init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" --list-state "${initbuildsysstuff[@]}" "${definesnstuff[@]}" "${initbuildsys_recipeargs[@]}" "${repos[@]}" $DLNOSIGNATURE $RECIPEPATH $BUILD_EXTRA_PACKS
ERR=$?
rm -rf "$BUILD_ROOT"
cleanup_and_exit $ERR
Expand Down Expand Up @@ -1561,7 +1560,9 @@ MODULEMDFILE=

for RECIPEPATH in "${RECIPEFILES[@]}" ; do

if test -n "$RPM_BUILD_IN_PLACE" -a -z "$RUNNING_IN_VM" -a -z "$NO_SOURCE_COPY" ; then
recipe_set_build_in_place "$RECIPEPATH"

if test -n "$RECIPE_RPM_BUILD_IN_PLACE" -a -z "$RUNNING_IN_VM" -a -z "$NO_SOURCE_COPY" ; then
SRCDIR="$PWD"
RECIPEFILE="${RECIPEPATH##*/}"
elif test -n "$NO_SOURCE_COPY" ; then
Expand Down Expand Up @@ -1665,11 +1666,9 @@ for RECIPEPATH in "${RECIPEFILES[@]}" ; do
Q="'\''"
test -n "$DISTURL" && echo "BUILD_DISTURL='${DISTURL//"'"/$Q}'" >> $BUILD_ROOT/.buildenv
test "$BUILDTYPE" = preinstallimage && mkdir -p $BUILD_ROOT/.preinstall_image
CREATE_BUILD_BINARIES=
if recipe_needs_build_binaries "$RECIPEPATH" ; then
CREATE_BUILD_BINARIES=--create-build-binaries
fi
set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" "${initbuildsysstuff[@]}" "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $DLNOSIGNATURE $USEUSEDFORBUILD $CREATE_BUILD_BINARIES $RPMLIST "$RECIPEPATH" $ADDITIONAL_PACKS
recipe_set_build_in_place "$RECIPEPATH"
compute_recipe_args "$RECIPEPATH"
set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" "${initbuildsysstuff[@]}" "${definesnstuff[@]}" "${initbuildsys_recipeargs[@]}" "${repos[@]}" $CLEAN_BUILD $DLNOSIGNATURE $USEUSEDFORBUILD $RPMLIST "$RECIPEPATH" $ADDITIONAL_PACKS
echo "$* ..."
start_time=$SECONDS
"$@" || cleanup_and_exit 1
Expand Down Expand Up @@ -1867,7 +1866,7 @@ for RECIPEPATH in "${RECIPEFILES[@]}" ; do
if test "$BUILD_SUCCEEDED" = genbuildreqs -a "$DO_INIT" = true -a -z "$RPMLIST" -a -z "$RUNNING_IN_VM" -a -n "${GEN_BUILDREQS_PACKS[*]}" ; then
# re-expand deps with GEN_BUILDREQS_PACKS extra packages
umount_stuff
set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" "${initbuildsysstuff[@]}" "${definesnstuff[@]}" "${repos[@]}" $DLNOSIGNATURE $USEUSEDFORBUILD $CREATE_BUILD_BINARIES $RPMLIST "$MYSRCDIR/$RECIPEFILE" $ADDITIONAL_PACKS "${GEN_BUILDREQS_PACKS[@]}"
set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" "${initbuildsysstuff[@]}" "${definesnstuff[@]}" "${initbuildsys_recipeargs[@]}" "${repos[@]}" $DLNOSIGNATURE $USEUSEDFORBUILD $RPMLIST "$MYSRCDIR/$RECIPEFILE" $ADDITIONAL_PACKS "${GEN_BUILDREQS_PACKS[@]}"
echo "$* ..."
"$@" || cleanup_and_exit 1
check_exit
Expand Down
22 changes: 22 additions & 0 deletions build-recipe
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,27 @@ recipe_needs_build_binaries() {
return 1
}

recipe_set_build_in_place() {
test "$BUILDTYPE" = spec || return 0
if test -n "$RPM_BUILD_IN_PLACE" || grep -E '^#[[:blank:]]*build-in-place[[:blank:]]*$' >/dev/null <"$1"; then
RECIPE_RPM_BUILD_IN_PLACE=1
else
unset RECIPE_RPM_BUILD_IN_PLACE
fi
}

compute_recipe_args() {
local recipe="$1"
initbuildsys_recipeargs=()
if recipe_needs_build_binaries "$recipe" ; then
initbuildsys_recipeargs+=('--create-build-binaries')
fi
if test -n "$RECIPE_RPM_BUILD_IN_PLACE"; then
initbuildsys_recipeargs+=('--define')
initbuildsys_recipeargs+=('_build_in_place 1')
fi
}

recipe_build_time_statistics() {
if test "$DO_STATISTICS" = 1 -a -n "$RECIPE_BUILD_START_TIME" -a -n "$TOPDIR" -a -n "$RUNNING_IN_VM" ; then
mkdir -p "$TOPDIR/OTHER"
Expand Down Expand Up @@ -290,3 +311,4 @@ recipe_gendiff() {
fi
}

# vim: syntax=sh
10 changes: 5 additions & 5 deletions build-recipe-spec
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ spec_init_topdir() {
-b[ci]\ --short-circuit) keepbuild=BUILD ;;
-bb\ --short-circuit | -bl) keepbuild=BUILD keepbuildroot=BUILDROOT ;;
esac
test -n "$RPM_BUILD_IN_PLACE" && unset keepbuild
test -n "$RECIPE_RPM_BUILD_IN_PLACE" && unset keepbuild
if test -n "$keepbuild$keepbuildroot" ; then
for d in $keepbuild $keepbuildroot ; do
spec_is_empty_dir "$BUILD_ROOT$TOPDIR/$d" && cleanup_and_exit 1 "need files in $TOPDIR/$d for '${rpmstages[0]}'"
done
for d in "$BUILD_ROOT$TOPDIR"/* "$BUILD_ROOT$TOPDIR"/.[^.]* ; do
test "$d" = "$BUILD_ROOT$TOPDIR/$keepbuild" -o "$d" = "$BUILD_ROOT$TOPDIR/$keepbuildroot" && continue
# safeguard in case umount from RPM_BUILD_IN_PLACE failed
# safeguard in case umount from RECIPE_RPM_BUILD_IN_PLACE failed
if mountpoint -q "$d"; then
cleanup_and_exit 1 "ERROR: $d is a mountpoint!?"
else
Expand Down Expand Up @@ -140,7 +140,7 @@ spec_setup_stages() {
stage=${stage//s/a}
# drop p/a stages in build-in-place mode unless requested
test -n "$RPM_NOPREP" -a "$stage" != p -a "$origstage" = "${origstage/p/}" && stage="${stage#p}"
test -n "$RPM_BUILD_IN_PLACE" -a "$stage" != a -a "$origstage" = "${origstage/[as]/}" && stage="${stage%a}"
test -n "$RECIPE_RPM_BUILD_IN_PLACE" -a "$stage" != a -a "$origstage" = "${origstage/[as]/}" && stage="${stage%a}"
rpmstages=()
case $stage in
p | pc | pci | pcib | pciba) rpmstages[${#rpmstages[@]}]="-b${stage: -1}" ; stage= ;;
Expand Down Expand Up @@ -183,7 +183,7 @@ recipe_build_spec() {
# use only --nosignature for rpm v4
rpmbopts[${#rpmbopts[@]}]="--nosignature"
fi
if test -n "$RPM_BUILD_IN_PLACE" ; then
if test -n "$RECIPE_RPM_BUILD_IN_PLACE" ; then
rpmbopts[${#rpmbopts[@]}]="--build-in-place"
fi
if test -n "$ABUILD_TARGET" ; then
Expand Down Expand Up @@ -268,7 +268,7 @@ recipe_build_spec() {
chmod 755 $BUILD_ROOT/.build.command
check_exit
local build_command="/.build.command"
test -n "$RPM_BUILD_IN_PLACE" && build_command="cd /.build.packages/SOURCES && $build_command"
test -n "$RECIPE_RPM_BUILD_IN_PLACE" && build_command="cd /.build.packages/SOURCES && $build_command"
chroot $BUILD_ROOT su -c "$build_command" - $BUILD_USER < /dev/null
st=$?
test "$st" = 0 || break
Expand Down

0 comments on commit 1275793

Please sign in to comment.