-
Notifications
You must be signed in to change notification settings - Fork 2
/
makeTgzPkg.sh
executable file
·111 lines (84 loc) · 2.15 KB
/
makeTgzPkg.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
#!/bin/bash
DIR=$(dirname $(readlink -f $0))
if [ `arch` == 'x86_64' ]; then
ARCH=x86_64
else
ARCH=i386
fi
VERSION=`cat "$DIR/VERSION"`
BUILDDIR=$DIR/build/bin/diveboard-agent-$VERSION-$ARCH
OUTDIR=$DIR/build/packages
SHAREDIR=$DIR/build/bin/share
LIBDIVE=$DIR/build/bin/libdivecomputer.so
APPDIVEBOARD=$DIR/build/bin/DiveboardAgent
PKGNAME=diveboard-agent-$VERSION-$ARCH.tgz
#
# Put the package together
#
if [ ! -f $APPDIVEBOARD ]; then
echo Unable to find DiveBoard - did you build it?
echo MISSING: $APPDIVEDBOARD
exit 1
fi
if [ ! -f $LIBDIVE ]; then
echo Unable to find libdivecomputer - did you build it?
echo MISSING: $LIBDIVE
exit 1
fi
echo Creating build structure...
mkdir -p $OUTDIR
rm -f $OUTDIR/$PKGNAME
rm -rf $BUILDDIR
mkdir -p $BUILDDIR/usr/lib/diveboard
mkdir -p $BUILDDIR/usr/bin
echo Copying package contents...
cp $APPDIVEBOARD $BUILDDIR/usr/bin/DiveboardAgent
cp $LIBDIVE $BUILDDIR/usr/lib/diveboard/libdivecomputer.so
cp -r $SHAREDIR $BUILDDIR/usr/
echo Stripping binaries...
strip $BUILDDIR/usr/bin/DiveboardAgent
strip $BUILDDIR/usr/lib/diveboard/*.so
echo Fixing permissions...
chmod 755 $BUILDDIR/usr/bin/DiveboardAgent
chmod 644 $BUILDDIR/usr/lib/diveboard/*.so
#chmod -R 644 $BUILDDIR/usr/share/*
echo Creating install script...
cat > "$BUILDDIR/install.sh" <<EOF
#!/bin/bash
set -e
SELF=\$(which "\$0")
BASEDIR=\$(dirname "\$SELF")
if [ ! -w /usr/lib ]; then
echo "You need to be root to install the plugin"
exit 1
fi
cp -a "\$BASEDIR/usr" /
exit 0
EOF
EOF
chmod 755 $BUILDDIR/install.sh
echo Creating uninstall script...
cat > $BUILDDIR/uninstall.sh <<EOF
#!/bin/bash
set -e
if [ ! -d /usr/lib/diveboard ]; then
echo "The plugin for Diveboard does not seem to be installed. Aborting uninstallation."
exit 2
fi
if [ ! -w /usr/lib ]; then
echo "You need to be root to uninstall the plugin"
exit 1
fi
rm -fr /usr/lib/diveboard
rm -fr /usr/bin/DiveboardAgent
exit 0
EOF
EOF
chmod 755 $BUILDDIR/uninstall.sh
echo Building Package...
cd $BUILDDIR/..
tar zcf $OUTDIR/$PKGNAME --owner=root --group=root $(basename "$BUILDDIR")
if [ ! -f $OUTDIR/$PKGNAME ];then
echo Something went wrong!
exit 1
fi