Skip to content

Commit 3126c17

Browse files
committed
builddeb: split kernel headers deployment out into a function
Deploy kernel headers (linux-headers package) in a separate function for readability. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent aae6a67 commit 3126c17

File tree

1 file changed

+42
-34
lines changed

1 file changed

+42
-34
lines changed

scripts/package/builddeb

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,49 @@ create_package() {
4646
dpkg-deb ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" ..
4747
}
4848

49+
deploy_kernel_headers () {
50+
pdir=$1
51+
52+
rm -rf $pdir
53+
54+
(
55+
cd $srctree
56+
find . arch/$SRCARCH -maxdepth 1 -name Makefile\*
57+
find include scripts -type f -o -type l
58+
find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform
59+
find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f
60+
) > debian/hdrsrcfiles
61+
62+
{
63+
if is_enabled CONFIG_STACK_VALIDATION; then
64+
echo tools/objtool/objtool
65+
fi
66+
67+
find arch/$SRCARCH/include Module.symvers include scripts -type f
68+
69+
if is_enabled CONFIG_GCC_PLUGINS; then
70+
find scripts/gcc-plugins -name \*.so
71+
fi
72+
} > debian/hdrobjfiles
73+
74+
destdir=$pdir/usr/src/linux-headers-$version
75+
mkdir -p $destdir
76+
tar -c -f - -C $srctree -T debian/hdrsrcfiles | tar -xf - -C $destdir
77+
tar -c -f - -T debian/hdrobjfiles | tar -xf - -C $destdir
78+
rm -f debian/hdrsrcfiles debian/hdrobjfiles
79+
80+
# copy .config manually to be where it's expected to be
81+
cp $KCONFIG_CONFIG $destdir/.config
82+
83+
mkdir -p $pdir/lib/modules/$version/
84+
ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build
85+
}
86+
4987
version=$KERNELRELEASE
5088
tmpdir=debian/linux-image
51-
kernel_headers_dir=debian/linux-headers
5289
libc_headers_dir=debian/linux-libc-dev
5390
dbg_dir=debian/linux-image-dbg
5491
packagename=linux-image-$version
55-
kernel_headers_packagename=linux-headers-$version
5692
libc_headers_packagename=linux-libc-dev
5793
dbg_packagename=$packagename-dbg
5894

@@ -77,10 +113,9 @@ esac
77113
BUILD_DEBUG=$(if_enabled_echo CONFIG_DEBUG_INFO Yes)
78114

79115
# Setup the directory structure
80-
rm -rf "$tmpdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" debian/files
116+
rm -rf "$tmpdir" "$libc_headers_dir" "$dbg_dir" debian/files
81117
mkdir -m 755 -p "$tmpdir/DEBIAN"
82118
mkdir -p "$tmpdir/lib" "$tmpdir/boot"
83-
mkdir -p "$kernel_headers_dir/lib/modules/$version/"
84119

85120
# Install the kernel
86121
if [ "$ARCH" = "um" ] ; then
@@ -163,37 +198,10 @@ EOF
163198
chmod 755 "$tmpdir/DEBIAN/$script"
164199
done
165200

166-
# Build kernel header package
167-
(
168-
cd $srctree
169-
find . arch/$SRCARCH -maxdepth 1 -name Makefile\*
170-
find include scripts -type f -o -type l
171-
find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform
172-
find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f
173-
) > debian/hdrsrcfiles
174-
175-
{
176-
if is_enabled CONFIG_STACK_VALIDATION; then
177-
echo tools/objtool/objtool
178-
fi
179-
180-
find arch/$SRCARCH/include Module.symvers include scripts -type f
181-
182-
if is_enabled CONFIG_GCC_PLUGINS; then
183-
find scripts/gcc-plugins -name \*.so
184-
fi
185-
} > debian/hdrobjfiles
186-
187-
destdir=$kernel_headers_dir/usr/src/linux-headers-$version
188-
mkdir -p "$destdir"
189-
tar -c -f - -C $srctree -T debian/hdrsrcfiles | tar -xf - -C $destdir
190-
tar -c -f - -T debian/hdrobjfiles | tar -xf - -C $destdir
191-
cp $KCONFIG_CONFIG $destdir/.config # copy .config manually to be where it's expected to be
192-
ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build"
193-
rm -f debian/hdrsrcfiles debian/hdrobjfiles
194-
195201
if [ "$ARCH" != "um" ]; then
196-
create_package "$kernel_headers_packagename" "$kernel_headers_dir"
202+
deploy_kernel_headers debian/linux-headers
203+
create_package linux-headers-$version debian/linux-headers
204+
197205
create_package "$libc_headers_packagename" "$libc_headers_dir"
198206
fi
199207

0 commit comments

Comments
 (0)