Blame view
scripts/package/mkdebian
6.34 KB
b41d920ac kbuild: deb-pkg: ... |
1 2 3 4 5 6 7 |
#!/bin/sh # # Copyright 2003 Wichert Akkerman <wichert@wiggy.net> # # Simple script to generate a debian/ directory for a Linux kernel. set -e |
08d3892cd builddeb: Introdu... |
8 |
is_enabled() { |
6fb7ef5a3 kbuild: pkg: grep... |
9 |
grep -q "^$1=y" include/config/auto.conf |
08d3892cd builddeb: Introdu... |
10 11 12 13 14 15 16 17 18 |
} if_enabled_echo() { if is_enabled "$1"; then echo -n "$2" elif [ $# -ge 3 ]; then echo -n "$3" fi } |
b41d920ac kbuild: deb-pkg: ... |
19 |
set_debarch() { |
f2abcc13e builddeb: Skip ar... |
20 21 22 23 |
if [ -n "$KBUILD_DEBARCH" ] ; then debarch="$KBUILD_DEBARCH" return fi |
b41d920ac kbuild: deb-pkg: ... |
24 25 |
# Attempt to find the correct Debian architecture case "$UTS_MACHINE" in |
75ebcee76 builddeb: Add aut... |
26 |
i386|ia64|alpha|m68k|riscv*) |
b41d920ac kbuild: deb-pkg: ... |
27 28 29 30 |
debarch="$UTS_MACHINE" ;; x86_64) debarch=amd64 ;; sparc*) |
7e548e9a5 kbuild: deb-pkg: ... |
31 |
debarch=sparc$(if_enabled_echo CONFIG_64BIT 64) ;; |
b41d920ac kbuild: deb-pkg: ... |
32 |
s390*) |
4260ecd0a builddeb: Drop ch... |
33 |
debarch=s390x ;; |
b41d920ac kbuild: deb-pkg: ... |
34 |
ppc*) |
7e548e9a5 kbuild: deb-pkg: ... |
35 36 |
if is_enabled CONFIG_64BIT; then debarch=ppc64$(if_enabled_echo CONFIG_CPU_LITTLE_ENDIAN el) |
50d511ba6 builddeb: Add aut... |
37 |
else |
7e548e9a5 kbuild: deb-pkg: ... |
38 |
debarch=powerpc$(if_enabled_echo CONFIG_SPE spe) |
50d511ba6 builddeb: Add aut... |
39 40 |
fi ;; |
b41d920ac kbuild: deb-pkg: ... |
41 42 43 |
parisc*) debarch=hppa ;; mips*) |
7e548e9a5 kbuild: deb-pkg: ... |
44 45 46 47 |
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 |
159b37942 builddeb: Add aut... |
48 49 50 51 |
else debarch=mips fi ;; |
b41d920ac kbuild: deb-pkg: ... |
52 53 54 |
aarch64|arm64) debarch=arm64 ;; arm*) |
7e548e9a5 kbuild: deb-pkg: ... |
55 56 |
if is_enabled CONFIG_AEABI; then debarch=arm$(if_enabled_echo CONFIG_VFP hf el) |
b41d920ac kbuild: deb-pkg: ... |
57 |
else |
08d3892cd builddeb: Introdu... |
58 |
debarch=arm |
b41d920ac kbuild: deb-pkg: ... |
59 60 |
fi ;; |
822f44fb5 builddeb: Add aut... |
61 62 |
openrisc) debarch=or1k ;; |
79a85b55e builddeb: Add aut... |
63 |
sh) |
7e548e9a5 kbuild: deb-pkg: ... |
64 65 66 67 |
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) |
79a85b55e builddeb: Add aut... |
68 69 70 71 |
fi ;; esac if [ -z "$debarch" ]; then |
091d30aef builddeb: Change ... |
72 |
debarch=$(dpkg-architecture -qDEB_HOST_ARCH) |
b41d920ac kbuild: deb-pkg: ... |
73 74 75 76 77 |
echo "" >&2 echo "** ** ** WARNING ** ** **" >&2 echo "" >&2 echo "Your architecture doesn't have its equivalent" >&2 echo "Debian userspace architecture defined!" >&2 |
091d30aef builddeb: Change ... |
78 |
echo "Falling back to the current host architecture ($debarch)." >&2 |
b41d920ac kbuild: deb-pkg: ... |
79 80 |
echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 echo "" >&2 |
79a85b55e builddeb: Add aut... |
81 |
fi |
b41d920ac kbuild: deb-pkg: ... |
82 83 84 85 86 87 |
} # Some variables and settings used throughout the script version=$KERNELRELEASE if [ -n "$KDEB_PKGVERSION" ]; then packageversion=$KDEB_PKGVERSION |
bbcde0a72 kbuild: deb-pkg: ... |
88 |
revision=${packageversion##*-} |
b41d920ac kbuild: deb-pkg: ... |
89 90 91 92 93 |
else revision=$(cat .version 2>/dev/null||echo 1) packageversion=$version-$revision fi sourcename=$KDEB_SOURCENAME |
b41d920ac kbuild: deb-pkg: ... |
94 95 |
if [ "$ARCH" = "um" ] ; then |
0fa21cf44 kbuild: deb-pkg: ... |
96 97 98 |
packagename=user-mode-linux else packagename=linux-image |
b41d920ac kbuild: deb-pkg: ... |
99 |
fi |
0fa21cf44 kbuild: deb-pkg: ... |
100 101 |
debarch= set_debarch |
d5940c60e kbuild: deb-pkg i... |
102 103 104 105 106 |
email=${DEBEMAIL-$EMAIL} # use email string directly if it contains <email> if echo $email | grep -q '<.*>'; then maintainer=$email |
b41d920ac kbuild: deb-pkg: ... |
107 |
else |
d5940c60e kbuild: deb-pkg i... |
108 109 110 111 112 113 114 115 |
# 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>" |
b41d920ac kbuild: deb-pkg: ... |
116 |
fi |
b41d920ac kbuild: deb-pkg: ... |
117 118 119 120 121 122 123 124 125 126 127 128 |
# 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 |
f6d9db635 kbuild: deb-pkg: ... |
129 130 |
mkdir -p debian/source/ echo "1.0" > debian/source/format |
b41d920ac kbuild: deb-pkg: ... |
131 |
echo $debarch > debian/arch |
8ffdc54b6 kbuild/deb-pkg: a... |
132 |
extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)" |
7e548e9a5 kbuild: deb-pkg: ... |
133 |
extra_build_depends="$extra_build_depends, $(if_enabled_echo CONFIG_SYSTEM_TRUSTED_KEYRING libssl-dev:native)" |
b41d920ac kbuild: deb-pkg: ... |
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# Generate a simple changelog template cat <<EOF > debian/changelog $sourcename ($packageversion) $distribution; urgency=low * Custom built Linux kernel. -- $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 |
3e8541803 builddeb: Enable ... |
170 |
Rules-Requires-Root: no |
a11391b6f scripts: package:... |
171 |
Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends |
16a122c74 kbuild: Replace H... |
172 |
Homepage: https://www.kernel.org/ |
b41d920ac kbuild: deb-pkg: ... |
173 |
|
0fa21cf44 kbuild: deb-pkg: ... |
174 |
Package: $packagename-$version |
b41d920ac kbuild: deb-pkg: ... |
175 176 177 178 |
Architecture: $debarch Description: Linux kernel, version $version This package contains the Linux kernel, modules and corresponding other files, version: $version. |
b41d920ac kbuild: deb-pkg: ... |
179 180 181 182 183 184 185 |
Package: linux-libc-dev Section: devel Provides: linux-kernel-headers Architecture: $debarch Description: 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. |
5a4642178 builddeb: generat... |
186 |
Multi-Arch: same |
d9dac147a kbuild: deb-pkg: ... |
187 |
EOF |
bac977cbc kbuild: deb-pkg: ... |
188 189 |
if is_enabled CONFIG_MODULES; then cat <<EOF >> debian/control |
0fa21cf44 kbuild: deb-pkg: ... |
190 |
Package: linux-headers-$version |
bac977cbc kbuild: deb-pkg: ... |
191 192 193 194 195 196 197 |
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 |
d9dac147a kbuild: deb-pkg: ... |
198 199 |
if is_enabled CONFIG_DEBUG_INFO; then cat <<EOF >> debian/control |
b41d920ac kbuild: deb-pkg: ... |
200 |
|
0fa21cf44 kbuild: deb-pkg: ... |
201 |
Package: linux-image-$version-dbg |
b41d920ac kbuild: deb-pkg: ... |
202 203 204 205 206 207 |
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 |
d9dac147a kbuild: deb-pkg: ... |
208 |
fi |
b41d920ac kbuild: deb-pkg: ... |
209 210 211 |
cat <<EOF > debian/rules #!$(command -v $MAKE) -f |
175209cce kbuild: pkg: use ... |
212 |
srctree ?= . |
76c376687 builddeb: Add sup... |
213 214 |
build-indep: build-arch: |
bbcde0a72 kbuild: deb-pkg: ... |
215 |
\$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ |
175209cce kbuild: pkg: use ... |
216 |
KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile |
b41d920ac kbuild: deb-pkg: ... |
217 |
|
76c376687 builddeb: Add sup... |
218 219 220 221 |
build: build-arch binary-indep: binary-arch: build-arch |
bbcde0a72 kbuild: deb-pkg: ... |
222 |
\$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ |
175209cce kbuild: pkg: use ... |
223 |
KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg |
b41d920ac kbuild: deb-pkg: ... |
224 225 226 227 228 229 230 |
clean: rm -rf debian/*tmp debian/files \$(MAKE) clean binary: binary-arch EOF |
f6d9db635 kbuild: deb-pkg: ... |
231 |
chmod +x debian/rules |
b41d920ac kbuild: deb-pkg: ... |
232 233 |
exit 0 |