Commit 53429336 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'kbuild-fixes-v6.3' of...

Merge tag 'kbuild-fixes-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - Exclude kallsyms_seqs_of_names from kallsyms to fix build error

 - Fix 'make kernelrelease' for external module builds

 - Get the Debian source package compilable again

 - Fix the wrong uname when Debian packages are built with the
   KDEB_PKGVERSION option

 - Fix superfluous CROSS_COMPILE when building Debian packages

 - Fix RPM package build error when KCONFIG_CONFIG is set

 - Use 'git archive' for creating source tarballs

 - Remove the scripts/list-gitignored tool

* tag 'kbuild-fixes-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: use git-archive for source package creation
  kbuild: rpm-pkg: move source components to rpmbuild/SOURCES
  kbuild: deb-pkg: use dh_listpackages to know enabled packages
  kbuild: deb-pkg: split image and debug objects staging out into functions
  kbuild: deb-pkg: set CROSS_COMPILE only when undefined
  kbuild: deb-pkg: do not take KERNELRELEASE from the source version
  kbuild: deb-pkg: make debian source package working again
  Makefile: Make kernelrelease target work with M=
  kconfig: Update config changed flag before calling callback
  kallsyms: add kallsyms_seqs_of_names to list of special symbols
parents 2a3e75a7 05e96e96
...@@ -78,6 +78,7 @@ modules.order ...@@ -78,6 +78,7 @@ modules.order
# RPM spec file (make rpm-pkg) # RPM spec file (make rpm-pkg)
# #
/*.spec /*.spec
/rpmbuild/
# #
# Debian directory (make deb-pkg) # Debian directory (make deb-pkg)
......
...@@ -274,8 +274,7 @@ no-dot-config-targets := $(clean-targets) \ ...@@ -274,8 +274,7 @@ no-dot-config-targets := $(clean-targets) \
cscope gtags TAGS tags help% %docs check% coccicheck \ cscope gtags TAGS tags help% %docs check% coccicheck \
$(version_h) headers headers_% archheaders archscripts \ $(version_h) headers headers_% archheaders archscripts \
%asm-generic kernelversion %src-pkg dt_binding_check \ %asm-generic kernelversion %src-pkg dt_binding_check \
outputmakefile rustavailable rustfmt rustfmtcheck \ outputmakefile rustavailable rustfmt rustfmtcheck
scripts_package
# Installation targets should not require compiler. Unfortunately, vdso_install # Installation targets should not require compiler. Unfortunately, vdso_install
# is an exception where build artifacts may be updated. This must be fixed. # is an exception where build artifacts may be updated. This must be fixed.
no-compiler-targets := $(no-dot-config-targets) install dtbs_install \ no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
...@@ -1605,7 +1604,7 @@ MRPROPER_FILES += include/config include/generated \ ...@@ -1605,7 +1604,7 @@ MRPROPER_FILES += include/config include/generated \
certs/signing_key.pem \ certs/signing_key.pem \
certs/x509.genkey \ certs/x509.genkey \
vmlinux-gdb.py \ vmlinux-gdb.py \
*.spec \ *.spec rpmbuild \
rust/libmacros.so rust/libmacros.so
# clean - Delete most, but leave enough to build external modules # clean - Delete most, but leave enough to build external modules
...@@ -1656,10 +1655,6 @@ distclean: mrproper ...@@ -1656,10 +1655,6 @@ distclean: mrproper
%pkg: include/config/kernel.release FORCE %pkg: include/config/kernel.release FORCE
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
PHONY += scripts_package
scripts_package: scripts_basic
$(Q)$(MAKE) $(build)=scripts scripts/list-gitignored
# Brief documentation of the typical targets used # Brief documentation of the typical targets used
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -1886,6 +1881,8 @@ endif ...@@ -1886,6 +1881,8 @@ endif
else # KBUILD_EXTMOD else # KBUILD_EXTMOD
filechk_kernel.release = echo $(KERNELRELEASE)
### ###
# External module support. # External module support.
# When building external modules the kernel used as basis is considered # When building external modules the kernel used as basis is considered
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
/generate_rust_target /generate_rust_target
/insert-sys-cert /insert-sys-cert
/kallsyms /kallsyms
/list-gitignored
/module.lds /module.lds
/recordmcount /recordmcount
/sign-file /sign-file
......
...@@ -38,7 +38,7 @@ HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED ...@@ -38,7 +38,7 @@ HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED
endif endif
# The following programs are only built on demand # The following programs are only built on demand
hostprogs += list-gitignored unifdef hostprogs += unifdef
# The module linker script is preprocessed on demand # The module linker script is preprocessed on demand
targets += module.lds targets += module.lds
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Makefile for the different targets used to generate full packages of a kernel # Makefile for the different targets used to generate full packages of a kernel
include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Kbuild.include
include $(srctree)/scripts/Makefile.lib
KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
KBUILD_PKG_ROOTCMD ?="fakeroot -u" KBUILD_PKG_ROOTCMD ?="fakeroot -u"
...@@ -26,54 +27,46 @@ fi ; \ ...@@ -26,54 +27,46 @@ fi ; \
tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \ tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
--transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3) --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
# .tmp_filelist .tmp_filelist_exclude # tarball compression
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
scripts/list-gitignored: FORCE %.tar.gz: %.tar
$(Q)$(MAKE) -f $(srctree)/Makefile scripts_package $(call cmd,gzip)
# 1f5d3a6b6532e25a5cdf1f311956b2b03d343a48 removed '*.rej' from .gitignore, %.tar.bz2: %.tar
# but it is definitely a generated file. $(call cmd,bzip2)
filechk_filelist = \
$< --exclude='*.rej' --output=$@_exclude --prefix=./ --rootdir=$(srctree) --stat=-
.tmp_filelist: scripts/list-gitignored FORCE %.tar.xz: %.tar
$(call filechk,filelist) $(call cmd,xzmisc)
# tarball %.tar.zst: %.tar
# --------------------------------------------------------------------------- $(call cmd,zstd)
quiet_cmd_tar = TAR $@
cmd_tar = tar -c -f $@ $(tar-compress-opt) $(tar-exclude-opt) \
--owner=0 --group=0 --sort=name \
--transform 's:^\.:$*:S' -C $(tar-rootdir) .
tar-rootdir := $(srctree)
%.tar: # Git
$(call cmd,tar) # ---------------------------------------------------------------------------
%.tar.gz: private tar-compress-opt := -I $(KGZIP)
%.tar.gz:
$(call cmd,tar)
%.tar.bz2: private tar-compress-opt := -I $(KBZIP2) filechk_HEAD = git -C $(srctree) rev-parse --verify HEAD 2>/dev/null
%.tar.bz2:
$(call cmd,tar)
%.tar.xz: private tar-compress-opt := -I $(XZ) .tmp_HEAD: check-git FORCE
%.tar.xz: $(call filechk,HEAD)
$(call cmd,tar)
%.tar.zst: private tar-compress-opt := -I $(ZSTD) PHONY += check-git
%.tar.zst: check-git:
$(call cmd,tar) @if ! $(srctree)/scripts/check-git; then \
echo >&2 "error: creating source package requires git repository"; \
false; \
fi
# Linux source tarball # Linux source tarball
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
linux.tar.gz: tar-exclude-opt = --exclude=./$@ --exclude-from=$<_exclude quiet_cmd_archive_linux = ARCHIVE $@
linux.tar.gz: .tmp_filelist cmd_archive_linux = \
git -C $(srctree) archive --output=$$(realpath $@) --prefix=$(basename $@)/ $$(cat $<)
targets += linux.tar
linux.tar: .tmp_HEAD FORCE
$(call if_changed,archive_linux)
# rpm-pkg # rpm-pkg
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -89,7 +82,7 @@ PHONY += srcrpm-pkg ...@@ -89,7 +82,7 @@ PHONY += srcrpm-pkg
srcrpm-pkg: linux.tar.gz srcrpm-pkg: linux.tar.gz
$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -bs kernel.spec \ +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -bs kernel.spec \
--define='_smp_mflags %{nil}' --define='_sourcedir .' --define='_srcrpmdir .' --define='_smp_mflags %{nil}' --define='_sourcedir rpmbuild/SOURCES' --define='_srcrpmdir .'
# binrpm-pkg # binrpm-pkg
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -148,74 +141,62 @@ snap-pkg: ...@@ -148,74 +141,62 @@ snap-pkg:
# dir-pkg tar*-pkg - tarball targets # dir-pkg tar*-pkg - tarball targets
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
tar-pkg-tarball = linux-$(KERNELRELEASE)-$(ARCH).$(1)
tar-pkg-phony = $(subst .,,$(1))-pkg
tar-install: FORCE tar-install: FORCE
$(Q)$(MAKE) -f $(srctree)/Makefile $(Q)$(MAKE) -f $(srctree)/Makefile
+$(Q)$(srctree)/scripts/package/buildtar $@ +$(Q)$(srctree)/scripts/package/buildtar $@
quiet_cmd_tar = TAR $@
cmd_tar = cd $<; tar cf ../$@ --owner=root --group=root --sort=name *
linux-$(KERNELRELEASE)-$(ARCH).tar: tar-install
$(call cmd,tar)
PHONY += dir-pkg PHONY += dir-pkg
dir-pkg: tar-install dir-pkg: tar-install
@echo "Kernel tree successfully created in $<" @echo "Kernel tree successfully created in $<"
define tar-pkg-rule PHONY += tar-pkg
PHONY += $(tar-pkg-phony) tar-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar
$(tar-pkg-phony): $(tar-pkg-tarball)
@: @:
$(tar-pkg-tarball): private tar-rootdir := tar-install tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE
$(tar-pkg-tarball): tar-install @:
endef
$(foreach x, tar tar.gz tar.bz2 tar.xz tar.zst, $(eval $(call tar-pkg-rule,$(x))))
# perf-tar*-src-pkg - generate a source tarball with perf source # perf-tar*-src-pkg - generate a source tarball with perf source
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
perf-tar-src-pkg-tarball = perf-$(KERNELVERSION).$(1) .tmp_perf:
perf-tar-src-pkg-phony = perf-$(subst .,,$(1))-src-pkg $(Q)mkdir .tmp_perf
quiet_cmd_stage_perf_src = STAGE $@
cmd_stage_perf_src = \
rm -rf $@; \
mkdir -p $@; \
tar -c -f - --exclude-from=$<_exclude -C $(srctree) --files-from=$(srctree)/tools/perf/MANIFEST | \
tar -x -f - -C $@
.tmp_perf: .tmp_filelist
$(call cmd,stage_perf_src)
filechk_perf_head = \
if test -z "$(git -C $(srctree) rev-parse --show-cdup 2>/dev/null)" && \
head=$$(git -C $(srctree) rev-parse --verify HEAD 2>/dev/null); then \
echo $$head; \
else \
echo "not a git tree"; \
fi
.tmp_perf/HEAD: .tmp_perf FORCE .tmp_perf/HEAD: .tmp_HEAD | .tmp_perf
$(call filechk,perf_head) $(call cmd,copy)
quiet_cmd_perf_version_file = GEN $@ quiet_cmd_perf_version_file = GEN $@
cmd_perf_version_file = cd $(srctree)/tools/perf; util/PERF-VERSION-GEN $(dir $(abspath $@)) cmd_perf_version_file = cd $(srctree)/tools/perf; util/PERF-VERSION-GEN $(dir $(abspath $@))
# PERF-VERSION-FILE and HEAD are independent, but this avoids updating the # PERF-VERSION-FILE and .tmp_HEAD are independent, but this avoids updating the
# timestamp of PERF-VERSION-FILE. # timestamp of PERF-VERSION-FILE.
# The best is to fix tools/perf/util/PERF-VERSION-GEN. # The best is to fix tools/perf/util/PERF-VERSION-GEN.
.tmp_perf/PERF-VERSION-FILE: .tmp_perf/HEAD $(srctree)/tools/perf/util/PERF-VERSION-GEN .tmp_perf/PERF-VERSION-FILE: .tmp_HEAD $(srctree)/tools/perf/util/PERF-VERSION-GEN | .tmp_perf
$(call cmd,perf_version_file) $(call cmd,perf_version_file)
define perf-tar-src-pkg-rule quiet_cmd_archive_perf = ARCHIVE $@
PHONY += $(perf-tar-src-pkg-phony) cmd_archive_perf = \
$(perf-tar-src-pkg-phony): $(perf-tar-src-pkg-tarball) git -C $(srctree) archive --output=$$(realpath $@) --prefix=$(basename $@)/ \
@: --add-file=$$(realpath $(word 2, $^)) \
--add-file=$$(realpath $(word 3, $^)) \
$$(cat $(word 2, $^))^{tree} $$(cat $<)
$(perf-tar-src-pkg-tarball): private tar-rootdir := .tmp_perf targets += perf-$(KERNELVERSION).tar
$(perf-tar-src-pkg-tarball): .tmp_filelist .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE perf-$(KERNELVERSION).tar: tools/perf/MANIFEST .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE FORCE
endef $(call if_changed,archive_perf)
PHONY += perf-tar-src-pkg
perf-tar-src-pkg: perf-$(KERNELVERSION).tar
@:
$(foreach x, tar tar.gz tar.bz2 tar.xz tar.zst, $(eval $(call perf-tar-src-pkg-rule,$(x)))) perf-tar%-src-pkg: perf-$(KERNELVERSION).tar.% FORCE
@:
# Help text displayed when executing 'make help' # Help text displayed when executing 'make help'
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -243,4 +224,13 @@ help: ...@@ -243,4 +224,13 @@ help:
PHONY += FORCE PHONY += FORCE
FORCE: FORCE:
# Read all saved command lines and dependencies for the $(targets) we
# may be building above, using $(if_changed{,_dep}). As an
# optimization, we don't need to read them if the target does not
# exist, we will rebuild anyway in that case.
existing-targets := $(wildcard $(sort $(targets)))
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
.PHONY: $(PHONY) .PHONY: $(PHONY)
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
#
# succeed if we are in a git repository
srctree="$(dirname $0)/.."
if ! git -C "${srctree}" rev-parse --verify HEAD >/dev/null 2>/dev/null; then
exit 1
fi
if ! test -z $(git -C "${srctree}" rev-parse --show-cdup 2>/dev/null); then
exit 1
fi
...@@ -119,6 +119,7 @@ static bool is_ignored_symbol(const char *name, char type) ...@@ -119,6 +119,7 @@ static bool is_ignored_symbol(const char *name, char type)
"kallsyms_markers", "kallsyms_markers",
"kallsyms_token_table", "kallsyms_token_table",
"kallsyms_token_index", "kallsyms_token_index",
"kallsyms_seqs_of_names",
/* Exclude linker generated symbols which vary between passes */ /* Exclude linker generated symbols which vary between passes */
"_SDA_BASE_", /* ppc */ "_SDA_BASE_", /* ppc */
"_SDA2_BASE_", /* ppc */ "_SDA2_BASE_", /* ppc */
......
...@@ -1226,10 +1226,12 @@ static void (*conf_changed_callback)(void); ...@@ -1226,10 +1226,12 @@ static void (*conf_changed_callback)(void);
void conf_set_changed(bool val) void conf_set_changed(bool val)
{ {
if (conf_changed_callback && conf_changed != val) bool changed = conf_changed != val;
conf_changed_callback();
conf_changed = val; conf_changed = val;
if (conf_changed_callback && changed)
conf_changed_callback();
} }
bool conf_get_changed(void) bool conf_get_changed(void)
......
This diff is collapsed.
...@@ -51,7 +51,116 @@ create_package() { ...@@ -51,7 +51,116 @@ create_package() {
dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" ..
} }
deploy_kernel_headers () { install_linux_image () {
pdir=$1
pname=$2
rm -rf ${pdir}
# 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
if is_enabled CONFIG_MODULES; then
${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install
rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build"
rm -f "${pdir}/lib/modules/${KERNELRELEASE}/source"
if [ "${SRCARCH}" = um ] ; then
mkdir -p "${pdir}/usr/lib/uml/modules"
mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}"
fi
fi
# Install the kernel
if [ "${ARCH}" = um ] ; then
mkdir -p "${pdir}/usr/bin" "${pdir}/usr/share/doc/${pname}"
cp System.map "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}/System.map"
cp ${KCONFIG_CONFIG} "${pdir}/usr/share/doc/${pname}/config"
gzip "${pdir}/usr/share/doc/${pname}/config"
else
mkdir -p "${pdir}/boot"
cp System.map "${pdir}/boot/System.map-${KERNELRELEASE}"
cp ${KCONFIG_CONFIG} "${pdir}/boot/config-${KERNELRELEASE}"
fi
# Not all arches have the same installed path in debian
# XXX: have each arch Makefile export a variable of the canonical image install
# path instead
case "${SRCARCH}" in
um)
installed_image_path="usr/bin/linux-${KERNELRELEASE}";;
parisc|mips|powerpc)
installed_image_path="boot/vmlinux-${KERNELRELEASE}";;
*)
installed_image_path="boot/vmlinuz-${KERNELRELEASE}";;
esac
cp "$(${MAKE} -s -f ${srctree}/Makefile image_name)" "${pdir}/${installed_image_path}"
# Install the maintainer scripts
# Note: hook scripts under /etc/kernel are also executed by official Debian
# kernel packages, as well as kernel packages built using make-kpkg.
# make-kpkg sets $INITRD to indicate whether an initramfs is wanted, and
# so do we; recent versions of dracut and initramfs-tools will obey this.
debhookdir=${KDEB_HOOKDIR:-/etc/kernel}
for script in postinst postrm preinst prerm; do
mkdir -p "${pdir}${debhookdir}/${script}.d"
mkdir -p "${pdir}/DEBIAN"
cat <<-EOF > "${pdir}/DEBIAN/${script}"
#!/bin/sh
set -e
# Pass maintainer script parameters to hook scripts
export DEB_MAINT_PARAMS="\$*"
# Tell initramfs builder whether it's wanted
export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No)
test -d ${debhookdir}/${script}.d && run-parts --arg="${KERNELRELEASE}" --arg="/${installed_image_path}" ${debhookdir}/${script}.d
exit 0
EOF
chmod 755 "${pdir}/DEBIAN/${script}"
done
}
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
fi
# Build debug package
# Different tools want the image in different locations
# perf
mkdir -p ${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/
cp vmlinux ${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/
# systemtap
mkdir -p ${pdir}/usr/lib/debug/boot/
ln -s ../lib/modules/${KERNELRELEASE}/vmlinux ${pdir}/usr/lib/debug/boot/vmlinux-${KERNELRELEASE}
# kdump-tools
ln -s lib/modules/${KERNELRELEASE}/vmlinux ${pdir}/usr/lib/debug/vmlinux-${KERNELRELEASE}
}
install_kernel_headers () {
pdir=$1 pdir=$1
rm -rf $pdir rm -rf $pdir
...@@ -89,7 +198,7 @@ deploy_kernel_headers () { ...@@ -89,7 +198,7 @@ deploy_kernel_headers () {
ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build
} }
deploy_libc_headers () { install_libc_headers () {
pdir=$1 pdir=$1
rm -rf $pdir rm -rf $pdir
...@@ -104,132 +213,38 @@ deploy_libc_headers () { ...@@ -104,132 +213,38 @@ deploy_libc_headers () {
mv $pdir/usr/include/asm $pdir/usr/include/$host_arch/ mv $pdir/usr/include/asm $pdir/usr/include/$host_arch/
} }
version=$KERNELRELEASE rm -f debian/files
tmpdir=debian/linux-image
dbg_dir=debian/linux-image-dbg packages_enabled=$(dh_listpackages)
packagename=linux-image-$version
dbg_packagename=$packagename-dbg for package in ${packages_enabled}
do
if [ "$ARCH" = "um" ] ; then case ${package} in
packagename=user-mode-linux-$version *-dbg)
fi # This must be done after linux-image, that is, we expect the
# debug package appears after linux-image in debian/control.
# Not all arches have the same installed path in debian install_linux_image_dbg debian/linux-image-dbg debian/linux-image;;
# XXX: have each arch Makefile export a variable of the canonical image install linux-image-*|user-mode-linux-*)
# path instead install_linux_image debian/linux-image ${package};;
case $ARCH in linux-libc-dev)
um) install_libc_headers debian/linux-libc-dev;;
installed_image_path="usr/bin/linux-$version" linux-headers-*)
;; install_kernel_headers debian/linux-headers;;
parisc|mips|powerpc) esac
installed_image_path="boot/vmlinux-$version"
;;
*)
installed_image_path="boot/vmlinuz-$version"
esac
BUILD_DEBUG=$(if_enabled_echo CONFIG_DEBUG_INFO Yes)
# Setup the directory structure
rm -rf "$tmpdir" "$dbg_dir" debian/files
mkdir -m 755 -p "$tmpdir/DEBIAN"
mkdir -p "$tmpdir/lib" "$tmpdir/boot"
# Install the kernel
if [ "$ARCH" = "um" ] ; then
mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" "$tmpdir/usr/share/doc/$packagename"
cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config"
gzip "$tmpdir/usr/share/doc/$packagename/config"
else
cp System.map "$tmpdir/boot/System.map-$version"
cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version"
fi
cp "$($MAKE -s -f $srctree/Makefile image_name)" "$tmpdir/$installed_image_path"
if is_enabled CONFIG_OF_EARLY_FLATTREE; then
# Only some architectures with OF support have this target
if [ -d "${srctree}/arch/$SRCARCH/boot/dts" ]; then
$MAKE -f $srctree/Makefile INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install
fi
fi
if is_enabled CONFIG_MODULES; then
INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_install
rm -f "$tmpdir/lib/modules/$version/build"
rm -f "$tmpdir/lib/modules/$version/source"
if [ "$ARCH" = "um" ] ; then
mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
rmdir "$tmpdir/lib/modules/$version"
fi
if [ -n "$BUILD_DEBUG" ] ; then
for module in $(find $tmpdir/lib/modules/ -name *.ko -printf '%P\n'); do
module=lib/modules/$module
mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module)
# only keep debug symbols in the debug file
$OBJCOPY --only-keep-debug $tmpdir/$module $dbg_dir/usr/lib/debug/$module
# strip original module from debug symbols
$OBJCOPY --strip-debug $tmpdir/$module
# then add a link to those
$OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $tmpdir/$module
done
# resign stripped modules
if is_enabled CONFIG_MODULE_SIG_ALL; then
INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_sign
fi
fi
fi
# Install the maintainer scripts
# Note: hook scripts under /etc/kernel are also executed by official Debian
# kernel packages, as well as kernel packages built using make-kpkg.
# make-kpkg sets $INITRD to indicate whether an initramfs is wanted, and
# so do we; recent versions of dracut and initramfs-tools will obey this.
debhookdir=${KDEB_HOOKDIR:-/etc/kernel}
for script in postinst postrm preinst prerm ; do
mkdir -p "$tmpdir$debhookdir/$script.d"
cat <<EOF > "$tmpdir/DEBIAN/$script"
#!/bin/sh
set -e
# Pass maintainer script parameters to hook scripts
export DEB_MAINT_PARAMS="\$*"
# Tell initramfs builder whether it's wanted
export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No)
test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d
exit 0
EOF
chmod 755 "$tmpdir/DEBIAN/$script"
done done
if [ "$ARCH" != "um" ]; then for package in ${packages_enabled}
if is_enabled CONFIG_MODULES; then do
deploy_kernel_headers debian/linux-headers case ${package} in
create_package linux-headers-$version debian/linux-headers *-dbg)
fi create_package ${package} debian/linux-image-dbg;;
linux-image-*|user-mode-linux-*)
deploy_libc_headers debian/linux-libc-dev create_package ${package} debian/linux-image;;
create_package linux-libc-dev debian/linux-libc-dev linux-libc-dev)
fi create_package ${package} debian/linux-libc-dev;;
linux-headers-*)
create_package "$packagename" "$tmpdir" create_package ${package} debian/linux-headers;;
esac
if [ -n "$BUILD_DEBUG" ] ; then done
# Build debug package
# Different tools want the image in different locations
# perf
mkdir -p $dbg_dir/usr/lib/debug/lib/modules/$version/
cp vmlinux $dbg_dir/usr/lib/debug/lib/modules/$version/
# systemtap
mkdir -p $dbg_dir/usr/lib/debug/boot/
ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version
# kdump-tools
ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version
create_package "$dbg_packagename" "$dbg_dir"
fi
exit 0 exit 0
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
# Set up CROSS_COMPILE if we are cross-compiling, but not called from the # Set up CROSS_COMPILE if not defined yet
# kernel toplevel Makefile if [ "${CROSS_COMPILE+set}" != "set" -a "${DEB_HOST_ARCH}" != "${DEB_BUILD_ARCH}" ]; then
if [ -z "${CROSS_COMPILE}${cross_compiling}" -a "${DEB_HOST_ARCH}" != "${DEB_BUILD_ARCH}" ]; then
echo CROSS_COMPILE=${DEB_HOST_GNU_TYPE}- echo CROSS_COMPILE=${DEB_HOST_GNU_TYPE}-
fi fi
version=$(dpkg-parsechangelog -S Version) version=$(dpkg-parsechangelog -S Version)
version_upstream="${version%-*}" debian_revision="${version##*-}"
debian_revision="${version#${version_upstream}}"
debian_revision="${debian_revision#*-}"
echo KERNELRELEASE=${version_upstream} if [ "${version}" != "${debian_revision}" ]; then
echo KBUILD_BUILD_VERSION=${debian_revision} echo KBUILD_BUILD_VERSION=${debian_revision}
fi
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
diff_patch="${1}"
untracked_patch="${2}"
srctree=$(dirname $0)/../..
rm -f ${diff_patch} ${untracked_patch}
if ! ${srctree}/scripts/check-git; then
exit
fi
mkdir -p "$(dirname ${diff_patch})" "$(dirname ${untracked_patch})"
git -C "${srctree}" diff HEAD > "${diff_patch}"
if [ ! -s "${diff_patch}" ]; then
rm -f "${diff_patch}"
exit
fi
git -C ${srctree} status --porcelain --untracked-files=all |
while read stat path
do
if [ "${stat}" = '??' ]; then
if ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff &&
! head -n1 .tmp_diff | grep -q "Binary files"; then
{
echo "--- /dev/null"
echo "+++ linux/$path"
cat .tmp_diff | tail -n +3
} >> ${untracked_patch}
fi
fi
done
rm -f .tmp_diff
if [ ! -s "${diff_patch}" ]; then
rm -f "${diff_patch}"
exit
fi
...@@ -91,7 +91,7 @@ version=$KERNELRELEASE ...@@ -91,7 +91,7 @@ version=$KERNELRELEASE
if [ -n "$KDEB_PKGVERSION" ]; then if [ -n "$KDEB_PKGVERSION" ]; then
packageversion=$KDEB_PKGVERSION packageversion=$KDEB_PKGVERSION
else else
packageversion=$version-$($srctree/init/build-version) packageversion=$(${srctree}/scripts/setlocalversion --no-local ${srctree})-$($srctree/init/build-version)
fi fi
sourcename=${KDEB_SOURCENAME:-linux-upstream} sourcename=${KDEB_SOURCENAME:-linux-upstream}
...@@ -152,6 +152,14 @@ mkdir -p debian/patches ...@@ -152,6 +152,14 @@ mkdir -p debian/patches
} > debian/patches/config } > debian/patches/config
echo config > debian/patches/series echo config > debian/patches/series
$(dirname $0)/gen-diff-patch debian/patches/diff.patch debian/patches/untracked.patch
if [ -f debian/patches/diff.patch ]; then
echo diff.patch >> debian/patches/series
fi
if [ -f debian/patches/untracked.patch ]; then
echo untracked.patch >> debian/patches/series
fi
echo $debarch > debian/arch echo $debarch > debian/arch
extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)" extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)"
extra_build_depends="$extra_build_depends, $(if_enabled_echo CONFIG_SYSTEM_TRUSTED_KEYRING libssl-dev:native)" extra_build_depends="$extra_build_depends, $(if_enabled_echo CONFIG_SYSTEM_TRUSTED_KEYRING libssl-dev:native)"
...@@ -192,7 +200,7 @@ Section: kernel ...@@ -192,7 +200,7 @@ Section: kernel
Priority: optional Priority: optional
Maintainer: $maintainer Maintainer: $maintainer
Rules-Requires-Root: no Rules-Requires-Root: no
Build-Depends: bc, rsync, kmod, cpio, bison, flex $extra_build_depends Build-Depends: bc, debhelper, rsync, kmod, cpio, bison, flex $extra_build_depends
Homepage: https://www.kernel.org/ Homepage: https://www.kernel.org/
Package: $packagename-$version Package: $packagename-$version
...@@ -200,6 +208,10 @@ Architecture: $debarch ...@@ -200,6 +208,10 @@ Architecture: $debarch
Description: Linux kernel, version $version Description: Linux kernel, version $version
This package contains the Linux kernel, modules and corresponding other This package contains the Linux kernel, modules and corresponding other
files, version: $version. files, version: $version.
EOF
if [ "${SRCARCH}" != um ]; then
cat <<EOF >> debian/control
Package: linux-libc-dev Package: linux-libc-dev
Section: devel Section: devel
...@@ -222,6 +234,7 @@ Description: Linux kernel headers for $version on $debarch ...@@ -222,6 +234,7 @@ Description: Linux kernel headers for $version on $debarch
This is useful for people who need to build external modules This is useful for people who need to build external modules
EOF EOF
fi fi
fi
if is_enabled CONFIG_DEBUG_INFO; then if is_enabled CONFIG_DEBUG_INFO; then
cat <<EOF >> debian/control cat <<EOF >> debian/control
...@@ -239,10 +252,12 @@ cat <<EOF > debian/rules ...@@ -239,10 +252,12 @@ cat <<EOF > debian/rules
#!$(command -v $MAKE) -f #!$(command -v $MAKE) -f
srctree ?= . srctree ?= .
KERNELRELEASE = ${KERNELRELEASE}
build-indep: build-indep:
build-arch: build-arch:
\$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \ \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \
KERNELRELEASE=\$(KERNELRELEASE) \
\$(shell \$(srctree)/scripts/package/deb-build-option) \ \$(shell \$(srctree)/scripts/package/deb-build-option) \
olddefconfig all olddefconfig all
...@@ -250,7 +265,9 @@ build: build-arch ...@@ -250,7 +265,9 @@ build: build-arch
binary-indep: binary-indep:
binary-arch: build-arch binary-arch: build-arch
\$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} intdeb-pkg \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \
KERNELRELEASE=\$(KERNELRELEASE) intdeb-pkg
clean: clean:
rm -rf debian/files debian/linux-* rm -rf debian/files debian/linux-*
\$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} clean \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} clean
......
...@@ -15,15 +15,21 @@ if [ "$1" = prebuilt ]; then ...@@ -15,15 +15,21 @@ if [ "$1" = prebuilt ]; then
MAKE="$MAKE -f $srctree/Makefile" MAKE="$MAKE -f $srctree/Makefile"
else else
S= S=
mkdir -p rpmbuild/SOURCES
cp linux.tar.gz rpmbuild/SOURCES
cp "${KCONFIG_CONFIG}" rpmbuild/SOURCES/config
$(dirname $0)/gen-diff-patch rpmbuild/SOURCES/diff.patch rpmbuild/SOURCES/untracked.patch
touch rpmbuild/SOURCES/diff.patch rpmbuild/SOURCES/untracked.patch
fi fi
if grep -q CONFIG_MODULES=y .config; then if grep -q CONFIG_MODULES=y include/config/auto.conf; then
M= M=
else else
M=DEL M=DEL
fi fi
if grep -q CONFIG_DRM=y .config; then if grep -q CONFIG_DRM=y include/config/auto.conf; then
PROVIDES=kernel-drm PROVIDES=kernel-drm
fi fi
...@@ -48,7 +54,9 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF ...@@ -48,7 +54,9 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
Vendor: The Linux Community Vendor: The Linux Community
URL: https://www.kernel.org URL: https://www.kernel.org
$S Source0: linux.tar.gz $S Source0: linux.tar.gz
$S Source1: .config $S Source1: config
$S Source2: diff.patch
$S Source3: untracked.patch
Provides: $PROVIDES Provides: $PROVIDES
$S BuildRequires: bc binutils bison dwarves $S BuildRequires: bc binutils bison dwarves
$S BuildRequires: (elfutils-libelf-devel or libelf-devel) flex $S BuildRequires: (elfutils-libelf-devel or libelf-devel) flex
...@@ -85,7 +93,13 @@ $S$M against the $__KERNELRELEASE kernel package. ...@@ -85,7 +93,13 @@ $S$M against the $__KERNELRELEASE kernel package.
$S$M $S$M
$S %prep $S %prep
$S %setup -q -n linux $S %setup -q -n linux
$S cp %{SOURCE1} . $S cp %{SOURCE1} .config
$S if [ -s %{SOURCE2} ]; then
$S patch -p1 < %{SOURCE2}
$S fi
$S if [ -s %{SOURCE3} ]; then
$S patch -p1 < %{SOURCE3}
$S fi
$S $S
$S %build $S %build
$S $MAKE %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release} $S $MAKE %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release}
......
...@@ -11,10 +11,16 @@ ...@@ -11,10 +11,16 @@
# #
usage() { usage() {
echo "Usage: $0 [srctree]" >&2 echo "Usage: $0 [--no-local] [srctree]" >&2
exit 1 exit 1
} }
no_local=false
if test "$1" = "--no-local"; then
no_local=true
shift
fi
srctree=. srctree=.
if test $# -gt 0; then if test $# -gt 0; then
srctree=$1 srctree=$1
...@@ -26,14 +32,22 @@ fi ...@@ -26,14 +32,22 @@ fi
scm_version() scm_version()
{ {
local short local short=false
local no_dirty=false
local tag local tag
short=false
while [ $# -gt 0 ];
do
case "$1" in
--short)
short=true;;
--no-dirty)
no_dirty=true;;
esac
shift
done
cd "$srctree" cd "$srctree"
if test "$1" = "--short"; then
short=true
fi
if test -n "$(git rev-parse --show-cdup 2>/dev/null)"; then if test -n "$(git rev-parse --show-cdup 2>/dev/null)"; then
return return
...@@ -75,6 +89,10 @@ scm_version() ...@@ -75,6 +89,10 @@ scm_version()
printf '%s%s' -g "$(echo $head | cut -c1-12)" printf '%s%s' -g "$(echo $head | cut -c1-12)"
fi fi
if ${no_dirty}; then
return
fi
# Check for uncommitted changes. # Check for uncommitted changes.
# This script must avoid any write attempt to the source tree, which # This script must avoid any write attempt to the source tree, which
# might be read-only. # might be read-only.
...@@ -110,11 +128,6 @@ collect_files() ...@@ -110,11 +128,6 @@ collect_files()
echo "$res" echo "$res"
} }
if ! test -e include/config/auto.conf; then
echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
exit 1
fi
if [ -z "${KERNELVERSION}" ]; then if [ -z "${KERNELVERSION}" ]; then
echo "KERNELVERSION is not set" >&2 echo "KERNELVERSION is not set" >&2
exit 1 exit 1
...@@ -126,6 +139,16 @@ if test ! "$srctree" -ef .; then ...@@ -126,6 +139,16 @@ if test ! "$srctree" -ef .; then
file_localversion="${file_localversion}$(collect_files "$srctree"/localversion*)" file_localversion="${file_localversion}$(collect_files "$srctree"/localversion*)"
fi fi
if ${no_local}; then
echo "${KERNELVERSION}$(scm_version --no-dirty)"
exit 0
fi
if ! test -e include/config/auto.conf; then
echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
exit 1
fi
# version string from CONFIG_LOCALVERSION # version string from CONFIG_LOCALVERSION
config_localversion=$(sed -n 's/^CONFIG_LOCALVERSION=\(.*\)$/\1/p' include/config/auto.conf) config_localversion=$(sed -n 's/^CONFIG_LOCALVERSION=\(.*\)$/\1/p' include/config/auto.conf)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment