Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
605ad88
UPSTREAM: kbuild: deb-pkg: apply short -R and -j options
dmitriib1 Nov 5, 2023
3de27d6
UPSTREAM: kbuild: deb-pkg: remove the fakeroot builds support
masahir0y Nov 28, 2023
091abea
UPSTREAM: kbuild: deb-pkg: split debian/copyright from the mkdebian s…
masahir0y Dec 19, 2023
e855818
UPSTREAM: kbuild: deb-pkg: hard-code Build-Depends
masahir0y Dec 19, 2023
9120b9b
UPSTREAM: kbuild: deb-pkg: factor out common Make options in debian/r…
masahir0y Dec 26, 2023
ee11908
UPSTREAM: kbuild: deb-pkg: squash scripts/package/deb-build-option to…
masahir0y Dec 26, 2023
3aac018
UPSTREAM: kbuild: deb-pkg: set DEB_* variables if debian/rules is dir…
masahir0y Dec 26, 2023
b24ef6c
UPSTREAM: kbuild: deb-pkg: allow to run debian/rules from output dire…
masahir0y Dec 26, 2023
24e43a7
UPSTREAM: kbuild: deb-pkg: remove unneeded '-f $srctree/Makefile' in …
masahir0y Dec 26, 2023
21ee9f4
UPSTREAM: kbuild: deb-pkg: use more debhelper commands in builddeb
masahir0y Dec 26, 2023
14d0aa7
UPSTREAM: kbuild: deb-pkg: use build ID instead of debug link for dbg…
masahir0y Dec 26, 2023
6ce3d8c
UPSTREAM: kbuild: deb-pkg: do not search for 'scripts' directory unde…
masahir0y Dec 30, 2023
c2cc8e8
UPSTREAM: kbuild: deb-pkg: move 'make headers' to build-arch
masahir0y Dec 30, 2023
cd7afe1
UPSTREAM: kbuild: deb-pkg: use debian/<package> for tmpdir
masahir0y Dec 30, 2023
800daf4
UPSTREAM: kbuild: deb-pkg: show verbose log for direct package builds
masahir0y Jan 13, 2024
2613eb1
UPSTREAM: kbuild: deb-pkg: make debian/rules quiet for 'make deb-pkg'
masahir0y Jan 13, 2024
efc018c
UPSTREAM: kbuild: deb-pkg: build binary-arch in parallel
masahir0y Jan 13, 2024
ae7c7a7
UPSTREAM: kbuild: deb-pkg: call more misc debhelper commands
masahir0y Jan 13, 2024
2a6ebce
BACKPORT: UPSTREAM: kbuild: move init/build-version to scripts/
masahir0y Jun 11, 2024
a0103bf
UPSTREAM: kbuild: deb-pkg: remove support for EMAIL environment variable
masahir0y Jul 2, 2024
bb1f9d2
UPSTREAM: kbuild: deb-pkg: remove support for "name <email>" form for…
masahir0y Jul 2, 2024
e2f778f
BACKPORT: UPSTREAM: kbuild: package: add -e and -u options to some sh…
masahir0y Jul 2, 2024
d7109f3
UPSTREAM: kbuild: deb-pkg: use default string when variable is unset …
masahir0y Jul 4, 2024
daa5fff
UPSTREAM: kbuild: deb-pkg: Remove blank first line from maint scripts
dev-aaront-org Oct 4, 2024
9727ab5
UPSTREAM: kbuild: slim down package for building external modules
masahir0y Jul 27, 2024
69047d0
UPSTREAM: kbuild: cross-compile linux-headers package when possible
masahir0y Jul 27, 2024
36fee70
UPSTREAM: kbuild: deb-pkg: add pkg.linux-upstream.nokernelheaders bui…
masahir0y Oct 22, 2024
8273636
UPSTREAM: kbuild: deb-pkg: add pkg.linux-upstream.nokerneldbg build p…
masahir0y Oct 22, 2024
e9aba05
UPSTREAM: kbuild: deb-pkg: Don't fail if modules.order is missing
mfleming Nov 7, 2024
3af452f
UPSTREAM: kbuild: deb-pkg: add python3:native to build dependency
masahir0y Nov 23, 2024
2a42fe4
UPSTREAM: kbuild: deb-pkg: fix build error with O=
masahir0y Dec 8, 2024
0d8e0b5
UPSTREAM: kbuild: deb-pkg: don't set KBUILD_BUILD_VERSION uncondition…
Mar 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion init/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CFLAGS_version.o := -include $(obj)/utsversion-tmp.h
# Build version-timestamp.c with final UTS_VERSION
#

include/generated/utsversion.h: build-version-auto = $(shell $(srctree)/$(src)/build-version)
include/generated/utsversion.h: build-version-auto = $(shell $(srctree)/$(src)/scripts/build-version)
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path to build-version is incorrect. The variable $(src) evaluates to init in this Makefile, so this would try to execute init/scripts/build-version which doesn't exist. The script has been moved to scripts/build-version, so this should be $(shell $(srctree)/scripts/build-version) instead.

Suggested change
include/generated/utsversion.h: build-version-auto = $(shell $(srctree)/$(src)/scripts/build-version)
include/generated/utsversion.h: build-version-auto = $(shell $(srctree)/scripts/build-version)

Copilot uses AI. Check for mistakes.
include/generated/utsversion.h: build-timestamp-auto = $(shell LC_ALL=C date)
include/generated/utsversion.h: FORCE
$(call filechk,uts_version)
Expand Down
4 changes: 1 addition & 3 deletions scripts/Makefile.package
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ debian-orig: linux.tar$(debian-orig-suffix) debian
cp $< ../$(orig-name); \
fi

KBUILD_PKG_ROOTCMD ?= 'fakeroot -u'

PHONY += deb-pkg srcdeb-pkg bindeb-pkg

deb-pkg: private build-type := source,binary
Expand All @@ -148,7 +146,7 @@ deb-pkg srcdeb-pkg bindeb-pkg:
$(if $(findstring source, $(build-type)), \
--unsigned-source --compression=$(KDEB_SOURCE_COMPRESS)) \
$(if $(findstring binary, $(build-type)), \
--rules-file='$(MAKE) -f debian/rules' --jobs=1 -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch), \
-R'$(MAKE) -f debian/rules' -j1 -a$$(cat debian/arch), \
--no-check-builddeps) \
$(DPKG_FLAGS))

Expand Down
File renamed without changes.
137 changes: 37 additions & 100 deletions scripts/package/builddeb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# specified in KDEB_HOOKDIR) that will be called on package install and
# removal.

set -e
set -eu

is_enabled() {
grep -q "^$1=y" include/config/auto.conf
Expand All @@ -24,45 +24,16 @@ if_enabled_echo() {
fi
}

create_package() {
local pname="$1" pdir="$2"
local dpkg_deb_opts

mkdir -m 755 -p "$pdir/DEBIAN"
mkdir -p "$pdir/usr/share/doc/$pname"
cp debian/copyright "$pdir/usr/share/doc/$pname/"
cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian"
gzip -n -9 "$pdir/usr/share/doc/$pname/changelog.Debian"
sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \
| xargs -r0 md5sum > DEBIAN/md5sums"

# Fix ownership and permissions
if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then
dpkg_deb_opts="--root-owner-group"
else
chown -R root:root "$pdir"
fi
# a+rX in case we are in a restrictive umask environment like 0077
# ug-s in case we build in a setuid/setgid directory
chmod -R go-w,a+rX,ug-s "$pdir"

# Create the package
dpkg-gencontrol -p$pname -P"$pdir"
dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" ..
}

install_linux_image () {
pdir=$1
pname=$2

rm -rf ${pdir}
pname=$1
pdir=debian/$1

# Only some architectures with OF support have this target
if is_enabled CONFIG_OF_EARLY_FLATTREE && [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install
fi

${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install
${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" INSTALL_MOD_STRIP=1 modules_install
rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build"

# Install the kernel
Expand Down Expand Up @@ -132,7 +103,6 @@ install_linux_image () {

mkdir -p "${pdir}/DEBIAN"
cat <<-EOF > "${pdir}/DEBIAN/${script}"

#!/bin/sh

set -e
Expand All @@ -151,25 +121,21 @@ install_linux_image () {
}

install_linux_image_dbg () {
pdir=$1
image_pdir=$2

rm -rf ${pdir}

for module in $(find ${image_pdir}/lib/modules/ -name *.ko -printf '%P\n'); do
module=lib/modules/${module}
mkdir -p $(dirname ${pdir}/usr/lib/debug/${module})
# only keep debug symbols in the debug file
${OBJCOPY} --only-keep-debug ${image_pdir}/${module} ${pdir}/usr/lib/debug/${module}
# strip original module from debug symbols
${OBJCOPY} --strip-debug ${image_pdir}/${module}
# then add a link to those
${OBJCOPY} --add-gnu-debuglink=${pdir}/usr/lib/debug/${module} ${image_pdir}/${module}
done

# re-sign stripped modules
if is_enabled CONFIG_MODULE_SIG_ALL; then
${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${image_pdir}" modules_sign
pdir=debian/$1

# Parse modules.order directly because 'make modules_install' may sign,
# compress modules, and then run unneeded depmod.
if is_enabled CONFIG_MODULES; then
while read -r mod; do
mod="${mod%.o}.ko"
dbg="${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/kernel/${mod}"
buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
link="${pdir}/usr/lib/debug/.build-id/${buildid}.debug"

mkdir -p "${dbg%/*}" "${link%/*}"
"${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
ln -sf --relative "${dbg}" "${link}"
done < modules.order
fi

# Build debug package
Expand All @@ -185,64 +151,35 @@ install_linux_image_dbg () {
}

install_kernel_headers () {
pdir=$1
version=$2
pdir=debian/$1
version=${1#linux-headers-}

rm -rf $pdir

"${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}"
CC="${DEB_HOST_GNU_TYPE}-gcc" "${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}"

mkdir -p $pdir/lib/modules/$version/
ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build
}

install_libc_headers () {
pdir=$1

rm -rf $pdir
pdir=debian/$1

$MAKE -f $srctree/Makefile headers
$MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH=$pdir/usr

# move asm headers to /usr/include/<libc-machine>/asm to match the structure
# used by Debian-based distros (to support multi-arch)
host_arch=$(dpkg-architecture -a$DEB_HOST_ARCH -qDEB_HOST_MULTIARCH)
mkdir $pdir/usr/include/$host_arch
mv $pdir/usr/include/asm $pdir/usr/include/$host_arch/
mkdir "$pdir/usr/include/${DEB_HOST_MULTIARCH}"
mv "$pdir/usr/include/asm" "$pdir/usr/include/${DEB_HOST_MULTIARCH}"
}

rm -f debian/files

packages_enabled=$(dh_listpackages)

for package in ${packages_enabled}
do
case ${package} in
*-dbg)
# This must be done after linux-image, that is, we expect the
# debug package appears after linux-image in debian/control.
install_linux_image_dbg debian/linux-image-dbg debian/linux-image;;
linux-image-*|user-mode-linux-*)
install_linux_image debian/linux-image ${package};;
linux-libc-dev)
install_libc_headers debian/linux-libc-dev;;
linux-headers-*)
install_kernel_headers debian/linux-headers ${package#linux-headers-};;
esac
done

for package in ${packages_enabled}
do
case ${package} in
*-dbg)
create_package ${package} debian/linux-image-dbg;;
linux-image-*|user-mode-linux-*)
create_package ${package} debian/linux-image;;
linux-libc-dev)
create_package ${package} debian/linux-libc-dev;;
linux-headers-*)
create_package ${package} debian/linux-headers;;
esac
done

exit 0
package=$1

case "${package}" in
*-dbg)
install_linux_image_dbg "${package}";;
linux-image-*|user-mode-linux-*)
install_linux_image "${package}";;
linux-libc-dev)
install_libc_headers "${package}";;
linux-headers-*)
install_kernel_headers "${package}";;
esac
2 changes: 1 addition & 1 deletion scripts/package/buildtar
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Wichert Akkerman <[email protected]>.
#

set -e
set -eu

#
# Some variables and settings used throughout the script
Expand Down
14 changes: 0 additions & 14 deletions scripts/package/deb-build-option

This file was deleted.

16 changes: 16 additions & 0 deletions scripts/package/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
This is a packaged upstream version of the Linux kernel.

The sources may be found at most Linux archive sites, including:
https://www.kernel.org/pub/linux/kernel

Copyright: 1991 - 2023 Linus Torvalds and others.

The git repository for mainline kernel development is at:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991.

On Debian GNU/Linux systems, the complete text of the GNU General Public
License version 2 can be found in `/usr/share/common-licenses/GPL-2'.
84 changes: 72 additions & 12 deletions scripts/package/debian/rules
Original file line number Diff line number Diff line change
@@ -1,33 +1,93 @@
#!/usr/bin/make -f
# SPDX-License-Identifier: GPL-2.0-only

include debian/rules.vars
# in case debian/rules is executed directly
export DEB_RULES_REQUIRES_ROOT := no

srctree ?= .
include debian/rules.vars

ifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS))))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS += -j$(NUMJOBS)
endif

# When KBUILD_VERBOSE is undefined (presumably you are directly working with
# the debianized tree), show verbose logs unless DEB_BUILD_OPTION=terse is set.
ifeq ($(origin KBUILD_VERBOSE),undefined)
ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
export KBUILD_VERBOSE := 1
else
Q := @
endif
endif

revision = $(shell dpkg-parsechangelog -S Version | sed -n 's/.*-//p')
CROSS_COMPILE ?= $(filter-out $(DEB_BUILD_GNU_TYPE)-, $(DEB_HOST_GNU_TYPE)-)
make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) \
$(addprefix KBUILD_BUILD_VERSION=,$(revision)) \
$(addprefix CROSS_COMPILE=,$(CROSS_COMPILE))

binary-targets := $(addprefix binary-, image image-dbg headers libc-dev)

all-packages = $(shell dh_listpackages)
image-package = $(filter linux-image-% user-%, $(filter-out %-dbg, $(all-packages)))
image-dbg-package = $(filter %-dbg, $(all-packages))
libc-dev-package = $(filter linux-libc-dev, $(all-packages))
headers-package = $(filter linux-headers-%, $(all-packages))

mk-files = $(patsubst binary-%,debian/%.files,$1)
package = $($(@:binary-%=%-package))

# DH_OPTION is an environment variable common for all debhelper commands.
# We could 'export' it, but here it is passed from the command line to clarify
# which package is being processed in the build log.
DH_OPTIONS = -p$(package)

define binary
$(Q)dh_testdir $(DH_OPTIONS)
$(Q)dh_testroot $(DH_OPTIONS)
$(Q)dh_prep $(DH_OPTIONS)
$(Q)+$(MAKE) $(make-opts) run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb $(package)'
$(Q)dh_installdocs $(DH_OPTIONS)
$(Q)dh_installchangelogs $(DH_OPTIONS)
$(Q)dh_compress $(DH_OPTIONS)
$(Q)dh_fixperms $(DH_OPTIONS)
$(Q)dh_gencontrol $(DH_OPTIONS) -- -f$(call mk-files,$@)
$(Q)dh_md5sums $(DH_OPTIONS)
$(Q)dh_builddeb $(DH_OPTIONS) -- $(addprefix -Z,$(KDEB_COMPRESS))
endef

.PHONY: $(binary-targets)
$(binary-targets): build-arch
$(Q)truncate -s0 $(call mk-files,$@)
$(if $(package),$(binary))

.PHONY: binary binary-indep binary-arch
binary: binary-arch binary-indep
binary-indep: build-indep
binary-arch: build-arch
$(MAKE) -f $(srctree)/Makefile ARCH=$(ARCH) \
KERNELRELEASE=$(KERNELRELEASE) \
run-command KBUILD_RUN_COMMAND=+$(srctree)/scripts/package/builddeb
binary-arch: $(binary-targets)
$(Q)cat $(call mk-files,$^) > debian/files

.PHONY: build build-indep build-arch
build: build-arch build-indep
build-indep:
build-arch:
$(MAKE) -f $(srctree)/Makefile ARCH=$(ARCH) \
KERNELRELEASE=$(KERNELRELEASE) \
$(shell $(srctree)/scripts/package/deb-build-option) \
olddefconfig all
$(Q)$(MAKE) $(make-opts) olddefconfig
$(Q)$(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all

.PHONY: clean
clean:
rm -rf debian/files debian/linux-*
$(MAKE) -f $(srctree)/Makefile ARCH=$(ARCH) clean
$(Q)dh_clean
$(Q)rm -rf debian/deb-env.vars* debian/*.files
$(Q)$(MAKE) ARCH=$(ARCH) clean

# If DEB_HOST_ARCH is empty, it is likely that debian/rules was executed
# directly. Run 'dpkg-architecture --print-set --print-format=make' to
# generate a makefile construct that exports all DEB_* variables.
ifndef DEB_HOST_ARCH
include debian/deb-env.vars

debian/deb-env.vars:
$(Q)dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > [email protected]
$(Q)mv [email protected] $@
endif
2 changes: 2 additions & 0 deletions scripts/package/gen-diff-patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only

set -eu

diff_patch=$1

mkdir -p "$(dirname "${diff_patch}")"
Expand Down
Loading
Loading