Debian Codegraph @

build_tools/dkms-helper

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 set -e
4
5 DKMS=$(whichscip-shell system . . which. dkms)
6
7 usagescip-shell shell shell-project 0.0.0 usage().() {
8 echoscip-shell system . . echo. "$(basenamescip-shell system . . basename. $0): Helper functions for DKMS (Dynamic Kernel Module Support)"
9 echoscip-shell system . . echo. "Usage: $0 [add|remove|generate_conf]"
10 echoscip-shell system . . echo. "Options:"
11 echoscip-shell system . . echo. " remove -a : Remove all versions of DAHDI for all kernels."
12 echoscip-shell system . . echo. ""
13 echoscip-shell system . . echo. "Examples:"
14 echoscip-shell system . . echo. ""
15 echoscip-shell system . . echo. " build_tools/dkms-helper add"
16 echoscip-shell system . . echo. " Installs the current version of DAHDI into the DKMS system."
17 echoscip-shell system . . echo. ""
18 echoscip-shell system . . echo. " build_tools/dkms-helper remove"
19 echoscip-shell system . . echo. " Removes the current version of DAHDI from all kernels."
20 echoscip-shell system . . echo. ""
21 echoscip-shell system . . echo. " build_tools/dkms-helper generate_conf > dkms.conf"
22 echoscip-shell system . . echo. " Create a dkms.conf based on the currently compiled kernel"
23 echoscip-shell system . . echo. " modules. This is also done as part of add and is not"
24 echoscip-shell system . . echo. " normally needed as a separate step."
25 echoscip-shell system . . echo. ""
26 echoscip-shell system . . echo. "NOTE: Because firmware files could be different between different"
27 echoscip-shell system . . echo. "versions of DAHDI, and the firmware files are installed into the common"
28 echoscip-shell system . . echo. "/lib/firmware directory, you should remove a given version of DAHDI from allscip-shell filesystem . . `/lib/firmware directory, you should remove a given version of DAHDI from all`."
29 echoscip-shell system . . echo. "kernels before installing a new version of DAHDI to avoid potential"
30 echoscip-shell system . . echo. "conflicts."
31 echoscip-shell system . . echo. ""
32 }
33
34 generate_configurationscip-shell shell shell-project 0.0.0 generate_configuration().() {
35 echoscip-shell system . . echo. 'PACKAGE_NAME="dahdi-linux"'
36 echoscip-shell system . . echo. "PACKAGE_VERSION=\"$(build_tools/make_version .)\""
37 echoscip-shell system . . echo. 'MAKE="make KSRC=/lib/modules/${kernelver}/build"'
38 echoscip-shell system . . echo. 'CLEAN="make clean"'
39 echoscip-shell system . . echo. 'AUTOINSTALL="yes"'
40 let "module_number=0" || truescip-shell system . . true.
41 for file in $(findscip-shell system . . find. ./ -type f -name "*.ko"); do
42 MODULE_LOCATION=$(dirnamescip-shell system . . dirname. $file | cutscip-shell system . . cut. -d\/ -f 2-)
43 echoscip-shell system . . echo. "BUILT_MODULE_NAME[$module_number]=\"$(basenamescip-shell system . . basename. $file .ko)\""
44 echoscip-shell system . . echo. "BUILT_MODULE_LOCATION[$module_number]=\"$MODULE_LOCATION\""
45 echoscip-shell system . . echo. "DEST_MODULE_LOCATION[$module_number]=\"/kernel/dahdi/$(echoscip-shell system . . echo. $MODULE_LOCATION | cutscip-shell system . . cut. -d\/ -f 3-)\""
46 let "module_number=${module_number}+1" || truescip-shell system . . true.
47 done
48 if [scip-shell system . . `[`. $module_number -eq 0 ]; then
49 echoscip-shell system . . echo. "WARNING: You should build the modules before generating a config." >&2
50 exit 1
51 fi
52 }
53
54 addscip-shell shell shell-project 0.0.0 add().() {
55 GIT=$(whichscip-shell system . . which. git)
56 VERSION="$(build_tools/make_version .)"
57 if [scip-shell system . . `[`. $(idscip-shell system . . id. -u) != "0" ]; then
58 echoscip-shell system . . echo. "You must run $0 as root."
59 exit 1
60 fi
61 echoscip-shell system . . echo. "Building for version ${VERSION}"
62 makescip-shell system . . make. > /dev/nullscip-shell filesystem . . `/dev/null`.
63 echoscip-shell system . . echo. "Copying to /usr/src/dahdi-linux-${VERSION}"
64 if [scip-shell system . . `[`. ! -d /usr/src/dahdi-linux-${VERSION} ]; then
65 if [scip-shell system . . `[`. -d .git ]; then
66 ${GIT} checkout-index -a --prefix=/usr/src/dahdi-linux-${VERSION}/
67 else
68 cpscip-shell system . . cp. -f -r * /usr/src/dahdi-linux-${VERSION}/
69 fi
70 fi
71 build_tools/dkms-helper generate_conf > /usr/src/dahdi-linux-${VERSION}/dkms.conf
72 echoscip-shell system . . echo. $VERSION > /usr/src/dahdi-linux-${VERSION}/.version
73 ${DKMS} add -m dahdi-linux -v ${VERSION}
74 ${DKMS} build -m dahdi-linux -v ${VERSION}
75 ${DKMS} install --force -m dahdi-linux -v ${VERSION}
76 }
77
78 removescip-shell shell shell-project 0.0.0 remove().() {
79 if [scip-shell system . . `[`. $(idscip-shell system . . id. -u) != "0" ]; then
80 echoscip-shell system . . echo. "You must run $0 as root."
81 exit 1
82 fi
83 REMOVE_ALL=false
84 shift
85 while getopts "a" opt; do
86 case $opt in
87 a) REMOVE_ALL=true ;;
88 *) echoscip-shell system . . echo. "Unknown option to remove" ; exit 1;;
89 esac
90 done
91 if [scip-shell system . . `[`. $REMOVE_ALL == true ]; then
92 # Remove all installed dahdi versions for all kernels.
93 for version in $(${DKMS} status -m dahdi-linux | cutscip-shell system . . cut. -d, -f 2 | sedscip-shell system . . sed. -e "s/^\s\+//"); do
94 echoscip-shell system . . echo. "Removing version ${version}"
95 ${DKMS} remove -m dahdi-linux -v ${version} --all
96 rmscip-shell system . . rm. -f -r /usr/src/dahdi-linux-${version}
97 done
98 else
99 # Just remove the version for the current tree.
100 GIT=$(whichscip-shell system . . which. git)
101 VERSION="$(build_tools/make_version .)"
102 ${DKMS} remove -m dahdi-linux -v ${VERSION} --all
103 if [scip-shell system . . `[`. -e /usr/src/dahdi-linux-${VERSION}/dkms.conf ]; then
104 rmscip-shell system . . rm. -f -r /usr/src/dahdi-linux-${VERSION}
105 else
106 echoscip-shell system . . echo. "/usr/src/dahdi-linux-${VERSION} not a dkms dir?"
107 exit 1
108 fi
109 fi
110 }
111
112 # Run the command...
113 shift $(($OPTIND-1))
114 COMMAND=$1
115 case $COMMAND in
116 add) addscip-shell shell shell-project 0.0.0 add(). $*; exit $? ;;
117 remove) removescip-shell shell shell-project 0.0.0 remove(). $* ; exit $? ;;
118 generate_conf) generate_configurationscip-shell shell shell-project 0.0.0 generate_configuration().; exit $? ;;
119 *) echoscip-shell system . . echo. "unknown command $0" ; usagescip-shell shell shell-project 0.0.0 usage().; exit 1;;
120 esac
121
122 exit 0