]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/bin/sh -e |
2 | ||
3 | if [ ! -d .git ]; then | |
4 | echo "no .git present. run this from the base dir of the git checkout." | |
5 | exit 1 | |
6 | fi | |
7 | ||
8 | version=$1 | |
9 | [ -z "$version" ] && version=`git describe --match 'v*' | sed 's/^v//'` | |
10 | outfile="ceph-$version" | |
11 | ||
12 | echo "version $version" | |
13 | ||
14 | # update submodules | |
15 | echo "updating submodules..." | |
16 | force=$(if git submodule usage 2>&1 | grep --quiet 'update.*--force'; then echo --force ; fi) | |
17 | if ! git submodule sync || ! git submodule update $force --init --recursive; then | |
18 | echo "Error: could not initialize submodule projects" | |
19 | echo " Network connectivity might be required." | |
20 | exit 1 | |
21 | fi | |
22 | ||
b32b8144 FG |
23 | download_boost() { |
24 | boost_version=$1 | |
25 | shift | |
11fdf7f2 | 26 | boost_sha256=$1 |
b32b8144 FG |
27 | shift |
28 | boost_version_underscore=$(echo $boost_version | sed 's/\./_/g') | |
29 | boost_fname=boost_${boost_version_underscore}.tar.bz2 | |
30 | set +e | |
31 | while true; do | |
32 | url_base=$1 | |
33 | shift | |
34 | if [ -z $url_base ]; then | |
35 | echo "Error: failed to download boost." | |
36 | exit | |
37 | fi | |
38 | url=$url_base/$boost_fname | |
39 | wget -c --no-verbose -O $boost_fname $url | |
40 | if [ $? != 0 -o ! -e $boost_fname ]; then | |
41 | echo "Download of $url failed" | |
11fdf7f2 TL |
42 | elif [ $(sha256sum $boost_fname | awk '{print $1}') != $boost_sha256 ]; then |
43 | echo "Error: failed to download boost: SHA256 mismatch." | |
b32b8144 FG |
44 | else |
45 | break | |
46 | fi | |
47 | done | |
48 | set -e | |
49 | tar xjf $boost_fname -C src \ | |
50 | --exclude="$boost_version_underscore/libs/*/doc" \ | |
51 | --exclude="$boost_version_underscore/libs/*/example" \ | |
52 | --exclude="$boost_version_underscore/libs/*/examples" \ | |
53 | --exclude="$boost_version_underscore/libs/*/meta" \ | |
54 | --exclude="$boost_version_underscore/libs/*/test" \ | |
55 | --exclude="$boost_version_underscore/tools/boostbook" \ | |
56 | --exclude="$boost_version_underscore/tools/quickbook" \ | |
57 | --exclude="$boost_version_underscore/tools/auto_index" \ | |
58 | --exclude='doc' --exclude='more' --exclude='status' | |
59 | mv src/boost_${boost_version_underscore} src/boost | |
60 | tar cf ${outfile}.boost.tar ${outfile}/src/boost | |
61 | rm -rf src/boost | |
62 | } | |
63 | ||
11fdf7f2 TL |
64 | _python_autoselect() { |
65 | python_command= | |
66 | for interpreter in python2.7 python3 ; do | |
67 | type $interpreter > /dev/null 2>&1 || continue | |
68 | python_command=$interpreter | |
69 | break | |
70 | done | |
71 | if [ -z "$python_command" ] ; then | |
72 | echo "Could not find a suitable python interpreter! Bailing out." | |
73 | exit 1 | |
74 | fi | |
75 | echo $python_command | |
76 | } | |
77 | ||
78 | build_dashboard_frontend() { | |
79 | CURR_DIR=`pwd` | |
80 | TEMP_DIR=`mktemp -d` | |
eafe8130 | 81 | |
11fdf7f2 TL |
82 | $CURR_DIR/src/tools/setup-virtualenv.sh --python=$(_python_autoselect) $TEMP_DIR |
83 | $TEMP_DIR/bin/pip install nodeenv | |
84 | $TEMP_DIR/bin/nodeenv -p --node=10.13.0 | |
85 | cd src/pybind/mgr/dashboard/frontend | |
eafe8130 TL |
86 | |
87 | DEFAULT_LANG=`jq -r .config.locale package.json` | |
88 | if [ -z "$DASHBOARD_FRONTEND_LANGS" ]; then | |
89 | BUILD_TARGET=":${DEFAULT_LANG}" | |
90 | else | |
91 | if [ "$DASHBOARD_FRONTEND_LANGS" == "ALL" ]; then | |
92 | BUILD_TARGET=":*" | |
93 | else | |
94 | DASHBOARD_FRONTEND_LANGS_LIST=`echo "$DASHBOARD_FRONTEND_LANGS" | sed 's/ /,/g'` | |
95 | if [[ $DASHBOARD_FRONTEND_LANGS_LIST != *"${DEFAULT_LANG}"* ]]; then | |
96 | # default language must be always built | |
97 | DASHBOARD_FRONTEND_LANGS_LIST="${DASHBOARD_FRONTEND_LANGS},${DEFAULT_LANG}" | |
98 | fi | |
99 | BUILD_TARGET=":{${DASHBOARD_FRONTEND_LANGS_LIST}}" | |
100 | fi | |
101 | fi | |
102 | [ -z "$MAX_DASHBOARD_PARALLEL_BUILDS" ] && MAX_DASHBOARD_PARALLEL_BUILDS=2 | |
103 | ||
11fdf7f2 TL |
104 | . $TEMP_DIR/bin/activate |
105 | npm ci | |
eafe8130 TL |
106 | echo "Building ceph-dashboard frontend with build${BUILD_TARGET} script"; |
107 | # we need to use "-- --" because so that "--prod" survives accross all | |
108 | # scripts redirections inside package.json | |
109 | npx npm-run-all --print-label --parallel --max-parallel $MAX_DASHBOARD_PARALLEL_BUILDS "build${BUILD_TARGET} -- -- --prod" | |
11fdf7f2 TL |
110 | deactivate |
111 | cd $CURR_DIR | |
112 | rm -rf $TEMP_DIR | |
113 | tar cf dashboard_frontend.tar $outfile/src/pybind/mgr/dashboard/frontend/dist | |
114 | } | |
115 | ||
7c673cae FG |
116 | # clean out old cruft... |
117 | echo "cleanup..." | |
118 | rm -f $outfile* | |
119 | ||
120 | # build new tarball | |
121 | echo "building tarball..." | |
122 | bin/git-archive-all.sh --prefix ceph-$version/ \ | |
123 | --verbose \ | |
124 | --ignore corpus \ | |
125 | $outfile.tar | |
126 | ||
127 | # populate files with version strings | |
128 | echo "including src/.git_version, ceph.spec" | |
129 | ||
130 | (git rev-parse HEAD ; git describe) 2> /dev/null > src/.git_version | |
131 | ||
132 | # if the version has '-' in it, it has a 'release' part, | |
133 | # like vX.Y.Z-N-g<shortsha1>. If it doesn't, it's just | |
134 | # vX.Y.Z. Handle both, and translate - to . for rpm | |
135 | # naming rules (the - separates version and release). | |
136 | ||
137 | if expr index $version '-' > /dev/null; then | |
138 | rpm_version=`echo $version | cut -d - -f 1-1` | |
139 | rpm_release=`echo $version | cut -d - -f 2- | sed 's/-/./'` | |
140 | else | |
141 | rpm_version=$version | |
142 | rpm_release=0 | |
143 | fi | |
144 | ||
7c673cae FG |
145 | for spec in ceph.spec.in alpine/APKBUILD.in; do |
146 | cat $spec | | |
147 | sed "s/@VERSION@/$rpm_version/g" | | |
148 | sed "s/@RPM_RELEASE@/$rpm_release/g" | | |
149 | sed "s/@TARBALL_BASENAME@/ceph-$version/g" > `echo $spec | sed 's/.in$//'` | |
150 | done | |
151 | ln -s . $outfile | |
152 | tar cvf $outfile.version.tar $outfile/src/.git_version $outfile/ceph.spec $outfile/alpine/APKBUILD | |
b32b8144 FG |
153 | # NOTE: If you change this version number make sure the package is available |
154 | # at the three URLs referenced below (may involve uploading to download.ceph.com) | |
11fdf7f2 TL |
155 | boost_version=1.67.0 |
156 | download_boost $boost_version 2684c972994ee57fc5632e03bf044746f6eb45d4920c343937a465fd67a5adba \ | |
b32b8144 FG |
157 | https://dl.bintray.com/boostorg/release/$boost_version/source \ |
158 | https://downloads.sourceforge.net/project/boost/boost/$boost_version \ | |
159 | https://download.ceph.com/qa | |
eafe8130 | 160 | |
11fdf7f2 | 161 | build_dashboard_frontend |
b32b8144 FG |
162 | tar --concatenate -f $outfile.all.tar $outfile.version.tar |
163 | tar --concatenate -f $outfile.all.tar $outfile.boost.tar | |
164 | tar --concatenate -f $outfile.all.tar $outfile.tar | |
11fdf7f2 | 165 | tar --concatenate -f $outfile.all.tar dashboard_frontend.tar |
b32b8144 | 166 | mv $outfile.all.tar $outfile.tar |
7c673cae FG |
167 | rm $outfile |
168 | rm -f $outfile.version.tar | |
b32b8144 | 169 | rm -f $outfile.boost.tar |
7c673cae FG |
170 | |
171 | echo "compressing..." | |
172 | bzip2 -9 $outfile.tar | |
173 | ||
174 | echo "done." |