forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-opensuse-leap15.sh
executable file
·120 lines (78 loc) · 2.79 KB
/
patch-opensuse-leap15.sh
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
#!/bin/bash -e
SRC_VERSION_NAME=linux
## from
## http://stackoverflow.com/questions/9293887/in-bash-how-do-i-convert-a-space-delimited-string-into-an-array
FULL_NAME=linux-$( uname -r | sed -e 's/-default//')
read -a VERSION <<< $FULL_NAME
SRC_VERSION_ID=${VERSION[0]} ## e.g. : 4.5.6
SRC_VERSION_REL=${VERSION[1]} ## e.g. : 1
LINUX_TYPE=${VERSION[2]} ## e.g. : ARCH
#remove trailing.0
SRC_VERSION_ID=$(echo $SRC_VERSION_ID | sed -e 's/\.0$//' )
LINUX_BRANCH=opensuse-$SRC_VERSION_ID
KERNEL_NAME=linux-$SRC_VERSION_ID
PATCH_NAME=patch-$SRC_VERSION_ID
# ARCH Linux -- KERNEL_NAME=linux-$SRC_VERSION_ID-$SRC_VERSION_REL-$ARCH.pkg.tar.xz
mkdir kernel
cd kernel
sudo zypper in kernel-source kernel-default-devel
mkdir $FULL_NAME
cp -r /usr/src/$FULL_NAME-obj/x86_64/default/* ./$FULL_NAME/
cp -r /usr/src/$FULL_NAME/* ./$FULL_NAME/
cd $FULL_NAME
## Get the patch
# echo "Patching the kernel..."
### patch not working ?
# xz -dc ../$PATCH_NAME.xz | patch -p1
echo "RealSense patch..."
# Apply our RealSense specific patch
patch -p1 < ../../realsense-camera-formats-opensuse.patch
# Prepare to compile modules
## Get the config
# zcat /proc/config.gz > .config ## Not the good one ?
cp /lib/modules/`uname -r`/build/.config .
cp /lib/modules/`uname -r`/build/Module.symvers .
echo "Prepare the build"
#cat Makefile | sed -e 's/\.\.\/\.\.\/\.\.\/linux-4.12.14-lp150.12.16/\.\.\/linux-4.12.14-lp150.12.16/' > Makefile.temp; mv Makefile.temp Makefile;
make -C . scripts oldconfig modules_prepare
# Compile UVC modules
echo "Beginning compilation of uvc..."
#make modules
KBASE=`pwd`
cd drivers/media/usb/uvc
cp $KBASE/Module.symvers .
make -C $KBASE M=$KBASE/drivers/media/usb/uvc/ modules
# Copy to sane location
#sudo cp $KBASE/drivers/media/usb/uvc/uvcvideo.ko ~/$LINUX_BRANCH-uvcvideo.ko
cd ../../../../../
cp $KBASE/drivers/media/usb/uvc/uvcvideo.ko ../uvcvideo.ko
# Unload existing module if installed
echo "Unloading existing uvcvideo driver..."
sudo modprobe -r uvcvideo
cd ..
## Not sure yet about deleting and copying...
# save the existing module
MODULE_NAME=/lib/modules/`uname -r`/kernel/drivers/media/usb/uvc/uvcvideo.ko
if [ -e $MODULE_NAME ]; then
sudo cp $MODULE_NAME $MODULE_NAME.backup
sudo rm $MODULE_NAME
sudo cp uvcvideo.ko $MODULE_NAME
fi
if [ -e $MODULE_NAME.xz ]; then
sudo cp $MODULE_NAME.xz $MODULE_NAME.xz.backup
sudo rm $MODULE_NAME.xz
# compress
xz uvcvideo.ko
sudo cp uvcvideo.ko.xz $MODULE_NAME
fi
if [ -e $MODULE_NAME.gz ]; then
sudo cp $MODULE_NAME.gz $MODULE_NAME.gz.backup
sudo rm $MODULE_NAME.gz
# compress
gzip uvcvideo.ko
sudo cp uvcvideo.ko.gz $MODULE_NAME.gz
fi
# Copy out to module directory
sudo modprobe uvcvideo
rm -rf kernel
echo "Script has completed. Please consult the installation guide for further instruction."