-
Notifications
You must be signed in to change notification settings - Fork 245
/
update_base
executable file
·92 lines (82 loc) · 2.47 KB
/
update_base
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
#!/usr/bin/bash
#
#
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright (c) 2012, Joyent, Inc.
#
#
# Update all of the non-local repos as necessary
#
shopt -s xpg_echo
upd_arg0=$(basename $0)
upd_root=$(pwd)
upd_extra_stamp="$upd_root/0-extra-stamp $upd_root/1-extra-stamp"
upd_illumos_stamp="$upd_root/0-illumos-stamp $upd_root/1-extra-stamp"
upd_live_stamp="$upd_root/0-livesrc-stamp $upd_root/0-man-stamp"
upd_live_stamp="$upd_live_stamp $upd_root/0-tools-stamp $upd_root/0-pwgen-stamp"
upd_live_stamp="$upd_live_stamp $upd_root/0-builder-stamp"
function fail
{
local msg="$*"
[[ -z "$msg" ]] && msg="failed"
echo "$sbz_arg0: $msg" >&2
exit 1
}
#
# Does a git pull --rebase and sees if anything has changed. Returns 0 if
# nothing changed.
#
function git_update
{
local sha newsha
sha=$(git show HEAD | head -n1 | awk '{print $2 }')
[[ $? -eq 0 ]] || fail 'failed to get current git sha'
git pull --rebase > /dev/null
[[ $? -eq 0 ]] || fail 'failed to update git'
newsha=$(git show HEAD | head -n1 | awk '{print $2 }')
[[ "$sha" == "$newsha" ]]
return
}
function update_extra
{
echo "Updating illumos-extra... \c "
cd $upd_root/projects/illumos-extra
[[ $? -eq 0 ]] || fail "can't find illumos-extra directory"
git_update || rm -f $upd_extra_stamp
echo "done"
}
if [[ -d $upd_root/projects/illumos-extra ]]; then
update_extra
else
echo "illumos-extra tarball in use. Update illumos-extra manually."
fi
echo "Updating illumos-joyent... \c "
cd $upd_root/projects/illumos
[[ $? -eq 0 ]] || fail "can't find illumos directory"
git_update || rm -f $upd_illumos_stamp
echo "done"
echo "Updating illumos-live... \c "
cd $upd_root
[[ $? -eq 0 ]] || fail "illumos-live repo disappeared"
git_update || rm -f $upd_live_stamp
echo "done"
exit 0