I have recently switched to debian, and I am trying to learn to compile kernels the debian way. I need a patch and an external module, so I am trying the following script:
M="make-kpkg \ --us --uc --initrd \ --append-to-version q4 \ --stem linux \ --added-modules madwifi \ --added-patches hda_codec.c-quique" $M clean $M configure kernel-image modules-image The point is to be able to rerun the script after fixing any errors I may have committed. It turns out that, when the patch has been applied, $M clean tries to unpatch the kernel source, but it does so only after having run "make ... distclean". Distclean removes the directory ./debian, which is used by the code that unpatches the source. Greatly simplified, the code in kernel-package/.../target.mk looks like: make distclean # removes debian/rules make -f debian/rules unpatch_now As a result I get the following output: ... test ! -f Makefile || \ /usr/bin/make ARCH=x86_64 distclean make[2]: Entering directory `/usr/src/linux-2.6-2.6.21' CLEAN scripts/basic CLEAN scripts/kconfig CLEAN /usr/src/linux-2.6-2.6.21/debian/ CLEAN include/config CLEAN .config include/linux/autoconf.h make[2]: Leaving directory `/usr/src/linux-2.6-2.6.21' test ! -f config.precious || mv -f config.precious .config /usr/bin/make -f ./debian/rules unpatch_now make[2]: Entering directory `/usr/src/linux-2.6-2.6.21' make[2]: ./debian/rules: No such file or directory make[2]: *** No rule to make target `./debian/rules'. Stop. make[2]: Leaving directory `/usr/src/linux-2.6-2.6.21' make[1]: *** [real_stamp_clean] Error 2 make[1]: Leaving directory `/usr/src/linux-2.6-2.6.21' make: *** [CLN-common] Error 2 I have found that my script works if I modify the file /usr/share/kernel-package/ruleset/targets/target.mk so that the unpatching happens before the distclean. However, I would like to ask if I am using the tools correctly. Is there any convenient way of upgrading the kernel within the debian framework, when I need both an external module, and a patch to one of the kernel source files? In the patch below, I have also tried to conserve the apparent goal of the code authors, who seem to have wanted that the deletion of the debian directory be controlled in target.mk, and only be done under certain conditions. --- kernel-package/ruleset/targets/save-target.mk 2007-05-05 07:48:30.000000000 +0200 +++ kernel-package/ruleset/targets/target.mk 2007-06-06 02:35:13.000000000 +0200 @@ -254,10 +254,23 @@ mv -f scripts/package/builddeb.kpkg-dist scripts/package/builddeb test ! -f scripts/package/Makefile.kpkg-dist || \ mv -f scripts/package/Makefile.kpkg-dist scripts/package/Makefile + $(eval $(deb_rule)) +ifeq ($(strip $(patch_the_kernel)),YES) + $(run_command) unpatch_now +endif +ifeq ($(strip $(NO_UNPATCH_BY_DEFAULT)),) + test ! -f stamp-patch || $(run_command) unpatch_now +endif + test -f stamp-building || test -f debian/official || rm -rf debian ifeq ($(DEB_HOST_GNU_SYSTEM), linux-gnu) test ! -f .config || cp -pf .config config.precious + test ! -d debian || { \ + rm -rf debian.precious; \ + mv -fT debian debian.precious; \ + } test ! -f Makefile || \ $(MAKE) $(FLAV_ARG) $(EXTRAV_ARG) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) distclean + test ! -f debian.precious || mv -f debian.precious debian test ! -f config.precious || mv -f config.precious .config else rm -f .config @@ -268,14 +281,6 @@ fi endif endif - $(eval $(deb_rule)) -ifeq ($(strip $(patch_the_kernel)),YES) - $(run_command) unpatch_now -endif -ifeq ($(strip $(NO_UNPATCH_BY_DEFAULT)),) - test ! -f stamp-patch || $(run_command) unpatch_now -endif - test -f stamp-building || test -f debian/official || rm -rf debian # work around idiocy in recent kernel versions test ! -e scripts/package/builddeb.dist || \ mv -f scripts/package/builddeb.dist scripts/package/builddeb