[pkg-nvidia-devel] Bug#520706: nvidia-kernel-source: A debian/rules which does the trick

Itaï BEN YAACOV candeb at free.fr
Mon Apr 6 11:14:51 UTC 2009


Package: nvidia-kernel-source
Version: 180.29-1
Severity: normal


See KCOM / KDIRS  definition.  I did not try it in other circumstances.


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (600, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.29-1-686 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages nvidia-kernel-source depends on:
ii  debhelper                     7.2.7      helper programs for debian/rules
ii  dpatch                        2.0.31     patch maintenance system for Debia
ii  make                          3.81-5     The GNU version of the "make" util
ii  sed                           4.1.5-8    The GNU sed stream editor

Versions of packages nvidia-kernel-source recommends:
ii  devscripts                    2.10.47    scripts to make the life of a Debi
ii  kernel-package                11.017     A utility for building Linux kerne
pn  nvidia-glx                    <none>     (no description available)

nvidia-kernel-source suggests no packages.

-- no debconf information
-------------- next part --------------
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This is the debhelper compatability version to use.
export DH_COMPAT=4

ifeq ($(shell id -u),0)
     ROOT_CMD=
endif
	
include $(CURDIR)/debian/conf.mk

KCOM=$(shell echo $(KSRC) | sed -e 's/\(.*linux-headers-[0-9]*\.[0-9]*\.[0-9]*-[0-9]*-\)[^\/]*/\1common/')
ifeq ($(KSRC),$(KCOM))
	KDIRS=SYSSRC=$(KSRC)
else
	KDIRS=SYSSRC=$(KCOM) KERNEL_OUTPUT=$(KSRC)
endif



.PHONY: build build-stamp
build: configure-stamp build-stamp
build-stamp:

	dh_testdir
	dh_testroot


	@echo "PATCHLEVEL = $(PATCHLEVEL) " ;
	@echo "Kernel compiler version : $(kernel_cc)" ; 
	@echo "Detected compiler version : $(module_cc)" ;
       

	@if [ "$(kernel_cc)" != "$(module_cc)" ]; then \
	echo "                                                           "; \
	echo "You appear to be compiling the NVIDIA kernel module with   "; \
	echo "a compiler different from the one that was used to compile "; \
	echo "the running kernel. This may be perfectly alright and you "; \
	echo "may be building this module for another kernel in which case"; \
	echo "you may ignore this message."; \
	echo " " ; \
	echo "The compiler that will be used to compile this module has been"; \
	echo "determined from:" ; \
	echo " 1) the CC environment variable " ; \
	echo " 2) that specified in "; \
	echo "    $(KSRC)/include/linux/compile.h" ; \
	echo " 3) gcc " ; \
	fi
	@echo "Using compiler $(CC) version $(module_cc)"; 

	

	touch $(CURDIR)/$(dirname)/gcc-check
	touch $(CURDIR)/$(dirname)/cc-sanity-check

	## Main Make ##
	IGNORE_CC_MISMATCH=1 CC="$(CC)" $(MAKE) -C $(CURDIR)/$(dirname) -f Makefile $(KDIRS)  $(KPKG_EXTRAV_ARG) KBUILD_PARAMS=$(KBUILD_PARAMS) module;

	touch build-stamp


.PHONY: install
install: build
	dh_testdir
	dh_testroot
	dh_clean -k

	sed 's/#KVERS#/$(KVERS)/g' debian/control.template > $(CURDIR)/debian/control
	sed 's/#KVERS#/$(KVERS)/g' debian/dirs.template > $(CURDIR)/debian/dirs
	sed 's/#KVERS#/$(KVERS)/g' debian/override.template > $(CURDIR)/debian/override

	dh_installdirs


	install -m 0644 $(CURDIR)/debian/override $(CURDIR)/debian/nvidia-kernel-$(KVERS)/usr/share/lintian/overrides/nvidia-kernel-$(KVERS)
	if [ "$(PATCHLEVEL)" = "6" ] ; then \
	   install -m 0644 $(CURDIR)/$(dirname)/nvidia.ko $(CURDIR)/debian/nvidia-kernel-$(KVERS)/lib/modules/$(KVERS)/nvidia/nvidia.ko ; \
	else \
	   install -m 0644 $(CURDIR)/$(dirname)/nvidia.o $(CURDIR)/debian/nvidia-kernel-$(KVERS)/lib/modules/$(KVERS)/nvidia/nvidia.o ;\
	fi





.PHONY: binary_modules
binary_modules: build install
	dh_testdir
	dh_testroot
#	dh_installdebconf	
	dh_installdocs
#	dh_installexamples
#	dh_installmanpages
#	dh_undocumented
	dh_installmodules

	dh_installinit
	
	dh_installchangelogs 
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
# You may want to make some executables suid here.
#	dh_suidregister
#	dh_makeshlibs
	dh_installdeb
#	dh_shlibdeps
	dh_gencontrol -- -v$(PKG_VERSION)
	dh_md5sums
	dh_builddeb  --destdir=$(KPKG_DEST_DIR)


.PHONY: clean
clean: clean.Makefile  unpatch
	if [ -f $(CURDIR)/debian/control.template ]; then \
		cp  $(CURDIR)/debian/control.template $(CURDIR)/debian/control; \
	fi

	dh_testroot
	rm -f build-stamp configure-stamp


	$(MAKE) clean $(KDIRS) -C $(CURDIR)/$(dirname) -f Makefile $(KPKG_EXTRAV_ARG)
        
	rm -f $(CURDIR)/$(dirname)/Makefile || true; 	
	-rm $(CURDIR)/$(dirname)/gcc-check
	-rm $(CURDIR)/$(dirname)/cc-sanity-check
	
	-dh_clean

	-rm $(CURDIR)/debian/control
	-rm $(CURDIR)/debian/dirs
	-rm $(CURDIR)/debian/override


unpatch: 
	if [ -e patch-stamp ]; then \
	   dpatch deapply-all ; \
	   rm -rf patch-stamp debian/patched ; \
	fi

	
	   

# The kdist_configure target is called by make-kpkg modules_config. It
# should configure the module so it is ready for compilation (mostly
# useful for calling configure)
.PHONY: kdist_config
kdist_config:
	     $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules configure

.PHONY: kdist_configure
kdist_configure:
		$(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules configure

# the kdist_image target is called by make-kpkg modules_image. It is
# responsible for compiling the module and creating the package. It
# should also clean up after making the module. Please note we use a
# seperate binary-modules target to make testing the package building
# easier
.PHONY: kdist_image
kdist_image:
	    echo "ROOT_CMD = $(ROOT_CMD)"
	    $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules binary_modules
	    $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules clean
 


# the kdist_clean target is called by make-kpkg modules_clean. It is
# responsible for cleaning up any changes that have been made by the
# other kdist_commands (except for the .deb files created).
.PHONY: kdist_clean
kdist_clean: 
	     $(MAKE) $(MFLAGS) -f debian/rules clean

kdist: 
	$(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules binary_modules
	# Build a .changes file.
	dpkg-genchanges -b -e"$(KMAINT) <$(KEMAIL)>" -u"$(KPKG_DEST_DIR)" > $(CHFILE)
	debsign -e"$(KMAINT) <$(KEMAIL)>" $(CHFILE)
	$(MAKE) $(MFLAGS) -f debian/rules clean
							


More information about the Pkg-nvidia-devel mailing list