-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcygsetup
executable file
·219 lines (186 loc) · 6.73 KB
/
cygsetup
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
#!/bin/sh
# Copyright Starfish Storage Corp, 2018 - Doug Hughes
# this script is cloned in using SF-Wrappers into the sfenv
# and includes a patches directory that is requisite
HOME=/home/starfish
export HOME
if [ $# -ne 2 ]; then
echo "Usage: must supply starfish version number (e.g. 4.0.4622)"
echo ' $1 = major (e.g. 4622)'
echo ' $2 = minor (e.g. 2f23831)'
exit 1
fi
VERSION=$1
MINOR=$2
# where might I find the cygwin necessary patches
mydir=`pwd`
cygsetupdir=$mydir/`dirname $0`
echo "Git clone password: "
stty -echo
read pass
stty echo
#echo password is $pass
echo "installing python updates"
python -m pip install --upgrade pip
pip install virtualenv
mkdir -p $HOME
virtualenv $HOME/sfenv
cd $HOME/sfenv
. bin/activate
pip install wheel PyNaCl psycopg2 egg future
if [ ! -f /usr/bin/sudo ]; then
cat > /usr/bin/sudo <<EOF
# fake sudo for cygwin
#!/usr/bin/bash
"\$@"
EOF
fi
# copy the patches from the SF-wrappers directory
if [ ! -d $cygsetupdir/../SF-wrappers ]; then
echo "I can't find the SF-wrappers directory. I'm expecting it to be at"
echo `pwd`
exit 1
fi
cp -r $cygsetupdir/cygpatches patches
if [ $? -ne 0 ]; then
echo "failed copying patch directory"
exit 1
fi
git clone -q -o $VERSION https://dhughes%40starfishstorage.com:[email protected]/StarfishStorage/starfish
if [ $? -ne 0 ]; then
echo "git glone of starfish failed: ec $?"
exit 1
fi
git clone -q -o $VERSION https://dhughes%40starfishstorage.com:[email protected]/StarfishStorage/sf-packaging
if [ $? -ne 0 ]; then
echo "git glone of sf-packaging failed: ec $?"
exit 1
fi
git clone -q -o $VERSION https://dhughes%40starfishstorage.com:[email protected]/StarfishStorage/ansible
if [ $? -ne 0 ]; then
echo "git glone of ansible failed: ec $?"
exit 1
fi
git clone -q -o $VERSION https://dhughes%40starfishstorage.com:[email protected]/StarfishStorage/SF-wrappers
if [ $? -ne 0 ]; then
echo "git glone of SF-wrappers failed: ec $?"
exit 1
fi
cd starfish
# cygwin doesn't need nginxor nodejs setup
perl -i.bak -pe ' s/( centos_install_nginx)/\#$1/; s/( centos_install_nodejs)/\#$1/; ' scripts/setup_dev_env.sh
#cygwin comment out things in requirements.txt that don't need to be built
perl -i.bak -pe 's/^(boto|vmprof|psutil)/\#$1/' agent/requirements/base.txt
perl -i.bak -pe 's/^(boto|vmprof|psutil)/\#$1/' client/requirements/base.txt
perl -i.bak -pe 's/^/\#/ if /(^boto|^vmprof|^sqlalchemy|^cryptography|egg=python-swiftclien|pyOpenSSL|future|psutil)/' starfish/requirements/base.txt
# remove extra /'s from post-install.sh - handled by patch
#perl -i.bak -pe 'if (m/STARFISH_BIN_DIR=/) {printf " SFHOME=\$(echo \$SFHOME | tr -s %c/%c)\n", 39, 39;}' ../sf-packaging/packaging-scripts/post-install.sh
# turn off wdb
perl -i.bak -pe 's/^wdb/\#wdb/' starfish/requirements/dev.txt
# strip off double slashes in paths. Cygwin doesn't like them
# also comment out generate manpages from install_tgz
pushd ..
patch -p0 --forward < patches/sf-packaging.patch
if [ $? -ne 0 ]; then
echo "patch of sf-packaging installers failed"
exit 1
fi
popd
patch --forward -p0 < ../patches/setup.py.patch
if [ $? -ne 0 ]; then
echo "patch of setup.py failed"
exit 1
fi
# fix base_service.py - disable vmprof
#perl -i.bak -pe '/^import vmprof/^/\#/' starfish/src/sfutils/base_service.py
patch --forward -p0 < ../patches/base_service.patch
if [ $? -ne 0 ]; then
echo "patch starfish/src/sfutils/base_service.py failed"
exit 1
fi
# install and fix psutil
mkdir -p $HOME/sfenv/pymods > /dev/null 2>&1
cd $HOME/sfenv/pymods
if [ -d psutil-5.2.0 ]; then
rm -rf psutil-5.2.0
fi
pip download psutil==5.2.0
if [ ! -f psutil-5.2.0.tar.gz ]; then
echo "pip download of psutil-5.2.0 failed"
exit 1
fi
# ignore the setup.py error about cygwin support
tar xfz psutil-5.2.0.tar.gz
if [ $? -ne 0 ]; then
echo "tar extraction of psutil-5.2.0 failed. Check disk space?"
exit 1
fi
cd psutil-5.2.0
patch -p1 --forward < ../../patches/cygwin-support.patch
if [ $? -ne 0 ]; then
echo "patch of cygwin-support failed"
exit 1
fi
# this patch may not be needed because _pscygwin.py should be used
patch -p0 --forward < ../../patches/_pswindows.py.patch
if [ $? -ne 0 ]; then
echo "patch of _pswindows.py failed"
exit 1
fi
patch -p0 --forward < ../../patches/_pscygwin.py.patch
if [ $? -ne 0 ]; then
echo "patch of _pscygwin.py failed"
exit 1
fi
echo "Done patching psutil"
make install
if [ $? -ne 0 ]; then
echo "make install of psutil failed"
exit 1
fi
cd build/lib.cygwin-*
# copy the built package into virtualenv
mkdir -p /opt/starfish/lib/virtualenv/sf-cli/lib/python2.7/site-packages > /dev/null 2>&1
mkdir -p /opt/starfish/lib/virtualenv/sf-agent/lib/python2.7/site-packages > /dev/null 2>&1
tar cf - psutil | tar -C /opt/starfish/lib/virtualenv/sf-cli/lib/python2.7/site-packages -xvf -
tar cf - psutil | tar -C /opt/starfish/lib/virtualenv/sf-agent/lib/python2.7/site-packages -xvf -
# setup the development environment
cd $HOME/sfenv/starfish
# Fix versions. do not run gen-version; remove it
#rm ../sf-packaging/gen-version
# hack to work around bug in sf-packaging 2018-07-09 - doug
echo "cat core_v4/version" > ../sf-packaging/gen-version
rm gen-version
echo "4.0.${VERSION}+${MINOR}" > $HOME/sfenv/sf-packaging/core/version
echo "4.0.${VERSION}+${MINOR}" > $HOME/sfenv/sf-packaging/core_v4/version
echo "4.0.${VERSION}+${MINOR}" > $HOME/sfenv/starfish/client/version
echo "4.0.${VERSION}+${MINOR}" > $HOME/sfenv/starfish/agent/version
echo "4.0.${VERSION}+${MINOR}" > $HOME/sfenv/starfish/redash/version
echo "4.0.${VERSION}+${MINOR}" > $HOME/sfenv/starfish/starfish/version
scripts/setup_dev_env.sh
###############################
# Build distribution packages #
###############################
cd $HOME/sfenv/sf-packaging
scripts/generate-dist.sh
./build-package.sh sf-cli tgz --method virtenv
./build-package.sh sf-agent tgz --method virtenv
./build-package.sh sf-core tgz --method virtenv
scripts/install-tgz.sh -n -s opt/starfish -f redhat build/sf-core-*${VERSION}*.tar.gz /
sh /opt/starfish/data/sf-core/post-install.sh 1
scripts/install-tgz.sh -n -s opt/starfish -f redhat build/sf-agent-*${VERSION}*.tar.gz /
sh /opt/starfish/data/sf-agent/post-install.sh 1
scripts/install-tgz.sh -n -s opt/starfish -f redhat build/sf-cli-*${VERSION}*.tar.gz /
sh /opt/starfish/data/sf-cli/post-install.sh 1
# for some reason future and builtins doesn't get copied in by the package builder
cd $HOME/sfenv
find lib -name builtins | xargs tar -cf - | (cd /opt/starfish/lib/virtualenv/sf-agent; tar -xf -)
find lib -name future* | xargs tar -cf - | (cd /opt/starfish/lib/virtualenv/sf-agent; tar -xf -)
echo "building tarball"
cd /
tar cfz /tmp/starfish-${VERSION}-${MINOR}.tar.gz /opt/starfish /home/starfish
echo "copy in startfish"
mkdir -p /usr/local/bin > /dev/null 2>&1
cp -r $cygsetupdir/cygpatches/startfish /usr/local/bin/startfish
echo "SUCCESS!"
exit 0