kbuild: pacman-pkg: move common commands to a separate function
PATCH 1/2 kbuild: pacman-pkg: move common commands to a separate function
All build and package functions share the following commands:
export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
cd "${objtree}"Factor out the common code.
---
scripts/package/PKGBUILD | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
scripts/package/PKGBUILD +10 -7
@@ -36,11 +36,15 @@ makedepends=( ) options=(!debug !strip !buildflags !makeflags) -build() { +_prologue() { # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild. # Bypass this override with a custom variable. export MAKEFLAGS="${KBUILD_MAKEFLAGS}" cd "${objtree}" +} + +build() { + _prologue ${MAKE} KERNELRELEASE="${KERNELRELEASE}" KBUILD_BUILD_VERSION="${pkgrel}" }
@@ -48,10 +52,10 @@ build() { _package() { pkgdesc="The ${pkgdesc} kernel and modules" - export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}" local modulesdir="${pkgdir}/usr/${MODLIB}" + _prologue + echo "Installing boot image..." # systemd expects to find the kernel here to allow hibernation # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
@@ -76,10 +80,10 @@ _package() { _package-headers() { pkgdesc="Headers and scripts for building modules for the ${pkgdesc} kernel" - export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}" local builddir="${pkgdir}/usr/${MODLIB}/build" + _prologue + if grep -q CONFIG_MODULES=y include/config/auto.conf; then echo "Installing build files..." "${srctree}/scripts/package/install-extmod-build" "${builddir}"
@@ -100,8 +104,7 @@ _package-api-headers() { provides=(linux-api-headers) conflicts=(linux-api-headers) - export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}" + _prologue ${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr" }
Signature · 1 line
2.43.0
PATCH 2/2 kbuild: pacman-pkg: do not override objtree
objtree is defined and exported by the top-level Makefile. I prefer not to override it.
There is no need to pass the absolute pass of objtree. PKGBUILD can detect it by itself.
---
scripts/Makefile.package | 3 +-- scripts/package/PKGBUILD | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-)
scripts/Makefile.package +1 -2
@@ -147,8 +147,7 @@ snap-pkg: PHONY += pacman-pkg pacman-pkg: @ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD - +objtree="$(realpath $(objtree))" \ - BUILDDIR="$(realpath $(objtree))/pacman" \ + BUILDDIR="$(realpath $(objtree))/pacman" \ CARCH="$(UTS_MACHINE)" \ KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \ KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \
scripts/package/PKGBUILD +3 -1
@@ -40,7 +40,9 @@ _prologue() { # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild. # Bypass this override with a custom variable. export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}" + + # Kbuild works in the output directory, where this PKGBUILD is located. + cd "$(dirname "${BASH_SOURCE[0]}")" } build() {
Signature · 1 line
2.43.0
Re: [PATCH 2/2] kbuild: pacman-pkg: do not override objtree
Aug 16, 2024 16:18:56 Masahiro Yamada <[email protected]>:
Quoted 4 lines
objtree is defined and exported by the top-level
Makefile. I prefer not to override it.There is no need to pass the absolute pass of objtree. PKGBUILD can
s/pass/path/g
Quoted 3 lines
detect it by itself.
Signed-off-by Masahiro Yamada <[email protected]>
Quoted 37 lines
---
scripts/Makefile.package| 3 +--scripts/package/PKGBUILD| 4 +++-2 files changed, 4 insertions(+), 3 deletions(-)scripts/Makefile.package +0
-0@@ -147,8 +147,7 @@ snap-pkg:PHONY += pacman-pkg
pacman-pkg:
@ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD - +objtree="$(realpath $(objtree))" \
- BUILDDIR="$(realpath $(objtree))/pacman" \
+ BUILDDIR="$(realpath $(objtree))/pacman" \
CARCH="$(UTS_MACHINE)" \
KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \
KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \scripts/package/PKGBUILD +0
-0@@ -40,7 +40,9 @@ _prologue() { # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild. # Bypass this override with a custom variable.export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
- cd "${objtree}"
+
+ #Kbuildworks in the output directory, where this PKGBUILD is located. + cd "$(dirname "${BASH_SOURCE[0]}")"
}
build(){
--
2.43.0
Re: [PATCH 2/2] kbuild: pacman-pkg: do not override objtree
In reply to Masahiro YamadaQuoted 7 lines · Masahiro Yamada
objtree is defined and exported by the top-level
Makefile. I prefer not to override it.There is no need to pass the absolute pass of objtree. PKGBUILD can detect it by itself.
Signed-off-by Masahiro Yamada <[email protected]>
Quoted 38 lines
---
scripts/Makefile.package | 3 +-- scripts/package/PKGBUILD | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-)scripts/Makefile.package +1
-2@@ -147,8 +147,7 @@ snap-pkg: PHONY += pacman-pkg pacman-pkg: @ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD - +objtree="$(realpath $(objtree))" \ - BUILDDIR="$(realpath $(objtree))/pacman" \ + BUILDDIR="$(realpath $(objtree))/pacman" \ CARCH="$(UTS_MACHINE)" \ KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \ KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \scripts/package/PKGBUILD +3
-1@@ -40,7 +40,9 @@ _prologue() { # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild. # Bypass this override with a custom variable. export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}" + + # Kbuild works in the output directory, where this PKGBUILD is located. + cd "$(dirname "${BASH_SOURCE[0]}")" } build() {Signature · 1 line
2.43.0
Re: [PATCH 2/2] kbuild: pacman-pkg: do not override objtree
In reply to Masahiro YamadaQuoted 5 lines · Masahiro Yamada
objtree is defined and exported by the top-level
Makefile. I prefer not to override it.There is no need to pass the absolute pass of objtree. PKGBUILD can detect it by itself.
Thomas already spotted the typo in the sentence above :)
Quoted 2 lines
Signed-off-by Masahiro Yamada <[email protected]>---
Re: [PATCH 2/2] kbuild: pacman-pkg: do not override objtree
In reply to Masahiro YamadaQuoted 19 lines · Masahiro Yamada
objtree is defined and exported by the top-level
Makefile. I prefer not to override it.There is no need to pass the absolute pass of objtree. PKGBUILD can detect it by itself.
Signed-off-by Masahiro Yamada <[email protected]>---
scripts/Makefile.package | 3 +-- scripts/package/PKGBUILD | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-)scripts/Makefile.package +0
-0
scripts/Makefile.package snap-pkg: · line 150
Quoted 6 lines
scripts/Makefile.package +1
-2@@ -147,8 +147,7 @@ snap-pkg: PHONY += pacman-pkg pacman-pkg: @ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD - +objtree="$(realpath $(objtree))" \ - BUILDDIR="$(realpath $(objtree))/pacman" \ + BUILDDIR="$(realpath $(objtree))/pacman" \
I restored the '+' prefix
when I applied this.
Quoted 21 lines
scripts/Makefile.package +0
-0CARCH="$(UTS_MACHINE)" \ KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \ KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \scripts/package/PKGBUILD +3
-2@@ -40,7 +40,9 @@ _prologue() { # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild. # Bypass this override with a custom variable. export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}" + + # Kbuild works in the output directory, where this PKGBUILD is located. + cd "$(dirname "${BASH_SOURCE[0]}")" } build() { --2.43.0
Signature · 2 lines
Best Regards Masahiro Yamada
Aug 16, 2024 16:18:53 Masahiro Yamada <[email protected]>:
Quoted 8 lines
All build and package functions share the following commands:
export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
cd "${objtree}"Factor out the common code.
Signed-off-by Masahiro Yamada <[email protected]>
Quoted 64 lines
---
scripts/package/PKGBUILD| 17 ++++++++++-------1 file changed, 10 insertions(+), 7 deletions(-)scripts/package/PKGBUILD +1
-1@@ -36,11 +36,15 @@ makedepends=( ) options=(!debug !strip !buildflags !makeflags) -build() { +_prologue() { # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild. # Bypass this override with a custom variable.export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
cd "${objtree}"scripts/package/PKGBUILD +4
-0+} + +build() { + _prologue${MAKE} KERNELRELEASE="${KERNELRELEASE}" KBUILD_BUILD_VERSION="${pkgrel}" }
scripts/package/PKGBUILD +0
-0@@ -48,10 +52,10 @@ build() { _package() {pkgdesc="The ${pkgdesc} kernel and modules"
- export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
- cd "${objtree}"
local modulesdir="${pkgdir}/usr/${MODLIB}"+
_prologue
+
echo "Installing boot image..."# systemd expects to find the kernel here to allow hibernation # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344scripts/package/PKGBUILD +0
-0@@ -76,10 +80,10 @@ _package() { _package-headers() {pkgdesc="Headers and scripts for building modules for the ${pkgdesc} kernel"
- export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}"
local builddir="${pkgdir}/usr/${MODLIB}/build"+
_prologue
+
if grep -qCONFIG_MODULES=yinclude/config/auto.conf; then echo "Installing build files..." "${srctree}/scripts/package/install-extmod-build" "${builddir}"scripts/package/PKGBUILD +1
-2@@ -100,8 +104,7 @@ _package-api-headers() { provides=(linux-api-headers) conflicts=(linux-api-headers) - export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}" + _prologue${MAKE}
headers_installINSTALL_HDR_PATH="${pkgdir}/usr" }
--
2.43.0
Quoted 8 lines · Masahiro Yamada
All build and package functions share the following commands:
export MAKEFLAGS="${KBUILD_MAKEFLAGS}" cd "${objtree}"Factor out the common code.
Signed-off-by Masahiro Yamada <[email protected]>
Quoted 65 lines
---
scripts/package/PKGBUILD | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)scripts/package/PKGBUILD +10
-7@@ -36,11 +36,15 @@ makedepends=( ) options=(!debug !strip !buildflags !makeflags) -build() { +_prologue() { # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild. # Bypass this override with a custom variable. export MAKEFLAGS="${KBUILD_MAKEFLAGS}" cd "${objtree}" +} + +build() { + _prologue ${MAKE} KERNELRELEASE="${KERNELRELEASE}" KBUILD_BUILD_VERSION="${pkgrel}" }@@ -48,10 +52,10 @@ build() { _package() { pkgdesc="The ${pkgdesc} kernel and modules" - export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}" local modulesdir="${pkgdir}/usr/${MODLIB}" + _prologue + echo "Installing boot image..." # systemd expects to find the kernel here to allow hibernation # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344@@ -76,10 +80,10 @@ _package() { _package-headers() { pkgdesc="Headers and scripts for building modules for the ${pkgdesc} kernel" - export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}" local builddir="${pkgdir}/usr/${MODLIB}/build" + _prologue + if grep -q CONFIG_MODULES=y include/config/auto.conf; then echo "Installing build files..." "${srctree}/scripts/package/install-extmod-build" "${builddir}"@@ -100,8 +104,7 @@ _package-api-headers() { provides=(linux-api-headers) conflicts=(linux-api-headers) - export MAKEFLAGS="${KBUILD_MAKEFLAGS}" - cd "${objtree}" + _prologue ${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr" }Signature · 1 line
2.43.0
Quoted 9 lines · Masahiro Yamada
All build and package functions share the following commands:
export MAKEFLAGS="${KBUILD_MAKEFLAGS}" cd "${objtree}"Factor out the common code.
Signed-off-by Masahiro Yamada <[email protected]>---