From: Daan De Meyer Date: Wed, 8 Nov 2023 12:37:33 +0000 (+0100) Subject: building rpms from source doc improvements X-Git-Tag: v19~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f0f0b01d623abab11768f51748eaeffd9f08d40;p=thirdparty%2Fmkosi.git building rpms from source doc improvements - Use env --chdir= instead of spawning a shell - Document that scripts are executed in the same directory that mkosi is running in and get rid of all uses of $SRCDIR and $CHROOT_SRCDIR in favor of relative paths. We have to use $PWD when actually building the rpm as some macros expect the topdir to be an absolute path. --- diff --git a/docs/building-rpms-from-source.md b/docs/building-rpms-from-source.md index 7a84d4912..ebcfc7244 100644 --- a/docs/building-rpms-from-source.md +++ b/docs/building-rpms-from-source.md @@ -65,30 +65,30 @@ mkosi-chroot \ rpmspec \ --query \ "$DEPS" \ - --define "_topdir $CHROOT_SRCDIR/mkosi" \ - --define "_sourcedir $CHROOT_SRCDIR/mkosi/rpm" \ - "$CHROOT_SRCDIR/mkosi/rpm/mkosi.spec" | + --define "_topdir mkosi" \ + --define "_sourcedir mkosi/rpm" \ + mkosi/rpm/mkosi.spec | grep -E -v "mkosi" | xargs -d '\n' dnf install --best if [ "$1" = "build" ]; then until mkosi-chroot \ - sh -c 'cd $CHROOT_SRCDIR/mkosi && exec $0 "$@"' \ + env --chdir=mkosi \ rpmbuild \ -bd \ --build-in-place \ - --define "_topdir $CHROOT_SRCDIR/mkosi" \ - --define "_sourcedir $CHROOT_SRCDIR/mkosi/rpm" \ + --define "_topdir ." \ + --define "_sourcedir rpm" \ --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ - "$CHROOT_SRCDIR/mkosi/rpm/mkosi.spec" + rpm/mkosi.spec do EXIT_STATUS=$? if [ $EXIT_STATUS -ne 11 ]; then exit $EXIT_STATUS fi - dnf builddep "$SRCDIR"/mkosi/SRPMS/mkosi-*.buildreqs.nosrc.rpm - rm "$SRCDIR"/mkosi/SRPMS/mkosi-*.buildreqs.nosrc.rpm + dnf builddep mkosi/SRPMS/mkosi-*.buildreqs.nosrc.rpm + rm mkosi/SRPMS/mkosi-*.buildreqs.nosrc.rpm done fi ``` @@ -128,19 +128,18 @@ output directory (stored in `$OUTPUTDIR`). The build script #!/bin/sh set -e -cd "$SRCDIR/mkosi" - -rpmbuild \ +env --chdir=mkosi \ + rpmbuild \ -bb \ --build-in-place \ $([ "$WITH_TESTS" = "0" ] && echo --nocheck) \ - --define "_topdir $SRCDIR/mkosi" \ - --define "_sourcedir $SRCDIR/mkosi/rpm" \ + --define "_topdir $PWD" \ + --define "_sourcedir rpm" \ --define "_rpmdir $OUTPUTDIR" \ ${BUILDDIR:+--define} \ ${BUILDDIR:+"_vpath_builddir $BUILDDIR"} \ --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ - "$SRCDIR/mkosi/rpm/mkosi.spec" + rpm/mkosi.spec ``` The `_vpath_builddir` directory will be used to store out-of-tree build diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index 3cb16f2e1..94718651d 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -1534,8 +1534,8 @@ root or root within the user namespace that mkosi created when running unprivileged) with a customized environment to simplify modifying the image. For each script, the configured build sources (`BuildSources=`) are mounted into the current working directory before running the script -and `$SRCDIR` is set to point to the current working directory. The -following scripts are supported: +in the current working directory. `$SRCDIR` is set to point to the +current working directory. The following scripts are supported: * If **`mkosi.prepare`** (`PrepareScripts=`) exists, it is first called with the `final` argument, right after the software packages are