armbian_build/packages/armbian/mkdebian
The-going 92b8320edd
Packaging (#2935)
* kbuild: deb-pkg: do not build linux-headers package if CONFIG_MODULES=n

Since commit 269a535ca931 ("modpost: generate vmlinux.symvers and
reuse it for the second modpost"), with CONFIG_MODULES disabled,
"make deb-pkg" (or "make bindeb-pkg") fails with:

find: ‘Module.symvers’: No such file or directory

If CONFIG_MODULES is disabled, it doesn't really make sense to build
the linux-headers package.

Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Wed Oct 14 03:38:19 2020 +0900
Upstream commit bac977cbc0d6731fb8e67c2be0e4acbd959e10b3

Fixes: 269a535ca931 ("modpost: generate vmlinux.symvers and reuse it for the second modpost")
Reported-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* mkdebian: fix: build a package for version 5.13

upstream commit 82526ef43399a7556b860538041802042b3872c1
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Tue Apr 20 02:05:05 2021 +0900

    kbuild: deb-pkg: change the source package name to linux-upstream

    Change the source package name from 'linux-$(KERNELRELEASE)' to
    'linux-upstream'.

    Initially, I tried to use 'linux' to be aligned with the Debian
    kernel package, but Ben suggested 'linux-upstream' so that it is
    clearly distinguished from distribution packages. [1]

    The filenames will be changed as follows:

    [Before]
      linux-5.12.0-rc3+_5.12.0-rc3+-1.dsc
      linux-5.12.0-rc3+_5.12.0-rc3+.orig.tar.gz
      linux-5.12.0-rc3+_5.12.0-rc3+-1.diff.gz

    [After]
      linux-upstream_5.12.0-rc3+-1.dsc
      linux-upstream_5.12.0-rc3+.orig.tar.gz
      linux-upstream_5.12.0-rc3+-1.diff.gz

    Commit 3716001bcb7f ("deb-pkg: add source package") introduced
    KDEB_SOURCENAME. If you are unhappy with the default name, you can
    override it via KDEB_SOURCENAME.

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* Search by template when updating initramfs

Search by pattern first, then use in the command.
If unsuccessful then exit by mistake.

Fix:
depmod: WARNING:
could not open modules.order at /var/tmp/mkinitramfs_bp3vP5/lib/modules/5.13.0-sunxi64:
 No such file or directory
could not open modules.builtin at /var/tmp/mkinitramfs_bp3vP5/lib/modules/5.13.0-sunxi64:
 No such file or directory
When a valid directory lib/modules/5.13.0-rc6-sunxi64
Or when the user added a localversion to the configuration file
and valid directory lib/modules/5.13.0-rt7-sunxi64

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* Code Cleanup: kernel build: Removing EXTRAVERSION Cleanup

This was intended for the EDGE kernel and is no longer required.
Moreover, this code is not working.

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>
2021-06-29 20:18:52 +02:00

257 lines
7.0 KiB
Bash
Executable File

#!/bin/sh
#
# Copyright 2003 Wichert Akkerman <wichert@wiggy.net>
#
# Simple script to generate a debian/ directory for a Linux kernel.
set -e
is_enabled() {
grep -q "^$1=y" include/config/auto.conf
}
if_enabled_echo() {
if is_enabled "$1"; then
echo -n "$2"
elif [ $# -ge 3 ]; then
echo -n "$3"
fi
}
set_debarch() {
if [ -n "$KBUILD_DEBARCH" ] ; then
debarch="$KBUILD_DEBARCH"
return
fi
# Attempt to find the correct Debian architecture
case "$UTS_MACHINE" in
i386|ia64|alpha|m68k|riscv*)
debarch="$UTS_MACHINE" ;;
x86_64)
debarch=amd64 ;;
sparc*)
debarch=sparc$(if_enabled_echo CONFIG_64BIT 64) ;;
s390*)
debarch=s390x ;;
ppc*)
if is_enabled CONFIG_64BIT; then
debarch=ppc64$(if_enabled_echo CONFIG_CPU_LITTLE_ENDIAN el)
else
debarch=powerpc$(if_enabled_echo CONFIG_SPE spe)
fi
;;
parisc*)
debarch=hppa ;;
mips*)
if is_enabled CONFIG_CPU_LITTLE_ENDIAN; then
debarch=mips$(if_enabled_echo CONFIG_64BIT 64)$(if_enabled_echo CONFIG_CPU_MIPSR6 r6)el
elif is_enabled CONFIG_CPU_MIPSR6; then
debarch=mips$(if_enabled_echo CONFIG_64BIT 64)r6
else
debarch=mips
fi
;;
aarch64|arm64)
debarch=arm64 ;;
arm*)
if is_enabled CONFIG_AEABI; then
debarch=arm$(if_enabled_echo CONFIG_VFP hf el)
else
debarch=arm
fi
;;
openrisc)
debarch=or1k ;;
sh)
if is_enabled CONFIG_CPU_SH3; then
debarch=sh3$(if_enabled_echo CONFIG_CPU_BIG_ENDIAN eb)
elif is_enabled CONFIG_CPU_SH4; then
debarch=sh4$(if_enabled_echo CONFIG_CPU_BIG_ENDIAN eb)
fi
;;
esac
if [ -z "$debarch" ]; then
debarch=$(dpkg-architecture -qDEB_HOST_ARCH)
echo "" >&2
echo "** ** ** WARNING ** ** **" >&2
echo "" >&2
echo "Your architecture doesn't have its equivalent" >&2
echo "Debian userspace architecture defined!" >&2
echo "Falling back to the current host architecture ($debarch)." >&2
echo "Please add support for $UTS_MACHINE to ${0} ..." >&2
echo "" >&2
fi
}
# Some variables and settings used throughout the script
KDEB_SOURCENAME=linux-$KERNELRELEASE
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-"$BRANCH$LOCALVERSION"
kernel_headers_packagename=linux-headers-"$BRANCH$LOCALVERSION"
libc_headers_packagename=linux-libc-dev
dtb_packagename=linux-dtb-"$BRANCH$LOCALVERSION"
dbg_packagename=$packagename-dbg
if [ "$ARCH" = "um" ] ; then
packagename=user-mode-linux-$version
fi
debarch=
set_debarch
email=${DEBEMAIL-$EMAIL}
# use email string directly if it contains <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
buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)}
email="$user@$buildhost"
fi
maintainer="$name <$email>"
fi
# Try to determine distribution
if [ -n "$KDEB_CHANGELOG_DIST" ]; then
distribution=$KDEB_CHANGELOG_DIST
# In some cases lsb_release returns the codename as n/a, which breaks dpkg-parsechangelog
elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ] && [ "$distribution" != "n/a" ]; then
: # nothing to do in this case
else
distribution="unstable"
echo >&2 "Using default distribution of 'unstable' in the changelog"
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
$sourcename ($packageversion) $distribution; urgency=low
* Armbian built Linux kernel. $BRANCH
-- $maintainer $(date -R)
EOF
# Generate copyright file
cat <<EOF > debian/copyright
This is a packacked armbian patches 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
Homepage: https://www.kernel.org/
Package: $packagename
Architecture: $debarch
Provides: linux-image, linux-image-armbian, armbian-$BRANCH
Description: Linux kernel, armbian version $version $BRANCH
This package contains the Linux kernel, modules and corresponding other
files, version: $version.
Package: $libc_headers_packagename
Section: devel
Provides: linux-kernel-headers
Conflicts: linux-kernel-headers
Replaces: linux-kernel-headers
Architecture: $debarch
Description: Armbian Linux support headers for userspace development
This package provides userspaces headers from the Linux kernel. These headers
are used by the installed headers for GNU glibc and other system libraries.
Multi-Arch: same
Package: $dtb_packagename
Architecture: $debarch
Provides: linux-dtb, linux-dtb-armbian, armbian-$BRANCH
Description: Armbian Linux DTB, version $version $BRANCH
This package contains device blobs from the Linux kernel, version $version
EOF
if is_enabled CONFIG_MODULES; then
cat <<EOF >> debian/control
Package: $kernel_headers_packagename
Section: devel
Architecture: $debarch
Provides: linux-headers, linux-headers-armbian, armbian-$BRANCH
Depends: make, gcc, libc6-dev, bison, flex, libssl-dev
Description: Linux kernel headers for $version on $debarch $BRANCH
This package provides kernel header files for $version on $debarch
.
This is useful for people who need to build external modules
EOF
fi
if is_enabled CONFIG_DEBUG_INFO; then
cat <<EOF >> debian/control
Package: $dbg_packagename
Section: debug
Architecture: $debarch
Description: Linux kernel debugging symbols for $version
This package will come in handy if you need to debug the kernel. It provides
all the necessary debug symbols for the kernel and its modules.
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
EOF
chmod +x debian/rules
exit 0