-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall
More file actions
executable file
·124 lines (104 loc) · 2.72 KB
/
install
File metadata and controls
executable file
·124 lines (104 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
usage() {
echo "Usage: $0 [-c] [-l logfile] [-s] [kerneldir]"
echo "-c : copy (don't symlink) the source into the kernel tree."
echo "-l logfile : create install log (the default is install.log)."
echo "-s : install into kernel staging directory"
echo "[kerneldir] - the kernel tree to install to (default is /usr/src/linux)"
exit 1
}
log() {
echo $* | tee -a $LOGFILE
}
die() {
log $*
exit 1
}
apply() {
log "Applying $1 to $2"
patch -p 1 -l -N -i "$1" -b -z .orig -d "$2" | tee -a $LOGFILE
if [ $? -gt 0 ];then
die "Unable to apply $1 to $2"
fi
}
check_kdir() {
if [ ! -d "$1" ]; then
die "$1 is not a directory"
fi
if [ ! -e "$1"/MAINTAINERS ]; then
die "$1 is not a kernel directory"
fi
}
get_kv() {
VERSION=`grep "^VERSION[ ]*=" "$1"/Makefile | awk '{print $3}'`
PATCHLEVEL=`grep "^PATCHLEVEL[ ]*=" "$1"/Makefile | awk '{print $3}'`
SUBLEVEL=`grep "^SUBLEVEL[ ]*=" "$1"/Makefile | awk '{print $3}'`
}
set -o pipefail
while getopts ":cl:s" opt; do
case $opt in
c) COPY_INSTALL=1
;;
l) LOGFILE=$OPTARG
;;
s) STAGING_INSTALL=1
COPY_INSTALL=1
;;
*) usage
;;
esac
done
shift $(($OPTIND - 1))
KDIR=${1:-/usr/src/linux}
SPKDIR="$(readlink -f "$(dirname "$0")")"
if [ -z "$LOGFILE" ]; then
LOGFILE=install.log
fi
check_kdir "${KDIR}"
get_kv "${KDIR}"
if [ $VERSION -lt 2 -o \( $VERSION -eq 2 -a $PATCHLEVEL -lt 6 \) -o \( $VERSION -eq 2 -a $PATCHLEVEL -eq 6 -a $SUBLEVEL -lt 26 \) ]; then
die "Speakup does not support kernels before 2.6.26."
fi
if [ -z "$STAGING_INSTALL" ]; then
BLDPATCH="$SPKDIR/patches/build-integration.patch"
DOCDIR="${KDIR}/Documentation/speakup"
SRCDIR="${KDIR}/drivers/accessibility/speakup"
else
BLDPATCH="$SPKDIR/patches/staging-integration.patch"
DOCDIR="${KDIR}/drivers/staging/speakup"
SRCDIR="${KDIR}/drivers/staging/speakup"
fi
if [ -e "${SRCDIR}" ]; then
log It appears that speakup is already installed into this kernel.
die Please start with a fresh kernel tree.
fi
if [ -n "$STAGING_INSTALL" -a ! -d ${KDIR}/.git ]; then
die staging installs should be done with the kernel git tree.
fi
if [ -n "${BLDPATCH}" ]; then
apply "${BLDPATCH}" "${KDIR}"
fi
log Installing user documentation.
if [ -z "${COPY_INSTALL}" ]; then
ln -s "${SPKDIR}/doc" "${DOCDIR}"
else
if [ ! -d "${DOCDIR}" ]; then
mkdir "${DOCDIR}"
fi
cp -a "${SPKDIR}"/doc/* "${DOCDIR}"
fi
log Installing speakup source.
if [ -z "$COPY_INSTALL" ]; then
ln -s "${SPKDIR}/src" "${SRCDIR}"
else
if [ ! -d "${SRCDIR}" ]; then
mkdir "${SRCDIR}"
fi
cp -a "${SPKDIR}"/src/* "${SRCDIR}"
fi
if [ -n "${STAGING_INSTALL}" ]; then
mv "${SRCDIR}/Kbuild" "${SRCDIR}/Makefile"
rm "${SRCDIR}/allmodule.mk"
cp "${SPKDIR}"/TODO.staging ${DOCDIR}/TODO
fi
log Speakup has been installed to ${KDIR}