Skip to content

Commit 3ab18a6

Browse files
committed
kbuild: deb-pkg: improve the usability of source package
Improve the source package support in case the dpkg-buildpackage is directly used to build binary packages. For cross-compiling, you can set CROSS_COMPILE via the environment variable, but it is better to set it automatically - set it to ${DEB_HOST_GNU_TYPE}- if we are cross-compiling but not from the top Makefile. The generated source package may be carried to a different build environment, which may have a different compiler installed. Run olddefconfig first to set new CONFIG options to their default values without prompting. Take KERNELRELEASE and KBUILD_BUILD_VERSION from the version field of debian/changelog in case it is updated afterwards. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent c5bf2ef commit 3ab18a6

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

scripts/package/deb-build-option

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0-only
3+
4+
# Set up CROSS_COMPILE if we are cross-compiling, but not called from the
5+
# kernel toplevel Makefile
6+
if [ -z "${CROSS_COMPILE}${cross_compiling}" -a "${DEB_HOST_ARCH}" != "${DEB_BUILD_ARCH}" ]; then
7+
echo CROSS_COMPILE=${DEB_HOST_GNU_TYPE}-
8+
fi
9+
10+
version=$(dpkg-parsechangelog -S Version)
11+
version_upstream="${version%-*}"
12+
debian_revision="${version#${version_upstream}}"
13+
debian_revision="${debian_revision#*-}"
14+
15+
echo KERNELRELEASE=${version_upstream}
16+
echo KBUILD_BUILD_VERSION=${debian_revision}

scripts/package/mkdebian

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ rm -rf debian
9090
version=$KERNELRELEASE
9191
if [ -n "$KDEB_PKGVERSION" ]; then
9292
packageversion=$KDEB_PKGVERSION
93-
revision=${packageversion##*-}
9493
else
95-
revision=$($srctree/init/build-version)
96-
packageversion=$version-$revision
94+
packageversion=$version-$($srctree/init/build-version)
9795
fi
9896
sourcename=${KDEB_SOURCENAME:-linux-upstream}
9997

@@ -244,8 +242,9 @@ srctree ?= .
244242
245243
build-indep:
246244
build-arch:
247-
\$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \
248-
KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile
245+
\$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \
246+
\$(shell \$(srctree)/scripts/package/deb-build-option) \
247+
olddefconfig all
249248
250249
build: build-arch
251250

0 commit comments

Comments
 (0)