blob: 6e5f5b0d0a59bfddd457726accfba783062cd42c (
plain)
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
#!/bin/sh
# die: print message to stderr and exit with error code
#
# PARAMETERS
# $1 $2 ... - message to be printed
die()
{
echo "$CE$N: fatal error: $*$CN" >&2
echo "For detailed log, see: $LOG"
exit 1
}
warn()
{
echo "$CE$N: warning: $*$CN" >&2
}
notice()
{
echo "$CX$N: $*$CN" >&2
}
lx()
{
notice "[exec]: $*"
"$@"
}
# make sure we're not root
if test `id -u` = "0"
then
die "Please install SBS in a user account, not as root"
fi
# enable colors only on terminal devices
TPUT="`which tput`"
if test -t 0 -a -t 1 -a -n "$TPUT"
then
CI="`$TPUT setf 6 || true`"
CE="`$TPUT setf 4 || true`"
CX="`$TPUT setf 2 || true`"
CN="`$TPUT sgr0 || true`"
else
CI=''
CE=''
CX=''
CN=''
fi
N="`basename \"$0\"`"
# default logging is none
LOG="$(mktemp /tmp/.sbs-install-XXXXXX)"
[ $? -eq 0 ] || { echo "$CE$N: error: unable to open log file$CN" >&2; exit 1; }
echo "SBS install begin" > "$LOG"
date >> "$LOG"
git rev-parse --short HEAD >> "$LOG"
echo >> "$LOG"
echo
echo "$CI""SBS install script$CN"
echo "$CI""git version: `git rev-parse --short HEAD`$CN"
echo "$CI""last commit: `git log HEAD^1.. | grep ^Date:`$CN"
echo "$CI""For help see: https://source.tizen.org$CN"
echo
check_email_and_complain()
{
local email name
# figure out the user's single ID
while true
do
email="`git config --global --get user.email`"
if [ "$email" ]
then
break
fi
echo "git username and email address are not set correctly."
echo "SBS will configure these for you now."
echo "Example name: David Kim"
echo "Example email: david.kim@your_company.com"
echo
echo -n "Your name: "
read name
echo -n "Your email: "
read email
git config --global user.name "$name"
git config --global user.email "$email"
echo
done
}
copy_key_from_scratchbox()
{
if ! test -f "$HOME/.ssh/id_rsa"
then
if test -f "/scratchbox/users/$USER/home/$USER/.ssh/id_rsa"
then
echo "Copying public key from old scratchbox install"
mkdir -p "$HOME/.ssh"
cp -f "/scratchbox/users/$USER/home/$USER/.ssh"/id_rsa* "$HOME/.ssh"
fi
fi
}
check_sbs_uptodate()
{
local branch
# update sbs
echo -n "Updating sbs... "
# using origin/master because this is the default setup by git
(git fetch "$REMOTE""tools/sbs" master:origin/master -q >> "$LOG") || die "failed to fetch sbs repository"
if ! git diff-index --quiet HEAD
then
echo
echo
echo "$CE""Files have been changed. Please checkin changes or remove them with:""$CN"
echo "$CE""git reset --hard origin""$CN"
echo
die "Repository not clean"
fi
# check the current branch contains the latest we fetched from above
branch=`git branch --contains origin/master 2> /dev/null | grep "^\\* "`
if [ ! "$branch" ]
then
warn "Please update to origin. e.g. git reset --hard origin"
die "Repository not up-to-date"
fi
echo "done"
}
# location of server with all our source
REMOTE=${SBS_INSTALL_REMOTE:-"download.tizen.org:"}
# our original cwd
ROOTDIR="`pwd`"
# no user compile options, thanks
unset CC CFLAGS LDFLAGS MAKE MAKEFLAGS PANTS
if [ ! "$SBS_INSTALL_LAX" ]
then
check_email_and_complain
copy_key_from_scratchbox
#check_sbs_uptodate
fi
# which distribution are we installing on?
cat /etc/lsb-release >> "$LOG" 2> /dev/null
INSTALLDIR=${SBS_INSTALL_DIR:-"$HOME/sbs-install"}
BUILDDIR="$ROOTDIR/Build"
SB2DIR="$BUILDDIR/scratchbox2"
QEMUDIR="$BUILDDIR/qemu"
DEBOOTDIR="$BUILDDIR/debootstrap"
LUTILDIR="$BUILDDIR/lutil"
missing=''
pkg-config --version >/dev/null 2>&1 || { missing="$missing pkg-config"; warn "pkg-config missing - dependency checks won't be accurate"; }
pkg-config --exists libxml-2.0 >/dev/null 2>&1 || missing="$missing libxml2-dev"
pkg-config --exists uuid >/dev/null 2>&1 || missing="$missing uuid-dev"
cpp --version >/dev/null 2>&1 || { missing="$missing cpp"; warn "cpp missing - dependency checks won't be accurate"; }
echo | cpp -include archive.h >/dev/null 2>&1 || missing="$missing libarchive-dev"
echo | cpp -include lzo/lzo1x.h >/dev/null 2>&1 || missing="$missing liblzo2-dev"
gcc --version >/dev/null 2>&1 || { missing="$missing gcc"; warn "gcc missing - dependency checks won't be accurate"; }
[ `uname -m` != 'x86_64' ] || echo '#include <asm/errno.h>' | gcc -m32 -xc -c -o /dev/null - >/dev/null 2>&1 || missing="$missing gcc-multilib"
if ! pkg-config --exists zlib >/dev/null 2>&1; then
# Either pkg-config or zlib itself wasn't found (Debian provide .pc file, Ubuntu doesn't)
# We have to check zlib existence manually.
echo | cpp -include zlib.h >/dev/null 2>&1 || missing="$missing zlib1g-dev"
fi
# check for things needed to build scratchbox2
for prog in automake autoconf make fakeroot realpath; do
$prog --version >/dev/null 2>&1 || missing="$missing $prog"
done
# check for dpkg-dev
if ! dpkg-architecture --version >/dev/null 2>&1; then
missing="$missing dpkg-dev"
fi
[ -z "$missing" ] || die "please install required packages: $missing"
mkdir -p "$BUILDDIR"
git rev-parse HEAD > "$BUILDDIR/versions"
# download stuff
while read name
do
srcfile="$BUILDDIR/$name.tar.gz"
srcdir="$BUILDDIR/$name"
echo -n "Downloading $name... "
echo "Downloading $name" >> "$LOG"
rm -rf "$srcdir"
wget --no-check-certificate -P $BUILDDIR http://download.tizen.org/releases/1.0/sbs/$name.tar.gz
mkdir "$srcdir"
tar xzf "$srcfile" -C "$srcdir" --touch
rm -f "$srcfile"
echo "done"
done <<END
scratchbox2
qemu
debootstrap
lutil
END
# build scratchbox2
echo -n "Building scratchbox2... "
(cd "$SB2DIR" && make clean > /dev/null 2>&1)
(cd "$SB2DIR" && ./autogen.sh && ./configure && make 2>&1 ) >> "$LOG" || die "scratchbox2 build failed"
echo "done"
echo -n "Installing scratchbox2... "
(cd "$SB2DIR" && make install prefix="$INSTALLDIR" 2>&1 ) >> "$LOG" || die "scratchbox2 install failed"
echo "done"
# build qemu
echo -n "Building qemu... "
(cd "$QEMUDIR" && make clean > /dev/null 2>&1)
(cd "$QEMUDIR" && ./configure --target-list=arm-linux-user,i386-linux-user --disable-blobs --disable-uuid && make 2>&1) >> "$LOG" || die "qemu build failed"
echo "done"
echo -n "Installing qemu... "
(cd "$QEMUDIR" && make install prefix="$INSTALLDIR" 2>&1 ) >> "$LOG" || die "qemu install failed"
echo "done"
# build lutil and related tools
echo -n "Building lutil... "
(cd "$LUTILDIR" && ./autogen.sh && make prefix=/) >> "$LOG" || die "failed to build lutil"
(cd "$LUTILDIR" && make install prefix=/ DESTDIR="$INSTALLDIR" 2>&1 ) >> "$LOG" || die "lutil install failed"
echo "done"
# install debootstrap
echo -n "Installing debootstrap... "
(cd "$DEBOOTDIR" && fakeroot make devices.tar.gz) >> "$LOG" || die "failed to build debootstrap"
mkdir -p "$INSTALLDIR"/share/debootstrap/scripts/
cp -fd "$DEBOOTDIR"/scripts/* "$INSTALLDIR"/share/debootstrap/scripts/
cp -f "$DEBOOTDIR"/functions "$INSTALLDIR"/share/debootstrap
cp -f "$DEBOOTDIR"/devices.tar.gz "$INSTALLDIR"/share/debootstrap
cp -f "$DEBOOTDIR"/debootstrap "$INSTALLDIR"/bin/debootstrap
echo "done"
# update the sbs binary
echo -n "Installing sbs scripts... "
if [ -e "$INSTALLDIR"/sbs.list ]; then
notice "removing old sbs installation files" >>"$LOG" 2>&1
sort -r "$INSTALLDIR"/sbs.list |
while read path; do
if [ -d "$INSTALLDIR/$path" ]
then
lx rmdir "$INSTALLDIR/$path" || true
else
lx rm "$INSTALLDIR/$path" || true
fi
done >>"$LOG" 2>&1
mv -f "$INSTALLDIR"/sbs.list "$INSTALLDIR"/sbs.list.old
fi
mkdir -p "$INSTALLDIR"
make install DESTDIR="$INSTALLDIR" prefix=/ >"$INSTALLDIR/sbs.list" 2>>$LOG || die "failed to install SBS"
echo "done"
# save the versions, to enable OSS license compliance
cp -f "$BUILDDIR"/versions "$INSTALLDIR"
SBS_ROOTDIR=${SBS_ROOTDIR:-$HOME/sbs}
if ! test -d "$SBS_ROOTDIR"
then
echo
echo "$CX""Run $INSTALLDIR/bin/sbs -c to create your initial environment$CN"
echo
else
echo
echo "$CX""SBS update successful$CN"
echo
fi
|