• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3set -e
4
5MODULE_PLAYGROUND=$1
6ROOTFS=$2
7
8declare -A map
9map=(
10    ["test-depmod/search-order-simple/lib/modules/4.4.4/kernel/crypto/"]="mod-simple.ko"
11    ["test-depmod/search-order-simple/lib/modules/4.4.4/updates/"]="mod-simple.ko"
12    ["test-depmod/search-order-same-prefix/lib/modules/4.4.4/foo/"]="mod-simple.ko"
13    ["test-depmod/search-order-same-prefix/lib/modules/4.4.4/foobar/"]="mod-simple.ko"
14    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-a.ko"]="mod-loop-a.ko"
15    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-b.ko"]="mod-loop-b.ko"
16    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-c.ko"]="mod-loop-c.ko"
17    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-d.ko"]="mod-loop-d.ko"
18    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-e.ko"]="mod-loop-e.ko"
19    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-f.ko"]="mod-loop-f.ko"
20    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-g.ko"]="mod-loop-g.ko"
21    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-h.ko"]="mod-loop-h.ko"
22    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-i.ko"]="mod-loop-i.ko"
23    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-j.ko"]="mod-loop-j.ko"
24    ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-k.ko"]="mod-loop-k.ko"
25    ["test-depmod/search-order-external-first/lib/modules/4.4.4/foo/"]="mod-simple.ko"
26    ["test-depmod/search-order-external-first/lib/modules/4.4.4/foobar/"]="mod-simple.ko"
27    ["test-depmod/search-order-external-first/lib/modules/external/"]="mod-simple.ko"
28    ["test-depmod/search-order-external-last/lib/modules/4.4.4/foo/"]="mod-simple.ko"
29    ["test-depmod/search-order-external-last/lib/modules/4.4.4/foobar/"]="mod-simple.ko"
30    ["test-depmod/search-order-external-last/lib/modules/external/"]="mod-simple.ko"
31    ["test-depmod/search-order-override/lib/modules/4.4.4/foo/"]="mod-simple.ko"
32    ["test-depmod/search-order-override/lib/modules/4.4.4/override/"]="mod-simple.ko"
33    ["test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/foo/"]="mod-foo-b.ko"
34    ["test-dependencies/lib/modules/4.0.20-kmod/kernel/"]="mod-foo-c.ko"
35    ["test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/"]="mod-foo-a.ko"
36    ["test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/"]="mod-foo.ko"
37    ["test-init/"]="mod-simple.ko"
38    ["test-remove/"]="mod-simple.ko"
39    ["test-modprobe/show-depends/lib/modules/4.4.4/kernel/mod-loop-a.ko"]="mod-loop-a.ko"
40    ["test-modprobe/show-depends/lib/modules/4.4.4/kernel/mod-loop-b.ko"]="mod-loop-b.ko"
41    ["test-modprobe/show-depends/lib/modules/4.4.4/kernel/mod-simple.ko"]="mod-simple.ko"
42    ["test-modprobe/show-exports/mod-loop-a.ko"]="mod-loop-a.ko"
43    ["test-modprobe/softdep-loop/lib/modules/4.4.4/kernel/mod-loop-a.ko"]="mod-loop-a.ko"
44    ["test-modprobe/softdep-loop/lib/modules/4.4.4/kernel/mod-loop-b.ko"]="mod-loop-b.ko"
45    ["test-modprobe/install-cmd-loop/lib/modules/4.4.4/kernel/mod-loop-a.ko"]="mod-loop-a.ko"
46    ["test-modprobe/install-cmd-loop/lib/modules/4.4.4/kernel/mod-loop-b.ko"]="mod-loop-b.ko"
47    ["test-modprobe/force/lib/modules/4.4.4/kernel/"]="mod-simple.ko"
48    ["test-modprobe/oldkernel/lib/modules/3.3.3/kernel/"]="mod-simple.ko"
49    ["test-modprobe/oldkernel-force/lib/modules/3.3.3/kernel/"]="mod-simple.ko"
50    ["test-modprobe/alias-to-none/lib/modules/4.4.4/kernel/"]="mod-simple.ko"
51    ["test-modprobe/module-param-kcmdline/lib/modules/4.4.4/kernel/"]="mod-simple.ko"
52    ["test-modprobe/external/lib/modules/external/"]="mod-simple.ko"
53    ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/block/cciss.ko"]="mod-fake-cciss.ko"
54    ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/hpsa.ko"]="mod-fake-hpsa.ko"
55    ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/scsi_mod.ko"]="mod-fake-scsi-mod.ko"
56    ["test-modinfo/mod-simple-i386.ko"]="mod-simple-i386.ko"
57    ["test-modinfo/mod-simple-x86_64.ko"]="mod-simple-x86_64.ko"
58    ["test-modinfo/mod-simple-sparc64.ko"]="mod-simple-sparc64.ko"
59    ["test-modinfo/mod-simple-sha1.ko"]="mod-simple.ko"
60    ["test-modinfo/mod-simple-sha256.ko"]="mod-simple.ko"
61    ["test-modinfo/mod-simple-pkcs7.ko"]="mod-simple.ko"
62    ["test-modinfo/external/lib/modules/external/mod-simple.ko"]="mod-simple.ko"
63    ["test-tools/insert/lib/modules/4.4.4/kernel/"]="mod-simple.ko"
64    ["test-tools/remove/lib/modules/4.4.4/kernel/"]="mod-simple.ko"
65)
66
67gzip_array=(
68    "test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/block/cciss.ko"
69    "test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/scsi_mod.ko"
70    )
71
72zstd_array=(
73    "test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/hpsa.ko"
74    )
75
76attach_sha256_array=(
77    "test-modinfo/mod-simple-sha256.ko"
78    )
79
80attach_sha1_array=(
81    "test-modinfo/mod-simple-sha1.ko"
82    )
83
84attach_pkcs7_array=(
85    "test-modinfo/mod-simple-pkcs7.ko"
86    )
87
88for k in ${!map[@]}; do
89    dst=${ROOTFS}/$k
90    src=${MODULE_PLAYGROUND}/${map[$k]}
91
92    if test "${dst: -1}" = "/"; then
93        install -d $dst
94        install -t $dst $src
95    else
96        install -D $src $dst
97    fi
98done
99
100# start poking the final rootfs...
101
102# gzip these modules
103for m in "${gzip_array[@]}"; do
104    gzip $ROOTFS/$m
105done
106
107# zstd-compress these modules
108for m in "${zstd_array[@]}"; do
109    zstd --rm $ROOTFS/$m
110done
111
112for m in "${attach_sha1_array[@]}"; do
113    cat ${MODULE_PLAYGROUND}/dummy.sha1 >> ${ROOTFS}/$m
114done
115
116for m in "${attach_sha256_array[@]}"; do
117    cat ${MODULE_PLAYGROUND}/dummy.sha256 >> ${ROOTFS}/$m
118done
119
120for m in "${attach_pkcs7_array[@]}"; do
121    cat ${MODULE_PLAYGROUND}/dummy.pkcs7 >> ${ROOTFS}/$m
122done
123