]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - debian/scripts/module-inclusion
UBUNTU: SAUCE: s390/mm: fix local TLB flushing vs. detach of an mm address space
[mirror_ubuntu-zesty-kernel.git] / debian / scripts / module-inclusion
1 #!/bin/bash
2
3 #
4 # Build a new directory of modules based on an inclusion list.
5 # The includsion list format must be a bash regular expression.
6 #
7 # usage: $0 ROOT INCLUSION_LIST
8 # example: $0 \
9 # debian/build/build-virtual-ALL debian/build/build-virtual \
10 # debian.master/control.d/virtual.inclusion-list \
11 # virtual.depmap
12 master=0
13 if [ "$1" = "--master" ]; then
14 master=1
15 shift
16 fi
17
18 ROOT=$1
19 NROOT=$2
20 ILIST=$3
21 DEPMAP=$4
22
23 tmp="/tmp/module-inclusion.$$"
24
25 #
26 # Prep a destination directory.
27 #
28 mkdir -p ${NROOT}
29
30 {
31 # Copy over the framework into the master package.
32 if [ "$master" -eq 1 ]; then
33 (cd ${ROOT}; find . ! -name "*.ko" -type f)
34 fi
35
36 # Copy over modules by name or pattern.
37 while read -r i
38 do
39 #
40 # 'find' blurts a warning if it cannot find any ko files.
41 #
42 case "$i" in
43 \!*)
44 (cd ${ROOT}; ${i#!} || true)
45 ;;
46 *\**)
47 (cd ${ROOT}; eval find "${i}" -name "*.ko" || true)
48 ;;
49 *)
50 echo "$i"
51 ;;
52 esac
53 done <"${ILIST}"
54 } >"$tmp"
55
56 # Copy over the listed modules.
57 while read i
58 do
59 # If this is already moved over, all is good.
60 if [ -f "${NROOT}/$i" ]; then
61 :
62
63 # If present in the source, moved it over.
64 elif [ -f "${ROOT}/$i" ]; then
65 mkdir -p "${NROOT}/`dirname $i`"
66 mv "${ROOT}/$i" "${NROOT}/$i"
67
68 # Otherwise, it is missing.
69 else
70 echo "Warning: Could not find ${ROOT}/$i" 1>&2
71 fi
72 done <"$tmp"
73
74 # Copy over any dependancies, note if those are missing
75 # we know they are in a pre-requisite package as they must
76 # have existed at depmap generation time, and can only have
77 # moved into a package.
78 let n=0 || true
79 while [ -s "$tmp" ]
80 do
81 let n="$n+1" || true
82 [ "$n" = "20" ] && break || true
83
84 echo "NOTE: pass $n: dependency scan" 1>&2
85
86 while read i
87 do
88 grep "^$i " "$DEPMAP" | \
89 while read m d
90 do
91 if [ -f "${ROOT}/$d" ]; then
92 echo "NOTE: pass $n: ${i} pulls in ${d}" 1>&2
93 echo "$d"
94 mkdir -p "${NROOT}/`dirname $d`"
95 mv "${ROOT}/$d" "${NROOT}/$d"
96 fi
97 done
98 done <"$tmp" >"$tmp.new"
99 mv -f "$tmp.new" "$tmp"
100 done
101
102 rm -f "$tmp"
103
104 exit 0