]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - debian/scripts/module-inclusion
x86/speculation/mds: Add mitigation control for MDS
[mirror_ubuntu-bionic-kernel.git] / debian / scripts / module-inclusion
CommitLineData
0d34a427
LO
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
12master=0
13if [ "$1" = "--master" ]; then
14 master=1
15 shift
16fi
17
18ROOT=$1
19NROOT=$2
20ILIST=$3
21DEPMAP=$4
22
23tmp="/tmp/module-inclusion.$$"
24
25#
26# Prep a destination directory.
27#
28mkdir -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.
57while read i
58do
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
72done <"$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.
78let n=0 || true
79while [ -s "$tmp" ]
80do
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"
100done
101
102rm -f "$tmp"
103
104exit 0