-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild_aufs_util.sh
More file actions
executable file
·255 lines (241 loc) · 6.93 KB
/
build_aufs_util.sh
File metadata and controls
executable file
·255 lines (241 loc) · 6.93 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/bin/bash
#
# This script will download and build aufs-util and prepare for installation
# by the associated create_xo_puppy script.
# You need to have kernel-headers from an aufs-enabled kernel, installed
#
# GPL2 (see /usr/share/doc) (c) mavrothal
# NO WARRANTY
BASEDIR=`pwd`
CWD="$BASEDIR"
# Check if we have development tools installed
if [ -f /etc/rc.d/BOOTCONFIG ] ; then
. /etc/rc.d/BOOTCONFIG
DEVX=`echo "$EXTRASFSLIST" | grep devx`
if [ "$DEVX" = "" ] ; then
echo -e "\\0033[1;31m"
echo "You _must_ have devx loaded for this script to run properly"
echo "Please load the devx SFS and try again"
echo -en "\\0033[0;39m"
xoolpcfunc
exit 0
fi
else
if [ "`which gcc | grep no\ `" != "" ] || [ "`which gcc`" = "" ] \
|| [ "`which make | grep no\ `" != "" ] || [ "`which make`" = "" ] ; then
echo -e "\\0033[1;31m"
echo "You _must_ have development tools installed for this script"
echo " to run properly. Please install them and try again"
echo -en "\\0033[0;39m"
xoolpcfunc
exit 0
fi
fi
#Check if we have git
if [ "`which git`" = "" ] ; then
echo -e "\\0033[1;31m"
echo "You _must_ have git installed for this script"
echo " to run properly. Please install git and try again"
echo -en "\\0033[0;39m"
xoolpcfunc
exit 0
fi
# check if the build system has aufs
if [ ! -f /usr/include/linux/aufs_type.h ] ; then
echo -e "\\0033[1;31m"
echo "To build aufs-utilities you must be running an aufs-patched"
echo "kernel and have kernel headers installed. Will not build aufs-util"
echo -en "\\0033[0;39m"
echo "Building Aufs utilities failed. $(date "+%Y-%m-%d %H:%M")" >> $CWD/build.log
sleep 5
exit 1
fi
#Warn if we build in another kernel
if [ "`ls /mnt/home/boot10 | grep 'config' | sed 's/config\-//'`" != "`uname -r`" ] \
&& [ "`ls /mnt/home/boot15 | grep 'config' | sed 's/config\-//'`" != "`uname -r`" ] \
&& [ "`ls /mnt/home/boot175 | grep 'config' | sed 's/config\-//'`" != "`uname -r`" ] \
&& [ "`ls /mnt/home/boot40 | grep 'config' | sed 's/config\-//'`" != "`uname -r`" ]; then
echo -e "\\0033[1;34m"
echo "You are not building Aufs-utils against an XO-puppy kernel"
echo "Hit \"c\" and then \"enter\" to take your chances"
echo "or just \"enter\" to quit building aufs utils"
echo -en "\\0033[0;39m"
read CONTINUE
if [ "$CONTINUE" = "c" ];then
echo "Build Aufs-util against the `uname -r` kernel. $(date "+%Y-%m-%d %H:%M")" >> $CWD/build.log
else
exit 0
fi
else
echo "Build Aufs-util against the `uname -r` kernel. $(date "+%Y-%m-%d %H:%M")" >> $CWD/build.log
fi
if [ ! -d $BASEDIR/XO_SFS_sources ] ; then
mkdir $BASEDIR/XO_SFS_sources
fi
XO_sources="$BASEDIR/XO_SFS_sources"
KMAJ=`uname -r | cut -f 1 -d '.'`
download3 ()
{
if [ ! -d "$XO_sources/aufs-util" ] ; then
cd $XO_sources
git clone git://aufs.git.sourceforge.net/gitroot/aufs/aufs-util.git 2>&1
if [ $? -ne 0 ]; then
echo -e "\\0033[1;31m"
echo "Error: failed to download the Aufs-utils."
echo "Check the connection and try again"
echo -en "\\0033[0;39m"
exit 1
fi
else
cd $XO_sources/aufs-util
git reset --hard HEAD@{1}
git fetch
if [ $? -ne 0 ]; then
echo -e "\\0033[1;31m"
echo "Error: failed to update the Aufs-utils."
echo -e "\\0033[1;34m"
echo "Hit \"c\" and then \"enter\" to continue"
echo "with the old sources or just \"enter\" to quit,"
echo "check the connection and try latter."
echo -en "\\0033[0;39m"
read CONTINUE
if [ "$CONTINUE" = "c" ];then
echo "Aufs-util git update failed. $(date "+%Y-%m-%d %H:%M")" >> $CWD/build.log
else
exit 0
fi
fi
fi
}
export -f download3
download2 ()
{
if [ ! -d "$XO_sources/aufs2-util" ] ; then
cd $XO_sources
git clone git://aufs.git.sourceforge.net/gitroot/aufs/aufs2-util.git 2>&1
if [ $? -ne 0 ]; then
git clone git://git.c3sl.ufpr.br/aufs/aufs2-util.git 2>&1
if [ $? -ne 0 ]; then
echo -e "\\0033[1;31m"
echo "Error: failed to download the Aufs2-utils."
echo "Check the connection and try again"
echo -en "\\0033[0;39m"
exit 1
fi
fi
else
cd $XO_sources/aufs2-util
git reset --hard HEAD@{1}
git fetch
if [ $? -ne 0 ]; then
echo -e "\\0033[1;31m"
echo "Error: failed to update the Aufs2-utils."
echo -e "\\0033[1;34m"
echo "Hit \"c\" and then \"enter\" to continue"
echo "with the old sources or just \"enter\" to quit,"
echo "check the connection and try latter."
echo -en "\\0033[0;39m"
read CONTINUE
if [ "$CONTINUE" = "c" ];then
echo "Aufs2-util git update failed. $(date "+%Y-%m-%d %H:%M")" >> $CWD/build.log
else
exit 0
fi
fi
fi
}
export -f download2
bld_utils ()
{
# Do not build statically
sed -i 's/static/shared/' Makefile
#check where we build and set output folder
if [ "echo $(cat /proc/devise-tree/compatible | grep '1.75')" != "" ]; then
output="$CWD/175aufs_utils"
mkdir -p $CWD/175aufs_utils
elif [ "echo $(cat /proc/devise-tree/compatible | grep 4)" != "" ]; then
output="$CWD/4aufs_utils"
mkdir -p $CWD/4aufs_utils
else
output="$CWD/XO_sfs"
mkdir -p $CWD/XO_sfs
fi
export output
sed -i 's/DESTDIR/output/g' Makefile
sed -i 's/DESTDIR/output/g' libau/Makefile
if [ "`uname -m | grep -i armv7`" != "" ] ; then
export CFLAGS="$CFLAGS -fPIC"
export CXXFLAGS="$CXXFLAGS -fPIC"
fi
make
if [ $? -ne 0 ]; then
echo "Building Aufs utilities failed. $(date "+%Y-%m-%d %H:%M")" >> $CWD/build.log
echo -e "\\0033[1;31m"
echo "Building Aufs utilities failed"
echo -en "\\0033[0;39m"
sleep 5
else
echo "Aufs utilities were build sucessfully. $(date "+%Y-%m-%d %H:%M")" >> $CWD/build.log
fi
make install
make clean
}
export -f bld_utils
cd $XO_sources
# Sellect Aufs-util version to build
echo
echo -e "\\0033[1;34m"
echo "To build aufs_utils for the 3.x kernels hit \"3\""
echo "and then \"enter\". Just \"enter\" to build "
echo "aufs_utils for the 2.6.x kernel"
echo -en "\\0033[0;39m"
read CONTINUE
if [ "$CONTINUE" = "3" ] ; then
if [ "$KMAJ" != "3" ] ; then
echo
echo -e "\\0033[1;31m"
echo "Building aufs_utils for the 3.x kernels in a system"
echo "running a 2.6.x kernel is likely to fail!"
echo "hit \"c\" and then \"enter\" to take your chances"
echo "or just \"enter\" to exit "
echo -en "\\0033[0;39m"
read CONTINUE
if [ "$CONTINUE" = "c" ] ; then
download3
cd $XO_sources/aufs-util
git checkout origin/aufs3.0
bld_utils
else
exit 0
fi
else
download3
cd $XO_sources/aufs-util
git checkout origin/aufs3.0
bld_utils
fi
else
if [ "$KMAJ" != "2" ] ; then
echo
echo -e "\\0033[1;31m"
echo "Building aufs_utils for the 2.6.x kernels in a system"
echo "running a 3.x kernel is likely to fail!"
echo "hit \"c\" and then \"enter\" to take your chances"
echo "or just \"enter\" to exit "
echo -en "\\0033[0;39m"
read CONTINUE
if [ "$CONTINUE" = "c" ] ; then
download2
cd $XO_sources/aufs2-util
git checkout origin/aufs2.2
bld_utils
else
exit 0
fi
else
download2
cd $XO_sources/aufs2-util
git checkout origin/aufs2.2
bld_utils
fi
fi