-
Notifications
You must be signed in to change notification settings - Fork 3
/
package-linlib.bash
executable file
·100 lines (81 loc) · 2.81 KB
/
package-linlib.bash
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
#!/bin/bash
set -e
SCRIPT_DIR="$(dirname "$(realpath -s "$0")")"
OS_VER=$(lsb_release -cs)
SDK_COMMIT="$1"
VER_SUFFIX="$2"
UPLOAD="$3"
if [ -z "$SDK_COMMIT" ]; then
SDK_COMMIT=master
fi
echo ""
echo "Remember to modify the changelog in linlib/debian-linlib to include the current release notes."
echo "If you need to modify it now, hit [CTRL+C]. Otherwise hit [ENTER] to continue."
read STUFF
cd "$SCRIPT_DIR"
# Check for required files/folders
if [ ! -e "linlib/debian-linlib" ]; then
echo ""
echo "debian-linlib directory not found in linlib folder. Exiting..." 1>&2
exit -1
fi
if [ ! -e "linlib/Makefile-linlib" ]; then
echo ""
echo "Makefile-linlib not found in linlib folder. Exiting..." 1>&2
exit -1
fi
rm -rf BUILD/
mkdir BUILD
cd BUILD/
# Clone linuxcan folder
git clone --depth=1 --branch "$SDK_COMMIT" https://github.com/astuff/kvaser-linuxcan
mv kvaser-linuxcan/ kvaser-linlib/
# Get version of linuxcan
VERSION=$(cat kvaser-linlib/moduleinfo.txt | grep version | sed -e "s/version=//" -e "s/_/./g" -e "s/\r//g")
DEBIAN_VERSION=${VERSION}-0ubuntu0~ppa
if [ -n "$VER_SUFFIX" ]; then
DEBIAN_VERSION=${DEBIAN_VERSION}$VER_SUFFIX
else
DEBIAN_VERSION=${DEBIAN_VERSION}0
fi
# Strip down to only linlib
cd kvaser-linlib/
rm 10-kvaser.rules
rm -r canlib/ leaf/ mhydra/ pcican/ pcican2/ pciefd/ usbcanII/ virtualcan/ dkms/
cp ../../linlib/Makefile-linlib Makefile
# Modify Makefiles for DEB install
sed -i "1s/^/prefix = \/usr\n/" linlib/Makefile
sed -i "s/install \(.*\)\/usr/install -D \1\$(DESTDIR)\$(prefix)/g" linlib/Makefile
sed -i "s/mkdir \(.*\)\/usr/mkdir \1\$(DESTDIR)\$(prefix)/g" linlib/Makefile
sed -i "s/cp \(.*\)\/usr/cp \1\$(DESTDIR)\$(prefix)/g" linlib/Makefile
sed -i "s/ln \(.*\)\/usr/ln \1\$(DESTDIR)\$(prefix)/g" linlib/Makefile
# Have to run 3 times due to combined "rm" lines
sed -i "s/rm \(.*\)\/usr/rm \1\$(DESTDIR)\$(prefix)/g" linlib/Makefile
sed -i "s/rm \(.*\)\/usr/rm \1\$(DESTDIR)\$(prefix)/g" linlib/Makefile
sed -i "s/rm \(.*\)\/usr/rm \1\$(DESTDIR)\$(prefix)/g" linlib/Makefile
sed -i "s/^.*\/sbin\/ldconfig.*$//g" linlib/Makefile
# Create original tarball
tar cfJ ../kvaser-linlib-dev_${VERSION}.orig.tar.xz .
# Modify debian files with correct OS and package versions
cp -r ../../linlib/debian-linlib/ debian/
sed -i "s/unstable/${OS_VER}/" debian/changelog
sed -i "s/MODULE_VERSION/${DEBIAN_VERSION}/" debian/changelog
sed -i "s/DATE_STAMP/$(LC_ALL=C date -R)/" debian/changelog
sed -i "s/DATE_STAMP/$(LC_ALL=C date -R)/" debian/README.Debian
# Build the package
debuild -S -sa
cd ..
# Upload
echo ""
if [ "$UPLOAD" == "upload" ]; then
echo "Uploading..."
dput ppa:astuff/kvaser-linux kvaser-linlib-dev_${DEBIAN_VERSION}_source.changes
echo "Done!"
else
echo "Upload skipped"
fi
cd kvaser-linlib/
echo ""
echo "Building debs locally for testing purposes ..."
debuild --build=binary -sa
echo "Done"