Newer
Older
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/kernel-wedge-2.96ubuntu3/README b/kernel-wedge-2.96ubuntu3/README
new file mode 100644
index 0000000..5d7d329
--- /dev/null
+++ b/kernel-wedge-2.96ubuntu3/README
@@ -0,0 +1,195 @@
+This is kernel-wedge, an industrial strength kernel splitting tool.
+It is used to generate kernel module udebs for the debian installer.
+
+To use kernel-wedge, you need a source package, which will become the
+"source" for the generated udebs. Your source package will be very simple,
+looking something like this:
+
+ debian/copyright
+ debian/changelog
+ debian/rules
+ debian/control.stub
+
+ kernel-versions
+ modules/<arch>/*
+ exclude-packages
+ package-list
+
+The second group of files may be placed in a subdirectory, in which
+case the environment variable $KW_CONFIG_DIR must be set to the
+subdirectory name.
+
+Let's get the easy files out of the way. The changelog is a changelog, like
+any other, as is the copyright. The debian/rules can be something as simple
+as this:
+
+ #!/usr/bin/make -f
+ include /usr/share/kernel-wedge/generic-rules
+
+Or you can use the kernel-wedge command directly in your own rules file.
+Run it for some semblance of usage help.
+
+debian/control.stub is the top of a control file. Something like this:
+
+ Source: linux-kernel-di-i386
+ Section: debian-installer
+ Priority: optional
+ Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
+ Build-Depends: kernel-wedge
+
+The rest of the control file will be generated for you.
+
+The kernel-versions file lists the kernel versions to produce packages for.
+There are 6 whitespace separated fields per line, and it looks something
+like this:
+
+# arch version flavour installedname suffix build-depends
+i386 2.4.25-1 386 2.4.25-1-386 - kernel-image-2.4.25-1-386, kernel-pcmcia-modules-2.4.25-1-386
+i386 2.4.24 speakup 2.4.24-speakup - kernel-image-2.4.24-speakup
+
+In this case we are building two different flavours of i386 kernels.
+We could just as easily be building kernels for different architectures.
+
+The version is the kernel version, or can be "-", in which case a
+version must be specified when running the gen-control and install-files
+commands.
+
+The installedname column gives the directory/filename that the kernel and
+modules are installed using in the kernel .deb. If it is "-", it's
+generated from the version and flavor.
+
+The suffix column is either y, - or -$suffix; if it is y then the kernel
+image inside the udeb will include the version and flavour in its name, if
+it is -$suffix then it will include this. (So will the System.map).
+
+The build-depends are the package that is split up by kernel-wedge.
+If it's "-", kernel-wedge is being used inside the kernel's source
+package.
+
+Finally, you need a modules/<arch> directory, or directories. These are
+used to list the modules that go in a kernel. For example, for i386, we
+want to have some nic drivers, so we create a modules/i386/nic-modules
+listing them:
+
+# My short list of nic modules.
+8139too
+e100
+natsemi
+ne2k-pci
+tulip
+winbond-840
+3c59x
+
+Suppose we want a different set of modules in the speakup flavored kernel.
+Then create a modules/<arch>-<flavor>/nic-modules instead, it will be used
+by preference. One udeb will be created for each modules list file,
+containing the listed modules. The names of the files should match the
+names of the various modules listed in the package-list file in the
+default-configuration directory.
+
+The default-configuration directory is specified by the environment
+variable $KW_DEFCONFIG_DIR.
+
+You will also want a special modules list file for the kernel-image udeb.
+If you need to include no modules with your kernel, it can be an empty file.
+but you should have a modules/<arch>/kernel.
+
+kernel-wedge will copy the listed modules into each package. If a listed
+module does not exist, it will fail by default. Sometimes you might want to
+make a module be included but it's not fatal for it not to be available.
+To indicate this, follow the module with a space and a "?".
+
+Module list files can also include other module lists by reference. This
+works similar to cpp includes, and can be used to include module lists
+distributed as part of kernel-wedge, or others. For example:
+
+# kernel-wedge's standard set of cdrom modules
+#include <cdrom-core-modules>
+# my own list
+#include "../../includes/cdrom-modules"
+
+The <name> syntax includes a file from the modules subdirectory of the
+default-configuration directory.
+
+A final capability of the module list files is the ability to include a
+module list and then override parts of it. Follow a module name with " -" to
+remove it from the list if it was previously listed, as by an include:
+
+# kernel-wedge's standard set of cdrom modules
+#include <cdrom-core-modules>
+# but not this one
+sr_mod -
+
+The udebs are named with the version of the kernel in their package name,
+since that can be useful during kernel transitions. The string -di is
+appended to prevent any posible collisions in names with real debs.
+
+A few other, optional files:
+
+The package-list file can be used to override and/or suppliment values from
+kernel-wedge's own /usr/share/kernel-wedge/package-list file. New packages
+can be defined in this file using the same format, or partial entries can
+be used to override a field or fields of a previously defined package. For
+example:
+
+# This file is used to build up the control file. The kernel version and
+# "-di" are appended to the package names. Section can be left out. So can
+# architecture, which is derived from the files in the modules directory.
+# It overwrites specifications from /usr/share/kernel-wedge/package-list.
+Package: fat-modules
+Priority: standard
+
+Package: nic-modules
+Depends: kernel-image, nic-shared-modules, core-modules, firewire-core-modules
+
+Package: other-modules
+Depends: kernel-image
+Description: some other modules I like to have in the installer
+
+Note that dependencies that are not built are omitted from the control file
+generated by the union of the package-list files. If you don't want that to
+happen for a particular dependency, follow it by a "!"
+
+Depends: some-third-party-module!
+
+The exclude-packages file is an optional file that lists any udebs (by
+full package name) that would normally be built, but that you want to
+skip.
+
+Building:
+
+Once you have your source package set up, run:
+ kernel-wedge gen-control > debian/control
+You only need to do this once. Then build it like any other package. Be
+amazed at the sheer quantities of udebs that are spit out with no effort.
+Note that you will have to have the kernels listed as build dependencies
+installed normally; but see "kernel-wedge help build-all" for an
+alternative.
+
+Misc other info:
+
+The "kernel-wedge copy-modules" command does the actual copying of modules
+to the temp dirs that are used to build the package. It is complicated by
+the need to make sure that all of a module's dependencies are included in
+its package, or in a package on which it depends. If necessary, extra
+modules will be added to a package to make sure the dependencies are
+satisfied.
+
+The dependency information from modules.dep is compared with the output of
+the "kernel-wedge gen-deps" command, which extracts dependency information
+from package-lists, and formats it in a form used by tsort. If any
+additional modules are needed to meet dependencies of modules in the udebs,
+they will automatically be added. Since that might result in modules being
+copied to multiple udebs, the "kernel-wedge find-dups" command is used to
+scan for duplicates of modules. When you have duplicates, you need to find
+(or make) a package that both packages depend on, and move the duplicate
+modules to it. Alternatively, as a quick hack you can just touch a file
+named ignore-dups in the root of your package and duplicate modules will
+stop being a fatal error.
+
+SOURCEDIR can be set to a directory containing a tree of kernel modules and
+kernel image, and it will be used instead of the usual tree. That directory
+will need to have a modules.dep file already generated for this to work
+though -- but the modules.dep can even be copied from another system and
+it'll work. This can be useful if you cannot install the required
+kernel-image package, or are cross-compiling.
diff --git a/kernel-wedge-2.104ubuntu1/README.md b/kernel-wedge-2.104ubuntu1/README.md
deleted file mode 100644
index 06d5d3c..0000000
--- a/kernel-wedge-2.104ubuntu1/README.md
+++ /dev/null
@@ -1,224 +0,0 @@
-# kernel-wedge, an industrial strength kernel splitting tool
-
-kernel-wedge is used to generate kernel module udebs for the debian
-installer.
-
-kernel-wedge is now used as part of the build process of the linux and
-kfreebsd-* source packages, but can also be used separately.
-
-## Configuration directory layout
-
-The default-configuration directory contains the following files:
-
-modules/*<BR>
-package-list
-
-The environment variable `$KW_DEFCONFIG_DIR` must be set, naming the
-default-configuration directory.
-
-Each configuration directory contains the following files:
-
-kernel-versions<BR>
-modules/*arch*/\*<BR>
-exclude-packages (optional)<BR>
-package-list
-
-The environment variable `$KW_CONFIG_DIR` may be set, naming the
-configuration directory; otherwise the default value is "`.`".
-Typically there is a separate configuration directory per
-architecture, but this is not required. The configuration directory
-may be the same as the default-configuration directory.
-
-## Use in a kernel source package
-
-### Configuration files
-
-The kernel-versions file lists the kernel flavours to produce packages
-for. There are 6 whitespace separated fields per line, and it looks
-something like this:
-
- # arch version flavour installedname suffix build-depends
- i386 - 686 - - -
- i386 - 686-pae - - -
-
-The arch column must be set to the target Debian architecture and the
-flavour to the kernel flavour name that appears in the package and
-file names.
-
-The version, installedname and build-depends columns must all be set
-to "`-`" in this case.
-
-The suffix column is either `y`, `-` or `-`*suffix*; if it is `y` then
-the kernel image inside the udeb will include the version and flavour
-in its name, if it is `-`*suffix* then it will include this. (So will
-the System.map).
-
-The udebs are named with the version of the kernel in their package name,
-since that can be useful during kernel transitions. The string `-di` is
-appended to prevent any posible collisions in names with real debs.
-
-The package-list and (optional) exclude-packages configuration files
-are used by `gen-control`, as explained in its online help.
-
-Finally, you need a modules/*arch* directory, or directories. These are
-used to list the modules that go in a package. For example, for i386, we
-want to have some nic drivers, so we create a modules/i386/nic-modules
-listing them:
-
- # My short list of nic modules.
- 8139too
- e100
- natsemi
- ne2k-pci
- tulip
- winbond-840
- 3c59x
-
-But for Linux, drivers are organised into subdirectories by type, and
-we can instead include (most) Ethernet drivers using a wildcard:
-
- drivers/net/ethernet/**
-
-Suppose we want a different set of modules in the 686 flavour kernel.
-Then create a `modules/`*arch*-*flavour*`/nic-modules` instead, and it
-will be used by preference. One udeb will be created for each modules
-list file, containing the listed modules. The names of the files
-should match the names of the various modules listed in the
-package-list file in the default-configuration directory.
-
-You will also want a special modules list file for the kernel-image udeb.
-If you need to include no modules with your kernel, it can be an empty file.
-but you should have a modules/*arch*/kernel-image.
-
-`kernel-wedge` will copy the listed modules into each package. If a listed
-module does not exist, it will fail by default. Sometimes you might want to
-make a module be included but it's not fatal for it not to be available.
-To indicate this, follow the module with a space and a "`?`".
-
-Module list files can also include other module lists by reference. This
-works similar to cpp includes, and can be used to include module lists
-distributed as part of kernel-wedge, or others. For example:
-
- # kernel-wedge's standard set of cdrom modules
- #include <cdrom-core-modules>
- # my own list
- #include "../../includes/cdrom-modules"
-
-The `<name>` syntax includes a file from the modules subdirectory of the
-default-configuration directory.
-
-A final capability of the module list files is the ability to include a
-module list and then override parts of it. Follow a module name with " `-`" to
-remove it from the list if it was previously listed, as by an include:
-
- # kernel-wedge's standard set of cdrom modules
- #include <cdrom-core-modules>
- # but not this one
- sr_mod -
-
-### Debian directory
-
-To add the udeb packages to the control file, run for each
-architecture:
-
-`kernel-wedge gen-control `*version*` >> debian/control`
-
-Where *version* is the kernel ABI/version that appears in package
-names.
-
-In case you use the same kernel flavour name on multiple
-architectures, you will need to merge the output from multiple
-invocations of `kernel-wedge gen-control`.
-
-## Use in a separate source package
-
-### Configuration files
-
-The kernel-versions file looks something like this:
-
- # arch version flavour installedname suffix build-depends
- i386 2.4.25-1 386 2.4.25-1-386 - kernel-image-2.4.25-1-386, kernel-pcmcia-modules-2.4.25-1-386
- i386 2.4.24 speakup 2.4.24-speakup - kernel-image-2.4.24-speakup
-
-In this case we are building two different flavours of i386 kernels.
-We could just as easily be building kernels for different architectures.
-
-The arch, flavour and suffix columns are set as above.
-
-The version is the kernel version, or can be "`-`", in which case a
-version must be specified when running the `gen-control` and
-`install-files` commands.
-
-The installedname column gives the directory/filename that the kernel and
-modules are installed using in the kernel `.deb`. If it is "`-`", it's
-generated from the version and flavor.
-
-The build-depends are the package that is split up by kernel-wedge.
-
-The other configuration files are set in the same way as normal.
-
-### Debian directory
-
-Your source package will be very simple, looking something like this:
-
-debian/copyright<BR>
-debian/changelog<BR>
-debian/rules<BR>
-debian/control.stub
-
-Let's get the easy files out of the way. The changelog is a
-changelog, like any other, as is the copyright. The debian/rules
-can be something as simple as this:
-
- #!/usr/bin/make -f
- include /usr/share/kernel-wedge/generic-rules
-
-Or you can use the `kernel-wedge` command directly in your own rules file.
-Run it for some semblance of usage help.
-
-`debian/control.stub` is the top of a control file. Something like this:
-
- Source: linux-kernel-di-i386
- Section: debian-installer
- Priority: optional
- Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
- Build-Depends: kernel-wedge
-
-The rest of the control file will be generated for you.
-
-Once you have your source package set up, run:
-
- kernel-wedge gen-control > debian/control
-
-You only need to do this once. Then build it like any other package.
-Note that you will have to have the kernels listed as build dependencies
-installed normally; but see "`kernel-wedge help build-all`" for an
-alternative.
-
-## Misc other info
-
-The "`kernel-wedge copy-modules`" command does the actual copying of modules
-to the temp dirs that are used to build the package. It is complicated by
-the need to make sure that all of a module's dependencies are included in
-its package, or in a package on which it depends. If necessary, extra
-modules will be added to a package to make sure the dependencies are
-satisfied.
-
-The dependency information from modules.dep is compared with the output of
-the "`kernel-wedge gen-deps`" command, which extracts dependency information
-from package-lists, and formats it in a form used by tsort. If any
-additional modules are needed to meet dependencies of modules in the udebs,
-they will automatically be added. Since that might result in modules being
-copied to multiple udebs, the "`kernel-wedge find-dups`" command is used to
-scan for duplicates of modules. When you have duplicates, you need to find
-(or make) a package that both packages depend on, and move the duplicate
-modules to it. Alternatively, as a quick hack you can just touch a file
-named ignore-dups in the root of your package and duplicate modules will
-stop being a fatal error.
-
-`SOURCEDIR` can be set to a directory containing a tree of kernel modules and
-kernel image, and it will be used instead of the usual tree. That directory
-will need to have a modules.dep file already generated for this to work
-though -- but the modules.dep can even be copied from another system and
-it'll work. This can be useful if you cannot install the required
-kernel-image package, or are cross-compiling.
diff --git a/kernel-wedge-2.104ubuntu1/TODO b/kernel-wedge-2.96ubuntu3/TODO
index 5c8df11..2c98bc5 100644
--- a/kernel-wedge-2.104ubuntu1/TODO
+++ b/kernel-wedge-2.96ubuntu3/TODO
@@ -1,2 +1,4 @@
* Better docs for making a custom modules package, or using a different or
custom kernel.
+* Support Depends_subarch in package-lists, not currently supported in
+ gen-deps or gen-control.
diff --git a/kernel-wedge-2.96ubuntu3/commands/build-all.txt b/kernel-wedge-2.96ubuntu3/commands/build-all.txt
new file mode 100644
index 0000000..225ba1b
--- /dev/null
+++ b/kernel-wedge-2.96ubuntu3/commands/build-all.txt
@@ -0,0 +1,10 @@
+build-all
+
+This is a wrapper script that can be used to build all architectures.
+
+The script builds all architectures listed in kernel-versions.
+It expects to have the unpacked kernel packages for various arches in
+../alpha, etc. modules.dep files have to be put in there too if they are
+not shipped in the .deb (varies)
+
+dpkg-cross must be installed, but you do not need a cross compiler.
diff --git a/kernel-wedge-2.104ubuntu1/commands/build-arch b/kernel-wedge-2.96ubuntu3/commands/build-arch
index 5b910ab..4a9b21f 100755
--- a/kernel-wedge-2.104ubuntu1/commands/build-arch
+++ b/kernel-wedge-2.96ubuntu3/commands/build-arch
@@ -21,7 +21,9 @@ buildpackage -S
# Directory for stubs, added to PATH.
arch="$1"
trap 'rm -rf $tmpdir' EXIT
-tmpdir=$(mktemp -d)
+tmpdir=$(tempfile)
+rm $tmpdir
+mkdir $tmpdir
PATH=$PATH:$tmpdir
export PATH
diff --git a/kernel-wedge-2.96ubuntu3/commands/build-arch.txt b/kernel-wedge-2.96ubuntu3/commands/build-arch.txt
new file mode 100644
index 0000000..ee82b24
--- /dev/null
+++ b/kernel-wedge-2.96ubuntu3/commands/build-arch.txt
@@ -0,0 +1,11 @@
+build-arch
+
+This is a wrapper script to build a specific architecture.
+
+It takes the architecture to be built as parameter and that architecture
+needs to be listed in kernel-versions.
+It expects to have the unpacked kernel packages for the architecture in
+e.g. ../alpha. modules.dep files have to be put in there too if they are
+not shipped in the .deb (varies)
+
+dpkg-cross must be installed, but you do not need a cross compiler.
diff --git a/kernel-wedge-2.96ubuntu3/commands/check.txt b/kernel-wedge-2.96ubuntu3/commands/check.txt
new file mode 100644
index 0000000..df4722a
--- /dev/null
+++ b/kernel-wedge-2.96ubuntu3/commands/check.txt
@@ -0,0 +1,6 @@
+check
+
+Check for various problems in the packages.
+
+Return 1 if any problems are found, unless $KW_CHECK_NONFATAL is
+non-empty.
diff --git a/kernel-wedge-2.96ubuntu3/commands/copy-firmware b/kernel-wedge-2.96ubuntu3/commands/copy-firmware
new file mode 100755
index 0000000..d8a3f1e
--- /dev/null
+++ b/kernel-wedge-2.96ubuntu3/commands/copy-firmware
@@ -0,0 +1,118 @@
+#!/bin/sh
+#
+# Copy firmware into the right directories in preparation for building udebs.
+#
+# Copyright (c) 2001-2002 Herbert Xu <herbert@debian.org>
+# Copyright (c) 2004 Canonical Ltd. Adapted for firmware by Colin Watson.
+#
+# Usage: copy-firmware version flavour installedname
+
+set -e
+
+processfirmware() {
+ local list=$1
+ local fwdir=$2
+
+ local code=0
+ cp $list $tmpdir/work
+ (
+ code=0
+ while read firmware; do
+ # Question mark suffixed firmware files are optional.
+ # Support dash prefixing for backwards compatibility.
+ if [ "${firmware#-}" != "$firmware" ] || \
+ [ "${firmware% \?}" != "$firmware" ]; then
+ optional=1
+ firmware=${firmware% \?}
+ firmware=${firmware#-}
+ else
+ optional=0
+ fi
+
+ if [ -e $fwdir/$firmware ]; then
+ echo $firmware
+ else
+ if [ "$optional" = 0 ]; then
+ echo "missing firmware $firmware" >&2
+ if [ -z "$KW_CHECK_NONFATAL" ]; then
+ code=1
+ fi
+ fi
+ fi
+ done
+ exit $code
+ ) < $tmpdir/work > $list.new || code=$?
+ sort < $list.new > $list
+ rm -f $list.new
+ return $code
+}
+
+version=$1-$2
+flavour=$2
+installedname=$3
+configdir=$(readlink -f ${KW_CONFIG_DIR:-.})
+arch=$(dpkg-architecture -qDEB_HOST_ARCH)
+home=$PWD
+
+trap 'rm -rf $tmpdir' EXIT
+tmpdir=$(tempfile)
+rm $tmpdir
+mkdir $tmpdir
+
+# SOURCEDIR may be set externally to control where to copy from.
+if [ -n "$SOURCEDIR" ]; then
+ fwdir=$SOURCEDIR/lib/firmware/$installedname
+else
+ fwdir=/lib/firmware/$installedname
+fi
+
+if [ ! -d $fwdir ] || [ ! -d $configdir/firmware ]; then
+ exit 0
+fi
+
+# The directory of firmware lists to use.
+if [ -d $configdir/firmware/$arch-$flavour ]; then
+ fwlistdir=$configdir/firmware/$arch-$flavour
+elif [ -d $configdir/firmware/$flavour ]; then
+ fwlistdir=$configdir/firmware/$flavour
+else
+ fwlistdir=$configdir/firmware/$arch
+fi
+
+mkdir $tmpdir/firmware-list
+
+code=0
+# loop over all udebs
+for i in $(
+ find $fwlistdir/ -maxdepth 1 \( -type f -or -type l \) -not -name '*.lnk' -printf "%f\t%f\n"
+); do
+ # preprocess file, handle includes and excludes and sort so that
+ # the joins work, no matter what the order of the input.
+ kernel-wedge preprocess $fwlistdir/$i $fwdir | sort > $tmpdir/firmware-list/$i
+
+ # deal with firmware marked as optional and other transformations
+ processfirmware $tmpdir/firmware-list/$i $fwdir || code=$?
+
+ if [ -s $tmpdir/firmware-list/$i ] && dh_listpackages | grep -qx "$i-$version-di"; then
+ # copy firmware to package build dir
+ cd $fwdir
+ ret=$( ( (
+ set +e
+ tar cfT - $tmpdir/firmware-list/$i
+ printf $? >&3
+ ) | (
+ set +e
+ dir=$home/debian/$i-$version-di/lib/firmware/$installedname
+ mkdir -p $dir
+ cd $dir
+ tar xf -
+ printf $? >&3
+ ) ) 3>&1)
+ if [ "$ret" != "00" ]; then
+ echo "tar failed" >&2
+ exit $ret
+ fi
+ cd $home
+ fi
+done
+exit $code
diff --git a/kernel-wedge-2.96ubuntu3/commands/copy-firmware.txt b/kernel-wedge-2.96ubuntu3/commands/copy-firmware.txt
new file mode 100644
index 0000000..600e534
--- /dev/null
+++ b/kernel-wedge-2.96ubuntu3/commands/copy-firmware.txt
@@ -0,0 +1,6 @@
+copy-firmware version flavour installedname
+
+Copy firmware into the right directories in preparation for building udebs.
+
+Return 1 if a required module is missing, unless $KW_CHECK_NONFATAL is
+non-empty.
diff --git a/kernel-wedge-2.104ubuntu1/commands/copy-modules b/kernel-wedge-2.96ubuntu3/commands/copy-modules
index 30f9dc5..276267a 100755
--- a/kernel-wedge-2.104ubuntu1/commands/copy-modules
+++ b/kernel-wedge-2.96ubuntu3/commands/copy-modules
@@ -32,6 +32,59 @@ deplist() {
done
}
+processmodules() {
+ local list=$1
+ local moddir=$2
+
+ local code=0
+ cp $list $tmpdir/work
+ (
+ code=0
+ while read module; do
+ # Question mark suffixed modules are optional.
+ if [ "${module% \?}" != "$module" ]; then
+ optional=1
+ module=${module% \?}
+ else
+ optional=0
+ fi
+
+ module=${module##*/} # remove path info
+ module=${module%.*} # remove extension
+
+ # Skip Linux modules that are really built-in.
+ if [ "$os" = "linux" ] && \
+ [ -f $moddir/modules.builtin ] && \
+ grep -q "/$module\\.ko\$" $moddir/modules.builtin
+ then
+ continue
+ fi
+
+ # Prefer modules in the kernel subdir, but failing
+ # that search the whole thing, to find third-party,
+ # etc modules.
+ match="$(find `ls -d $moddir/kernel 2>/dev/null` $moddir/ \
+ -name $module.o -or -name $module.ko \
+ | head -n 1 | sed "s!$moddir/!!")"
+
+ if [ -n "$match" ]; then
+ echo $match
+ else
+ if [ "$optional" = 0 ]; then
+ echo "missing module $module" >&2
+ if [ -z "$KW_CHECK_NONFATAL" ]; then
+ code=1
+ fi
+ fi
+ fi
+ done
+ exit $code
+ ) < $tmpdir/work > $list.new || code=$?
+ sort < $list.new > $list
+ rm -f $list.new
+ return $code
+}
+
version=$1-$2
flavour=$2
installedname=$3
@@ -41,7 +94,9 @@ os=$(dpkg-architecture -qDEB_HOST_ARCH_OS)
home=$PWD
trap 'rm -rf $tmpdir' EXIT
-tmpdir=$(mktemp -d)
+tmpdir=$(tempfile)
+rm $tmpdir
+mkdir $tmpdir
# SOURCEDIR may be set externally to control where to copy from.
if [ -n "$SOURCEDIR" ]; then
@@ -50,7 +105,7 @@ else
moddir=/lib/modules/$installedname
fi
-if [ ! -d $moddir ]; then
+if [ ! -d $moddir ] || [ ! -d $configdir/modules ]; then
exit 0
fi
@@ -64,16 +119,13 @@ else
fi
if [ "$os" = "linux" ] ; then
- if [ "$SOURCEDIR" ]; then
+ if [ -e "$moddir/modules.dep" ]; then
+ modulesdep=$moddir/modules.dep
+ else
modulesdep=$tmpdir/modules.dep
PATH="/usr/sbin:/sbin:$PATH" depmod \
- -b $SOURCEDIR $installedname -n \
+ ${SOURCEDIR:+-b $SOURCEDIR} $installedname -n \
| sed '/^#/d; /^alias /,$d' >$modulesdep
- elif [ -e "$moddir/modules.dep" ]; then
- modulesdep=$moddir/modules.dep
- else
- echo "Installed kernel package is missing $moddir/modules.dep" >&2
- exit 1
fi
# get module dependencies from modules.dep
@@ -132,6 +184,9 @@ for i in $(
join -o 2.1,2.2 -2 2 -v 2 $tmpdir/exclude $tmpdir/deps |
sort -k 1,1 > $tmpdir/tmpdeps
+ # deal with modules marked as optional and other transformations
+ processmodules $tmpdir/module-list/$i $moddir || code=$?
+
# include dependent modules which are not in a
# dependent udeb into module-list/$i
deplist $tmpdir/tmpdeps $tmpdir/module-list/$i
@@ -156,13 +211,6 @@ for i in $(
exit $ret
fi
cd $home
-
- if [ "$os" = linux ]; then
- cat >"debian/$i-$version-di.postinst" <<EOF
-#!/bin/sh -e
-depmod $installedname
-EOF
- fi
fi
done
exit $code
diff --git a/kernel-wedge-2.96ubuntu3/commands/copy-modules.txt b/kernel-wedge-2.96ubuntu3/commands/copy-modules.txt
new file mode 100644
index 0000000..f719caf
--- /dev/null
+++ b/kernel-wedge-2.96ubuntu3/commands/copy-modules.txt
@@ -0,0 +1,6 @@
+copy-modules version flavour installedname
+
+Copy modules into the right directories in preparation for building udebs.
+
+Return 1 if a required module is missing, unless $KW_CHECK_NONFATAL is
+non-empty.
diff --git a/kernel-wedge-2.104ubuntu1/commands/find-dups b/kernel-wedge-2.96ubuntu3/commands/find-dups
index 7c4d45a..ea34572 100755
--- a/kernel-wedge-2.104ubuntu1/commands/find-dups
+++ b/kernel-wedge-2.96ubuntu3/commands/find-dups
@@ -3,7 +3,7 @@
kernel=$1
(
shopt -s nullglob
- for dir in debian/*-modules-$kernel-di; do
+ for dir in $(find debian -maxdepth 1 -type d \( -name \*-modules-$kernel-di -or -name \*-firmware-$kernel-di \)); do
cd $dir
find lib -type f -printf "$dir %p\n"
cd ../..
diff --git a/kernel-wedge-2.96ubuntu3/commands/find-dups.txt b/kernel-wedge-2.96ubuntu3/commands/find-dups.txt
new file mode 100644
index 0000000..6ff3462
--- /dev/null
+++ b/kernel-wedge-2.96ubuntu3/commands/find-dups.txt
@@ -0,0 +1,6 @@
+find-dups kernel-name
+
+Find duplicate modules. Pass the kernel name.
+
+Return 1 if any duplicates are found, unless $KW_CHECK_NONFATAL is
+non-empty or the configuration file 'ignore-dups' exists.
diff --git a/kernel-wedge-2.96ubuntu3/commands/find-unpackaged.txt b/kernel-wedge-2.96ubuntu3/commands/find-unpackaged.txt
new file mode 100644
index 0000000..5aae086
--- /dev/null
+++ b/kernel-wedge-2.96ubuntu3/commands/find-unpackaged.txt
@@ -0,0 +1,5 @@
+find-unpackaged kernel-name
+
+List modules that are not packaged in a udeb. Pass the kernel name.
+
+Always return 0.
diff --git a/kernel-wedge-2.104ubuntu1/commands/gen-control b/kernel-wedge-2.96ubuntu3/commands/gen-control
index 67922d8..417930e 100755
--- a/kernel-wedge-2.104ubuntu1/commands/gen-control
+++ b/kernel-wedge-2.96ubuntu3/commands/gen-control
@@ -4,15 +4,22 @@
use strict;
use warnings;
-use KernelWedge qw(CONFIG_DIR CONTROL_FIELDS read_kernel_versions
- read_package_lists for_each_package);
-
+my @controlfields=qw(Package Package-Type Provides Depends Architecture Kernel-Version Section Priority Description);
+my @versions;
+my @packages;
+my %packages;
my @builddeps;
my %excluded;
+my $defconfigdir = $ENV{KW_DEFCONFIG_DIR};
+if (!defined($defconfigdir)) {
+ die "Required environment variable \$KW_DEFCONFIG_DIR is not defined";
+}
+my $configdir = ($ENV{KW_CONFIG_DIR} || '.');
+
my $fixkernelversion = $ARGV[0];
-if (open(EXCLUDED, CONFIG_DIR . "/exclude-packages")) {
+if (open(EXCLUDED, "$configdir/exclude-packages")) {
while (<EXCLUDED>) {
chomp;
$excluded{$_}=1;
@@ -20,23 +27,29 @@ if (open(EXCLUDED, CONFIG_DIR . "/exclude-packages")) {
close EXCLUDED;
}
-my $versions = read_kernel_versions($fixkernelversion);
-
-for my $ver (@$versions) {
- (my $arch, my $kernelversion, undef, undef, undef, my $builddep) =
- @$ver;
+open(KVERS, "$configdir/kernel-versions") || die "kernel-versions: $!";
+while (<KVERS>) {
+ chomp;
+ next if /^#/ || ! length;
+
+ my ($arch, $kernelversion, $flavour, $installedname, $multkern, $builddep)=split(' ', $_, 6);
+ if (! length $arch || ! length $kernelversion || ! length $flavour) {
+ die "parse error";
+ }
if (defined($fixkernelversion)) {
- $ver->[1] = $fixkernelversion;
+ $kernelversion = $fixkernelversion;
}
elsif ($kernelversion eq "-") {
die "kernel version not set in file or on command line";
}
+ push @versions, [ $arch, $kernelversion, $flavour ];
if ($builddep ne "-") {
foreach my $pkg (split(", ", $builddep)) {
push @builddeps, "$pkg [$arch]";
}
}
}
+close KVERS;
# Building with installed kernel package, or as part of a package?
if (@builddeps) {
@@ -51,48 +64,143 @@ if (@builddeps) {
close STUB;
}
-my $packages = read_package_lists();
+sub read_package_list
+{
+ sub merge_package
+ {
+ my %pkg = %{$_[0]};
+ if (not exists $packages{$pkg{Package}}) {
+ push @packages, $pkg{Package};
+ $packages{$pkg{Package}} = \%pkg;
+ }
+ else {
+ my %real_pkg = %{$packages{$pkg{Package}}};
+ foreach (keys(%pkg)) {
+ $real_pkg{$_} = $pkg{$_};
+ }
+ $packages{$pkg{Package}} = \%real_pkg;
+ }
+ }
+
+ my $file = shift;
+ open(LIST, $file) || die "package-list: $!";
+ my $field;
+ my %pkg;
+ while (<LIST>) {
+ chomp;
+ next if /^#/;
+
+ if (/^(\S+):\s*(.*)/) {
+ $field=$1;
+ my $val=$2;
+ if (! grep { $field =~ /^\Q$_\E(_.+)?$/ } @controlfields) {
+ die "unknown field, $field";
+ }
+ $pkg{$field}=$val;
+ }
+ elsif (/^$/) {
+ if (%pkg) {
+ merge_package(\%pkg);
+ %pkg=();
+ }
+ }
+ elsif (/^(\s+.*)/) {
+ # continued field
+ $pkg{$field}.="\n".$1;
+ }
+ }
+ if (%pkg) {
+ merge_package(\%pkg);
+ }
+ close LIST;
+}
+read_package_list("$defconfigdir/package-list");
+read_package_list("$configdir/package-list");
+
+foreach my $ver (@versions) {
+ my ($arch, $kernelversion, $flavour) = @$ver;
+ foreach my $pkg_name (@packages) {
+ my %pkg = %{$packages{$pkg_name}};
+
+ # Used to get a field of the package, looking first for
+ # architecture-specific fields.
+ my $package = sub {
+ my $field=shift;
+ return $pkg{$field."_".$flavour}
+ if exists $pkg{$field."_".$flavour};
+ return $pkg{$field."_".$arch."_".$flavour}
+ if exists $pkg{$field."_".$arch."_".$flavour};
+ return $pkg{$field."_".$arch}
+ if exists $pkg{$field."_".$arch};
+ return $pkg{$field}
+ if exists $pkg{$field};
+ return undef;
+ };
+
+ # Check for a modules list file for this architecture and
+ # package.
+ my $modlistdir="";
+ if (-d "$configdir/modules/$arch-$flavour") {
+ $modlistdir = "$configdir/modules/$arch-$flavour";
+ }
+ elsif (-d "$configdir/modules/$flavour") {
+ $modlistdir = "$configdir/modules/$flavour";
+ }
+ else {
+ $modlistdir = "$configdir/modules/$arch";
+ }
+
+ my $fwlistdir="";
+ if (-d "$configdir/firmware/$arch-$flavour") {
+ $fwlistdir="$configdir/firmware/$arch-$flavour";
+ }
+ elsif (-d "$configdir/firmware/$flavour") {
+ $fwlistdir="$configdir/firmware/$flavour";
+ }
+ else {
+ $fwlistdir="$configdir/firmware/$arch";
+ }
-for_each_package($packages, $versions, sub {
- my ($arch, $kernelversion, $flavour, $modlistdir, $template) = @_;
+ next unless -e "$modlistdir/".$package->("Package") or -e "$fwlistdir/".$package->("Package");
- my %override;
- $override{Architecture}=$arch;
- $override{Package}=$template->("Package")."-".$kernelversion."-".$flavour."-di";
- $override{'Package-Type'}="udeb";
- $override{'Kernel-Version'}=$kernelversion."-".$flavour;
+ $pkg{Architecture}=$arch;
+ $pkg{orig_package}=$package->("Package");
+ $pkg{Package}=$package->("Package")."-".$kernelversion."-".$flavour."-di";
+ $pkg{'Package-Type'}="udeb";
+ $pkg{'Kernel-Version'}=$kernelversion."-".$flavour;
- return if $excluded{$override{Package}};
+ next if $excluded{$pkg{Package}};