File: sample.module.rules

package info (click to toggle)
kernel-package 7.107
  • links: PTS
  • area: main
  • in suites: woody
  • size: 960 kB
  • ctags: 432
  • sloc: perl: 2,818; makefile: 1,574; sh: 231
file content (200 lines) | stat: -rwxr-xr-x 6,827 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#! /usr/bin/make -f

# Name of package
package		= kernmod
# KSRC is the location of the kernel source. This is the default value,
# when make-kpkg is used it will supply to real value
KSRC		= /usr/src/linux
# KDREV is the package-revision, as given to make-kpkg by the user.
# Just put a simply default value in here which we use when we test
# the packagebuilding without make-kpkg
ifeq ($(strip $(KDREV)),)
KDREV		= "test1.0"
endif

## Now to determine the kernel version, normally supplied by make-kpkg
ifeq ($(strip $(KVERS)),)
# Now we need to get the kernel-version somehow (we are not running
# under make-kpkg?)
ifeq ($(strip $(KSRC)),)
$(error Error. I do not know how to determine the kernel version)
else
kversion :=$(shell egrep '^VERSION +=' $(KSRC)/Makefile 2>/dev/null | \
                 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
kplevel  :=$(shell egrep '^PATCHLEVEL +=' $(KSRC)/Makefile 2>/dev/null | \
                    sed -e 's/[^0-9]*\([0-9]*\)/\1/')
ksublevel:=$(shell egrep '^SUBLEVEL +=' $(KSRC)/Makefile 2>/dev/null | \
                  sed -e 's/[^0-9]*\([0-9]*\)/\1/')
EXTRA_VERSION:=$(shell egrep '^EXTRAVERSION +=' $(KSRC)/Makefile 2>/dev/null | \
                 sed -e 's/EXTRAVERSION[\t ]*=[\t ]*\(.*\)/\1/')
kextra:=$(strip $(EXTRA_VERSION))
HAVE_NEW_MODLIB:=$(shell egrep '\(INSTALL_MOD_PATH\)' \
                            $(KSRC)/Makefile 2>/dev/null )

# If you want to have more than one kernel configuration per kernel
# version, set FLAVOUR in the top level kernel Makefile *before*
# invoking make-kpkg -- it will be appended to UTS_RELEASE in
# version.h (separated by a hyphen). This affects everything -- the
# names and versions of the image, source, headers, and doc packages,
# and where the modules are searched for in /lib/modules.

ifdef FLAVOUR
# uhm - should check if we really have a Makefile capable of Flavours?
endif

FLAVOUR:=$(shell grep ^FLAVOUR $(KSRC)/Makefile 2>/dev/null | \
                  perl -ple 's/FLAVOUR[\s:=]+//g')

ifneq ($(strip $(FLAVOUR)),)
INT_FLAV := -$(FLAVOUR)
FLAV_ARG := FLAVOUR=$(FLAVOUR)
else
INT_FLAV :=
FLAV_ARG :=
endif

## This is the replacement for FLAVOUR
ifneq ($(strip $(APPEND_TO_VERSION)),)
iatv := $(strip $(APPEND_TO_VERSION))
EXTRAV_ARG := EXTRAVERSION=${EXTRA_VERSION}${iatv}
else
iatv :=
EXTRAV_ARG :=
endif

KVERS = $(kversion).$(kplevel).$(ksublevel)$(kextra)$(iatv)$(INT_FLAV)

endif
endif

non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
epoch=$(shell echo $(KVERS) | perl -ne 'm/^(\d+:)/ && print $$1')

# We also need the package version
pversion	= $(shell sed -ne '1s/.*\((.*)\).*/\1/' debian/changelog)

# MODDIR is the place where the final .deb package should be made. This is the
# default value, when make-kpkg is used it will supply to real value
MODDIR		= ..

# Lets define the standard targets first

.PHONY: binary
binary: binary-indep binary-arch

# Please note that I've put binary-common with binary-indep here. For
# package where binaries are in binary-common this should be moved to
# binary-arch
.PHONY: binary-indep
binary-indep: binary-source binary-common

# For binary-arch we do nothing so autobuilder don't try to build the
# kernel modules.
.PHONY: binary-arch
binary-arch:


# 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:
	@echo Nothing to 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:
	$(MAKE) $(MFLAGS) debian/rules binary-modules
	$(MAKE) $(MFLAGS) 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) debian/rules clean

# the binary-source target creates the kernmod-source package. It does
# this by copying the entire package source into debian/tmp and running
# clean in the copy
.PHONY: binary-source
binary-source:
# Perform some simple tests
	test -f debian/rules
	test `id -u` = 0

# Initialize some things
	-rm -rf debian/tmp debian/substvars
	install -d -m 755 -o root -g root debian/tmp

# Copy the entire source to the proper location
	install -d -m 755 -o root -g root debian/tmp/usr/src/modules/$(package)
	find . \( -name \*.o -path ./debian/tmp \) -prune -o print | \
		cpio -admp debian/tmp/usr/src/modules/$(package)
	( cd debian/tmp/usr/src/modules/$(package) ; \
	  $(MAKE) $(MFLAGS) -f debian/rules clean )

# Install the usual stuff now. Note that we symlink the doc-directory
# to the kernmod-modules directory so we have all the docs in a single
# place.
	install -d -m 755 -o root -g root debian/tmp/usr/doc
	ln -s $(package)-modules debian/tmp/usr/doc/$(package)-source

	install -d -m 755 -o root -g root debian/tmp/DEBIAN
	install -p -m 644 -o root -g root debian/control debian/tmp/DEBIAN/

# Generate the package
	find debian/tmp -type f | grep -v "./DEBIAN" | xargs md5sum | \
		sed -e 's#debian/tmp/##' > debian/tmp/DEBIAN/md5sums
	dpkg-gencontrol -p$(package)-source
	dpkg --build debian/tmp ..

# the binary-common target creates the kernmod-common package.
.PHONY: binary-common
binary-common:
# Perform some simple tests
	test -f debian/rules
	test `id -u` = 0

# Initialize some things
	-rm -rf debian/tmp debian/substvars
	install -d -m 755 -o root -g root debian/tmp

	@echo TODO: put everything you want to put in the kernmod-common
	@echo package in here

# Generate the package
	find debian/tmp -type f | grep -v "./DEBIAN" | xargs md5sum | \
		sed -e 's#debian/tmp/##' > debian/tmp/DEBIAN/md5sums
	dpkg-gencontrol -p$(package)-common
	dpkg --build debian/tmp ..

# the binary-modules target creates the kernmod-modules-XXX package.
.PHONY: binary-modules
binary-modules:
# Perform some simple tests
	test -f debian/rules
	test `id -u` = 0

# Initialize some things
	-rm -rf debian/tmp debian/substvars
	install -d -m 755 -o root -g root debian/tmp

	@echo TODO: put everything you want to put in the kernmod-modules
	@echo package in here

# Generate the package
	echo "kpkg:Package-Version=$(epoch)$(pversion)+$(non_epoch_version)" \
		 >> debian/substvars
	echo "kpkg:Kernel-Version=$(KVERS)" >> debian/substvars

	find debian/tmp -type f | grep -v "./DEBIAN" | xargs md5sum | \
		sed -e 's#debian/tmp/##' > debian/tmp/DEBIAN/md5sums
	dpkg-gencontrol -p$(package)-modules-$(non_epoch_version)  \
		-v$(epoch)$(pversion)+$(non_epoch_version)
	dpkg --build debian/tmp ..