diff options
Diffstat (limited to 'scripts/package/mkdebian')
-rwxr-xr-x | scripts/package/mkdebian | 173 |
1 files changed, 95 insertions, 78 deletions
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index 48fbd3d0284a..070149c985fe 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -26,7 +26,7 @@ set_debarch() { # Attempt to find the correct Debian architecture case "$UTS_MACHINE" in - i386|ia64|alpha|m68k|riscv*) + i386|alpha|m68k|riscv*) debarch="$UTS_MACHINE" ;; x86_64) debarch=amd64 ;; @@ -84,41 +84,84 @@ set_debarch() { fi } -# Some variables and settings used throughout the script -version=$KERNELRELEASE -if [ -n "$KDEB_PKGVERSION" ]; then - packageversion=$KDEB_PKGVERSION - revision=${packageversion##*-} -else - revision=$(cat .version 2>/dev/null||echo 1) - packageversion=$version-$revision -fi -sourcename=$KDEB_SOURCENAME -packagename=linux-image-$version -kernel_headers_packagename=linux-headers-$version -dbg_packagename=$packagename-dbg -debarch= -set_debarch +# Create debian/source/ if it is a source package build +gen_source () +{ + mkdir -p debian/source + + echo "3.0 (quilt)" > debian/source/format + + { + echo "diff-ignore" + echo "extend-diff-ignore = .*" + } > debian/source/local-options + + # Add .config as a patch + mkdir -p debian/patches + { + echo "Subject: Add .config" + echo "Author: ${maintainer}" + echo + echo "--- /dev/null" + echo "+++ linux/.config" + diff -u /dev/null "${KCONFIG_CONFIG}" | tail -n +3 + } > debian/patches/config.patch + echo config.patch > debian/patches/series + + "${srctree}/scripts/package/gen-diff-patch" debian/patches/diff.patch + if [ -s debian/patches/diff.patch ]; then + sed -i " + 1iSubject: Add local diff + 1iAuthor: ${maintainer} + 1i + " debian/patches/diff.patch + + echo diff.patch >> debian/patches/series + else + rm -f debian/patches/diff.patch + fi +} -if [ "$ARCH" = "um" ] ; then - packagename=user-mode-linux-$version -fi +rm -rf debian +mkdir debian email=${DEBEMAIL-$EMAIL} # use email string directly if it contains <email> -if echo $email | grep -q '<.*>'; then - maintainer=$email +if echo "${email}" | grep -q '<.*>'; then + maintainer=${email} else # or construct the maintainer string user=${KBUILD_BUILD_USER-$(id -nu)} - name=${DEBFULLNAME-$user} - if [ -z "$email" ]; then + name=${DEBFULLNAME-${user}} + if [ -z "${email}" ]; then buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)} - email="$user@$buildhost" + email="${user}@${buildhost}" fi - maintainer="$name <$email>" + maintainer="${name} <${email}>" +fi + +if [ "$1" = --need-source ]; then + gen_source +fi + +# Some variables and settings used throughout the script +version=$KERNELRELEASE +if [ -n "$KDEB_PKGVERSION" ]; then + packageversion=$KDEB_PKGVERSION +else + packageversion=$(${srctree}/scripts/setlocalversion --no-local ${srctree})-$($srctree/init/build-version) fi +sourcename=${KDEB_SOURCENAME:-linux-upstream} + +if [ "$ARCH" = "um" ] ; then + packagename=user-mode-linux +else + packagename=linux-image +fi + +debarch= +set_debarch # Try to determine distribution if [ -n "$KDEB_CHANGELOG_DIST" ]; then @@ -132,12 +175,7 @@ else echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly" fi -mkdir -p debian/source/ -echo "1.0" > debian/source/format - echo $debarch > debian/arch -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)" # Generate a simple changelog template cat <<EOF > debian/changelog @@ -148,47 +186,26 @@ $sourcename ($packageversion) $distribution; urgency=low -- $maintainer $(date -R) EOF -# Generate copyright file -cat <<EOF > debian/copyright -This is a packacked 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 - 2018 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'. -EOF - # Generate a control file cat <<EOF > debian/control Source: $sourcename Section: kernel Priority: optional Maintainer: $maintainer -Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends +Rules-Requires-Root: no +Build-Depends: debhelper-compat (= 12) +Build-Depends-Arch: bc, bison, cpio, flex, kmod, libelf-dev:native, libssl-dev:native, rsync Homepage: https://www.kernel.org/ -Package: $packagename +Package: $packagename-$version Architecture: $debarch Description: Linux kernel, version $version This package contains the Linux kernel, modules and corresponding other files, version: $version. +EOF -Package: $kernel_headers_packagename -Architecture: $debarch -Description: Linux kernel headers for $version on $debarch - This package provides kernel header files for $version on $debarch - . - This is useful for people who need to build external modules +if [ "${SRCARCH}" != um ]; then +cat <<EOF >> debian/control Package: linux-libc-dev Section: devel @@ -200,10 +217,23 @@ Description: Linux support headers for userspace development Multi-Arch: same EOF +if is_enabled CONFIG_MODULES; then +cat <<EOF >> debian/control + +Package: linux-headers-$version +Architecture: $debarch +Description: Linux kernel headers for $version on $debarch + This package provides kernel header files for $version on $debarch + . + This is useful for people who need to build external modules +EOF +fi +fi + if is_enabled CONFIG_DEBUG_INFO; then cat <<EOF >> debian/control -Package: $dbg_packagename +Package: linux-image-$version-dbg Section: debug Architecture: $debarch Description: Linux kernel debugging symbols for $version @@ -212,25 +242,12 @@ Description: Linux kernel debugging symbols for $version EOF fi -cat <<EOF > debian/rules -#!$(command -v $MAKE) -f - -srctree ?= . - -build: - \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ - KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile - -binary-arch: - \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ - KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg - -clean: - rm -rf debian/*tmp debian/files - \$(MAKE) clean - -binary: binary-arch +cat <<EOF > debian/rules.vars +ARCH := ${ARCH} +KERNELRELEASE := ${KERNELRELEASE} EOF -chmod +x debian/rules + +cp "${srctree}/scripts/package/debian/copyright" debian/ +cp "${srctree}/scripts/package/debian/rules" debian/ exit 0 |