forked from dimkr/run_woof
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbashrc
132 lines (110 loc) · 3.54 KB
/
bashrc
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
#!/bin/sh
. /etc/profile
PS1="run_woof\\$ "
cd /root/share
# CHECK_FOR_UPDATES and MERGE_UPDATES are defined in run_woof.conf
if [ -e run_woof/run_woof.conf ]; then
. run_woof/run_woof.conf
elif [ -e run_woof-master/run_woof.conf ]; then
. run_woof-master/run_woof.conf
fi
if [ ! -d woof-CE ]; then
echo
echo "Do you want to download woof-CE?"
echo -n "(y/n)"
read YESNO
if [ "$YESNO" = 'y' -o "$YESNO" = 'Y' ]; then
DOWNLOAD='yes'
echo
echo "If you have a fork on GitHub of the woof-CE repo that you want to download,"
echo "enter your GitHub username, otherwise leave blank to download the main"
echo "puppylinux-woof-CE/woof-CE repo"
echo
echo -n "username: "
read USERNAME
fi
if [ "$DOWNLOAD" = 'yes' ]; then
if [ "$USERNAME" = '' ]; then
GIT_SSL_NO_VERIFY=true git clone https://github.com/puppylinux-woof-CE/woof-CE.git
else
GIT_SSL_NO_VERIFY=true git clone https://github.com/"$USERNAME"/woof-CE.git
cd woof-CE
git remote add upstream https://github.com/puppylinux-woof-CE/woof-CE.git
GIT_SSL_NO_VERIFY=true git fetch -v upstream
GIT_STATUS="`git status`"
ON_BRANCH="$(expr match "$(echo "$GIT_STATUS" | grep 'On branch')" 'On branch \(.*\)')"
if [ "`git branch -r | grep "upstream/${ON_BRANCH}"`" != '' ]; then
git branch --set-upstream-to=upstream/${ON_BRANCH}
fi
cd ..
fi
fi
else
if [ "$CHECK_FOR_UPDATES" != 'no' ]; then
if [ "`stat -c %U:%G woof-CE`" != 'root:root' ]; then
echo "Tip: If you want to check for updates from run_woof you can change"
echo "the ownership of the woof-CE repo with the following command:"
echo "chown -R root:root woof-CE"
CHECK_FOR_UPDATES='no'
fi
fi
if [ "$CHECK_FOR_UPDATES" = 'no' ]; then
YESNO='n'
elif [ "$CHECK_FOR_UPDATES" = 'yes' ]; then
YESNO='y'
else
echo
echo "Do you want to check for any updates to woof-CE?"
echo -n "(y/n)"
read YESNO
echo
fi
if [ "$YESNO" = 'y' -o "$YESNO" = 'Y' ]; then
cd woof-CE
if [ "`git remote | grep 'upstream'`" != '' ]; then
FETCH_URL="`git remote show -n upstream | grep 'Fetch URL:'`"
if [ "`echo "$FETCH_URL" | grep 'Fetch URL: http'`" = '' ]; then
# only http works from inside run_woof
GIT_SSL_NO_VERIFY=true git fetch -v https://github.com/$(expr match "$FETCH_URL" '.*github.com:\(.*\)') "+refs/heads/*:refs/remotes/upstream/*"
else
GIT_SSL_NO_VERIFY=true git fetch -v upstream
fi
echo
fi
if [ "`git remote | grep 'origin'`" != '' ]; then
FETCH_URL="`git remote show -n origin | grep 'Fetch URL:'`"
if [ "`echo "$FETCH_URL" | grep 'Fetch URL: http'`" = '' ]; then
# only http works from inside run_woof
GIT_SSL_NO_VERIFY=true git fetch -v https://github.com/$(expr match "$FETCH_URL" '.*github.com:\(.*\)') "+refs/heads/*:refs/remotes/origin/*"
else
GIT_SSL_NO_VERIFY=true git fetch -v origin
fi
echo
fi
GIT_STATUS="`git status`"
# echo "$GIT_STATUS"
if [ "`echo $GIT_STATUS | grep 'and can be fast-forwarded'`" != '' ]; then
if [ "$MERGE_UPDATES" = 'no' ]; then
YESNO='n'
elif [ "$MERGE_UPDATES" = 'yes' ]; then
YESNO='y'
else
echo "Do you want to update your local woof-CE repo?"
echo -n "(y/n)"
read YESNO
echo
fi
if [ "$YESNO" = 'y' -o "$YESNO" = 'Y' ]; then
TRACKING_BRANCH="$(expr match "$(echo "$GIT_STATUS" | grep 'Your branch is behind')" "Your branch is behind '\(.*\)'")"
# echo "$TRACKING_BRANCH"
if [ "$TRACKING_BRANCH" != '' ]; then
git merge --ff-only "$TRACKING_BRANCH"
fi
fi
fi
cd ..
fi
fi
echo
echo "Type exit and press <Enter> to leave run_woof"
echo