| 1 |
CREATING MODULE PACKAGES WITH M-A, MINI-HOWTO |
| 2 |
--------------------------------------------- |
| 3 |
|
| 4 |
Table of contents: |
| 5 |
------------------ |
| 6 |
|
| 7 |
- Howto |
| 8 |
- Notes |
| 9 |
- Troubleshooting |
| 10 |
|
| 11 |
Howto: |
| 12 |
------ |
| 13 |
|
| 14 |
Let's look on how we create a module-package with source package, using |
| 15 |
module-assistant where possible. |
| 16 |
|
| 17 |
A sample snapshot of the debian/ directory is located in the |
| 18 |
/usr/share/doc/module-assistant/examples/. |
| 19 |
|
| 20 |
To demonstrate the steps to package something from scratch, I will take shfs as |
| 21 |
example: |
| 22 |
|
| 23 |
1. Get the upstream source (I had to repack the upstream tarball, |
| 24 |
removing the half-cooked debian/ directory in shfs source, btw.) |
| 25 |
2. Run dh_make as usual and select "multiple binary" |
| 26 |
3. Edit debian/control and assign proper package names (I rename shfs to |
| 27 |
shfs-utils and shfs-doc to shfs-src and give proper descriptions). Don't |
| 28 |
forget to add debhelper to Depends of the -source package if it is used. |
| 29 |
4. Edit debian/rules and substitute the package names to match those in control |
| 30 |
5. Adapt or remove the example files in debian/ |
| 31 |
6. Edit the build-arch-stamp and install-arch rules to build/install |
| 32 |
ONLY the user applications (here: to build only the mount utilities) |
| 33 |
7. Edit the build-indep rule to do nothing and the install rule to |
| 34 |
install the package source into a tarball, as following example |
| 35 |
shows. Optionaly, the -utils package can get a control script for |
| 36 |
module-assistant, which is simply the "default.sh" from m-a. |
| 37 |
|
| 38 |
# create needed directories |
| 39 |
dh_installdirs -i usr/src/modules |
| 40 |
# only if needed |
| 41 |
dh_installdirs -a usr/share/modass/overrides |
| 42 |
|
| 43 |
# copy the driver source from shfs/ |
| 44 |
cp -a shfs debian/shfs-source/usr/src/modules/ |
| 45 |
|
| 46 |
# copy all relevant debian/ files. |
| 47 |
mkdir debian/shfs-source/usr/src/modules/shfs/debian |
| 48 |
cd debian ; cp changelog control compat *.modules.in rules copyright shfs-source/usr/src/modules/shfs/debian |
| 49 |
|
| 50 |
# entar the source |
| 51 |
cd debian/shfs-source/usr/src/ ; tar -c modules | bzip2 -9 > shfs.tar.bz2 && rm -rf modules |
| 52 |
|
| 53 |
# install the control script, if wished. Not really required for package to be |
| 54 |
# processed but helps m-a frontend: puts the package into the list of known |
| 55 |
# packages |
| 56 |
ln -s ../packages/default.sh debian/shfs-utils/usr/share/modass/overrides/shfs-source |
| 57 |
|
| 58 |
8. Return to the file header (or some position right before the module specific |
| 59 |
targets begin) and load the m-a includes: |
| 60 |
|
| 61 |
# prefix of the target package name |
| 62 |
PACKAGE=shfs-module |
| 63 |
# modifieable for experiments or debugging m-a |
| 64 |
MA_DIR ?= /usr/share/modass |
| 65 |
# load generic variable handling |
| 66 |
-include $(MA_DIR)/include/generic.make |
| 67 |
# load default rules |
| 68 |
-include $(MA_DIR)/include/common-rules.make |
| 69 |
|
| 70 |
8. Complete the module-building routines, adding missig rules: |
| 71 |
|
| 72 |
8.1. Add a cleaning rule |
| 73 |
|
| 74 |
MAJOR=$(shell echo $(KVERS) | sed -e 's/\(...\).*/\1/') |
| 75 |
ifeq ($(MAJOR),2.6) |
| 76 |
KO=k |
| 77 |
endif |
| 78 |
|
| 79 |
kdist_clean: |
| 80 |
dh_clean |
| 81 |
make -C Linux-$(MAJOR) clean |
| 82 |
|
| 83 |
8.2. Add the configuring rule and map the conventional target name to m-a |
| 84 |
|
| 85 |
# prep-deb-files rewrites the debian/ files as needed. See README for |
| 86 |
# details |
| 87 |
kdist_config: prep-deb-files |
| 88 |
# ... additional kernel specific things to configure... |
| 89 |
|
| 90 |
kdist_configure: kdist_config |
| 91 |
|
| 92 |
8.2. Create the binary-modules rule, like the following one: |
| 93 |
|
| 94 |
binary-modules: prep-deb-files |
| 95 |
dh_testdir |
| 96 |
dh_testroot |
| 97 |
dh_clean -k |
| 98 |
make -C Linux-$(MAJOR) KERNEL_SOURCES=$(KSRC) MODVERSIONS=detect KERNEL=linux-$(KVERS) |
| 99 |
install -m644 -b -D Linux-$(MAJOR)/shfs.$(KO)o $(CURDIR)/debian/$(PKGNAME)/lib/modules/$(KVERS)/shfs/shfs.$(KO)o |
| 100 |
dh_installdocs |
| 101 |
dh_installchangelogs |
| 102 |
dh_compress |
| 103 |
dh_fixperms |
| 104 |
dh_installdeb |
| 105 |
dh_gencontrol -- -v$(VERSION) |
| 106 |
dh_md5sums |
| 107 |
dh_builddeb --destdir=$(DEB_DESTDIR) |
| 108 |
|
| 109 |
9. Add some hints for the users into README.Debian in both, utils and the |
| 110 |
-source package (the usual blah, blah, suggesting make-kpkg, |
| 111 |
"m-a a-i thismodule" or similar things) |
| 112 |
|
| 113 |
10. Add a thisPackage-_KVERS_.postinst.modules.in file where you invoke depmod |
| 114 |
(see other examples), restart some daemon, etc.pp. |
| 115 |
|
| 116 |
DONE! |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
TROUBLESHOOTING: |
| 122 |
---------------- |
| 123 |
|
| 124 |
Q: I cannot understand what m-a is doing in background. |
| 125 |
A: Luke, use the undocumented option -d aka --debug. |
| 126 |
|
| 127 |
Q: How to prevent m-a from cleaning up after build? |
| 128 |
A: Edit /usr/share/modass/include/common-rules.make and remove the clean call |
| 129 |
from the kdist rule. |