1212
1313set -e
1414
15+ is_enabled () {
16+ grep -q " ^$1 =y" $KCONFIG_CONFIG
17+ }
18+
19+ if_enabled_echo () {
20+ if is_enabled " $1 " ; then
21+ echo -n " $2 "
22+ elif [ $# -ge 3 ]; then
23+ echo -n " $3 "
24+ fi
25+ }
26+
1527create_package () {
1628 local pname=" $1 " pdir=" $2 "
1729
@@ -62,7 +74,7 @@ parisc|mips|powerpc)
6274 installed_image_path=" boot/vmlinuz-$version "
6375esac
6476
65- BUILD_DEBUG=" $( grep -s ' ^ CONFIG_DEBUG_INFO=y ' $KCONFIG_CONFIG || true ) "
77+ BUILD_DEBUG=$( if_enabled_echo CONFIG_DEBUG_INFO Yes )
6678
6779# Setup the directory structure
6880rm -rf " $tmpdir " " $kernel_headers_dir " " $libc_headers_dir " " $dbg_dir " $objtree /debian/files
8395fi
8496cp " $( $MAKE -s -f $srctree /Makefile image_name) " " $tmpdir /$installed_image_path "
8597
86- if grep -q " ^ CONFIG_OF_EARLY_FLATTREE=y " $KCONFIG_CONFIG ; then
98+ if is_enabled CONFIG_OF_EARLY_FLATTREE; then
8799 # Only some architectures with OF support have this target
88100 if [ -d " ${srctree} /arch/$SRCARCH /boot/dts" ]; then
89101 $MAKE -f $srctree /Makefile INSTALL_DTBS_PATH=" $tmpdir /usr/lib/$packagename " dtbs_install
90102 fi
91103fi
92104
93- if grep -q ' ^ CONFIG_MODULES=y ' $KCONFIG_CONFIG ; then
105+ if is_enabled CONFIG_MODULES; then
94106 INSTALL_MOD_PATH=" $tmpdir " $MAKE -f $srctree /Makefile modules_install
95107 rm -f " $tmpdir /lib/modules/$version /build"
96108 rm -f " $tmpdir /lib/modules/$version /source"
@@ -111,8 +123,7 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
111123 done
112124
113125 # resign stripped modules
114- MODULE_SIG_ALL=" $( grep -s ' ^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true) "
115- if [ -n " $MODULE_SIG_ALL " ]; then
126+ if is_enabled CONFIG_MODULE_SIG_ALL; then
116127 INSTALL_MOD_PATH=" $tmpdir " $MAKE -f $srctree /Makefile modules_sign
117128 fi
118129 fi
129140# make-kpkg sets $INITRD to indicate whether an initramfs is wanted, and
130141# so do we; recent versions of dracut and initramfs-tools will obey this.
131142debhookdir=${KDEB_HOOKDIR:-/ etc/ kernel}
132- if grep -q ' ^CONFIG_BLK_DEV_INITRD=y' $KCONFIG_CONFIG ; then
133- want_initrd=Yes
134- else
135- want_initrd=No
136- fi
137143for script in postinst postrm preinst prerm ; do
138144 mkdir -p " $tmpdir$debhookdir /$script .d"
139145 cat << EOF > "$tmpdir /DEBIAN/$script "
@@ -145,7 +151,7 @@ set -e
145151export DEB_MAINT_PARAMS="\$ *"
146152
147153# Tell initramfs builder whether it's wanted
148- export INITRD=$want_initrd
154+ export INITRD=$( if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No )
149155
150156test -d $debhookdir /$script .d && run-parts --arg="$version " --arg="/$installed_image_path " $debhookdir /$script .d
151157exit 0
@@ -158,11 +164,11 @@ done
158164(cd $srctree ; find arch/* /include include scripts -type f -o -type l) >> " $objtree /debian/hdrsrcfiles"
159165(cd $srctree ; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> " $objtree /debian/hdrsrcfiles"
160166(cd $srctree ; find $( find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> " $objtree /debian/hdrsrcfiles"
161- if grep -q ' ^ CONFIG_STACK_VALIDATION=y ' $KCONFIG_CONFIG ; then
167+ if is_enabled CONFIG_STACK_VALIDATION; then
162168 (cd $objtree ; find tools/objtool -type f -executable) >> " $objtree /debian/hdrobjfiles"
163169fi
164170(cd $objtree ; find arch/$SRCARCH /include Module.symvers include scripts -type f) >> " $objtree /debian/hdrobjfiles"
165- if grep -q ' ^ CONFIG_GCC_PLUGINS=y ' $KCONFIG_CONFIG ; then
171+ if is_enabled CONFIG_GCC_PLUGINS; then
166172 (cd $objtree ; find scripts/gcc-plugins -name \* .so -o -name gcc-common.h) >> " $objtree /debian/hdrobjfiles"
167173fi
168174destdir=$kernel_headers_dir /usr/src/linux-headers-$version
0 commit comments