-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathprepare_repo_for_packaging
executable file
·152 lines (124 loc) · 3.93 KB
/
prepare_repo_for_packaging
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
#!/bin/bash
#
# Used during packaging.
#
# Do not run if you are not in a scratch checkout!
#
# THIS SCRIPT WILL DELETE YOUR .git DIRECTORY AND ALL YOUR HISTORY WILL BE
# LOST. THIS IS ON PURPOSE!
set -o errexit
set -o nounset
set -o pipefail
USAGE=`cat <<USAGE_WARNING
${0} is used by rpm-creator.py to prepare a git checkout of this repo for
packaging.
You almost certainly do not want to run this in your checkout; it deletes
all the .py files from the current directory (and all subdirectories), then
nukes the .git directory as well. This is likely to make you very sad if it
happens someplace you are doing work.
If you really, *really* want to run it, do:
${0} --destroy-all-my-work
USAGE_WARNING`
if [ $# == 0 ]; then
echo "$USAGE"
exit 0
fi
if [ $1 != "--destroy-all-my-work" ]; then
echo "$USAGE"
exit 0
fi
# Per MER-1056, remove all .py files and scrub .git directory before
# creating an RPM.
echo "Capturing git SHA..."
groksha=`git rev-parse --verify HEAD`
echo ${groksha} > static/grok.sha
echo ${groksha}
echo "Recording Grok Release Version..."
bin/update_release_version.py `python -c 'from grok.__version__ import __version__; print __version__'`-$(git rev-list HEAD | wc -l)
python -c 'from grok.__version__ import __version__; print __version__'
echo "Removing stale .pyc files"
find . -name '*.pyc' -delete
echo "**************************"
export PATH=/opt/numenta/anaconda/bin:$PATH
echo $PATH
echo "Compiling all .py files..."
for src_d in conf docs grok
do
# compileall only drills 10 deep, so rather than having a mysterious
# failure later if our directory structure gets more complex, compile
# in every subdir.
if [ -d $src_d ]; then
echo "Compiling .py files in ${src_d}"
find $src_d -type d -exec python -m compileall '{}' ';'
else
echo "**********"
echo "$src_d not found during .py compilation in prepare_repo_for_packaging"
echo "**********"
exit 1
fi
done
echo "Purging .py files:"
for src_d in grok/app
do
# Don't remove migrate.py to cope with Marketplace 1.0 bug. Version 1.0
# expected to find migrate.py in grok/app/repository, but
# when we started purging the .py files this meant the db migration wasn't
# getting run. Exclude migrate.py from deletion so 1.0 boxes won't choke
# during updates.
if [ -d $src_d ]; then
echo "Purging .py files in ${src_d}"
find ${src_d} -path grok/app/repository/migrations -prune -o \( -iname "*.py" ! -iname "migrate.py" \) -print0 | xargs -0 rm -f
else
echo "**********"
echo "$src_d not found during .py purge phase in prepare_repo_for_packaging"
echo "**********"
exit 1
fi
done
# Delete configs so they are not embedded in the RPM. Conf files should
# be generated by python setup.py init, not installed from a rpm.
echo "running git clean -xf conf/"
git clean -xf conf/
if [ -d conf ]; then
echo "Nuking conf files that have corresponding .tpl files"
for raw_f in conf/*.tpl
do
template_f=`basename $raw_f`
rm -fv conf/${template_f%%.*}.conf
done
echo "exclude conf/overrides from rpm explicitly"
rm -fv conf/overrides/*
else
echo "WTF, where is conf directory?"
echo -n "pwd: "
pwd
fi
# Scrub egg-link files. They inevitably point to directories on the build
# machine that will not be on the machines we're installing the RPM on, so
# kill them with fire.
find . -name '*.egg-link' -exec rm '{}' ';'
# Scrub random garbage
rm -f .gitignore \
.bowerrc \
.project \
.pydevproject \
CI.lock
# And finally, nuke the .git directory
echo "Purging .git directory..."
rm -fr .git
cat << KABOOM
_.-^^---....,,--
_-- --_
< >)
| BOOM! |
\._ _./
``---. . , ; .--'''
| | |
.-=|| | |=-.
\-=#$%&%$#=-'
| ; :|
_____.,-#%&*@%#&#~,._____
.py files have been purged, along with your .git directory.
KABOOM
# Keep prep script out of the RPM
rm -f prepare_repo_for_packaging