~nicktux/utappia/optimus-kernel

« back to all changes in this revision

Viewing changes to debian/scripts/module-inclusion

  • Committer: NickTh
  • Date: 2015-10-15 08:11:04 UTC
  • Revision ID: nick-athens30@ubuntu.com-20151015081104-cr4qwkh27u0mw0e2
Creating Initial Project

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
master=0
 
12
if [ "$1" = "--master" ]; then
 
13
        master=1
 
14
        shift
 
15
fi
 
16
 
 
17
ROOT=$1
 
18
NROOT=$2
 
19
ILIST=$3
 
20
 
 
21
#
 
22
# Prep a destination directory.
 
23
#
 
24
mkdir -p ${NROOT}
 
25
 
 
26
{
 
27
        # Copy over the framework into the master package.
 
28
        if  [ "$master" -eq 1 ]; then
 
29
                (cd ${ROOT}; find . ! -name "*.ko" -type f)
 
30
        fi
 
31
 
 
32
        # Copy over modules by name or pattern.
 
33
        while read -r i
 
34
        do
 
35
                #
 
36
                # 'find' blurts a warning if it cannot find any ko files.
 
37
                #
 
38
                case "$i" in
 
39
                \!*)
 
40
                        (cd ${ROOT}; ${i#!} || true)
 
41
                        ;;
 
42
                *\**)
 
43
                        (cd ${ROOT}; eval find "${i}" -name "*.ko" || true)
 
44
                        ;;
 
45
                *)
 
46
                        echo "$i"
 
47
                        ;;
 
48
                esac
 
49
        done <"${ILIST}"
 
50
# Copy over the listed modules.
 
51
} | \
 
52
while read i
 
53
do
 
54
        # If this is already moved over, all is good.
 
55
        if [ -f "${NROOT}/$i" ]; then
 
56
                :
 
57
 
 
58
        # If present in the source, moved it over.
 
59
        elif [ -f "${ROOT}/$i" ]; then
 
60
                mkdir -p "${NROOT}/`dirname $i`"
 
61
                mv "${ROOT}/$i" "${NROOT}/$i"
 
62
 
 
63
        # Otherwise, it is missing.
 
64
        else
 
65
                echo "Warning: Could not find ${ROOT}/$i" 1>&2
 
66
        fi
 
67
done
 
68
 
 
69
exit 0