]> git.proxmox.com Git - ceph.git/blame - ceph/make-dist
import ceph 16.2.6
[ceph.git] / ceph / make-dist
CommitLineData
9f95a23c 1#!/bin/bash -e
7c673cae 2
b3b6e05e
TL
3SCRIPTNAME="$(basename "${0}")"
4BASEDIR="$(readlink -f "$(dirname "${0}")")"
5
7c673cae 6if [ ! -d .git ]; then
b3b6e05e
TL
7 echo "$SCRIPTNAME: Full path to the script: $BASEDIR/$SCRIPTNAME"
8 echo "$SCRIPTNAME: No .git present. Run this from the base dir of the git checkout."
9 exit 1
10fi
11
12# Running the script from a directory containing a colon anywhere in the path
13# will expose us to the dreaded "[BUG] npm run [command] failed if the directory
14# path contains colon" bug https://github.com/npm/cli/issues/633
15# (see https://tracker.ceph.com/issues/39556 for details)
16if [[ "$BASEDIR" == *:* ]] ; then
17 echo "$SCRIPTNAME: Full path to the script: $BASEDIR/$SCRIPTNAME"
18 echo "$SCRIPTNAME: The path to the script contains a colon. Their presence has been known to break the script."
7c673cae
FG
19 exit 1
20fi
21
22version=$1
9f95a23c
TL
23[ -z "$version" ] && version=$(git describe --long --match 'v*' | sed 's/^v//')
24if expr index $version '-' > /dev/null; then
25 rpm_version=$(echo $version | cut -d - -f 1-1)
26 rpm_release=$(echo $version | cut -d - -f 2- | sed 's/-/./')
27else
28 rpm_version=$version
29 rpm_release=0
30fi
7c673cae 31
9f95a23c 32outfile="ceph-$version"
7c673cae
FG
33echo "version $version"
34
35# update submodules
36echo "updating submodules..."
37force=$(if git submodule usage 2>&1 | grep --quiet 'update.*--force'; then echo --force ; fi)
38if ! git submodule sync || ! git submodule update $force --init --recursive; then
39 echo "Error: could not initialize submodule projects"
40 echo " Network connectivity might be required."
41 exit 1
42fi
43
f67539c2
TL
44download_from() {
45 fname=$1
b32b8144 46 shift
f67539c2 47 sha256=$1
b32b8144 48 shift
b32b8144
FG
49 set +e
50 while true; do
51 url_base=$1
52 shift
53 if [ -z $url_base ]; then
f67539c2 54 echo "Error: failed to download $name."
b32b8144
FG
55 exit
56 fi
f67539c2
TL
57 url=$url_base/$fname
58 wget -c --no-verbose -O $fname $url
59 if [ $? != 0 -o ! -e $fname ]; then
b32b8144 60 echo "Download of $url failed"
f67539c2
TL
61 elif [ $(sha256sum $fname | awk '{print $1}') != $sha256 ]; then
62 echo "Error: failed to download $name: SHA256 mismatch."
b32b8144
FG
63 else
64 break
65 fi
66 done
67 set -e
f67539c2
TL
68}
69
70download_boost() {
71 boost_version=$1
72 shift
73 boost_sha256=$1
74 shift
75 boost_version_underscore=$(echo $boost_version | sed 's/\./_/g')
76 boost_fname=boost_${boost_version_underscore}.tar.bz2
77 download_from $boost_fname $boost_sha256 $*
b32b8144
FG
78 tar xjf $boost_fname -C src \
79 --exclude="$boost_version_underscore/libs/*/doc" \
80 --exclude="$boost_version_underscore/libs/*/example" \
81 --exclude="$boost_version_underscore/libs/*/examples" \
82 --exclude="$boost_version_underscore/libs/*/meta" \
83 --exclude="$boost_version_underscore/libs/*/test" \
84 --exclude="$boost_version_underscore/tools/boostbook" \
85 --exclude="$boost_version_underscore/tools/quickbook" \
86 --exclude="$boost_version_underscore/tools/auto_index" \
87 --exclude='doc' --exclude='more' --exclude='status'
88 mv src/boost_${boost_version_underscore} src/boost
89 tar cf ${outfile}.boost.tar ${outfile}/src/boost
90 rm -rf src/boost
91}
92
f67539c2
TL
93download_liburing() {
94 liburing_version=$1
95 shift
96 liburing_sha256=$1
97 shift
98 liburing_fname=liburing-${liburing_version}.tar.gz
99 download_from $liburing_fname $liburing_sha256 $*
100 tar xzf $liburing_fname -C src \
101 --exclude=debian \
102 --exclude=examples \
103 --exclude=man \
104 --exclude=test
105 # normalize the names, liburing-0.7 if downloaded from git.kernel.dk,
106 # liburing-liburing-0.7 from github.com
107 mv src/liburing-* src/liburing
108 tar cf ${outfile}.liburing.tar ${outfile}/src/liburing
109 rm -rf src/liburing
110}
111
11fdf7f2
TL
112build_dashboard_frontend() {
113 CURR_DIR=`pwd`
114 TEMP_DIR=`mktemp -d`
eafe8130 115
92f5a8d4 116 $CURR_DIR/src/tools/setup-virtualenv.sh $TEMP_DIR
11fdf7f2 117 $TEMP_DIR/bin/pip install nodeenv
f67539c2 118 $TEMP_DIR/bin/nodeenv --verbose -p --node=12.18.2
11fdf7f2 119 cd src/pybind/mgr/dashboard/frontend
eafe8130 120
11fdf7f2 121 . $TEMP_DIR/bin/activate
f67539c2
TL
122 NG_CLI_ANALYTICS=false timeout 1h npm ci
123 echo "Building ceph-dashboard frontend with build:localize script";
124 # we need to use "--" because so that "--prod" survives accross all
eafe8130 125 # scripts redirections inside package.json
f67539c2 126 npm run build:localize -- --prod
11fdf7f2
TL
127 deactivate
128 cd $CURR_DIR
129 rm -rf $TEMP_DIR
130 tar cf dashboard_frontend.tar $outfile/src/pybind/mgr/dashboard/frontend/dist
131}
132
9f95a23c
TL
133generate_rook_ceph_client() {
134 $outfile/src/pybind/mgr/rook/generate_rook_ceph_client.sh
135 tar cf rook_ceph_client.tar $outfile/src/pybind/mgr/rook/rook_client/*.py
136}
137
7c673cae
FG
138# clean out old cruft...
139echo "cleanup..."
140rm -f $outfile*
141
142# build new tarball
143echo "building tarball..."
144bin/git-archive-all.sh --prefix ceph-$version/ \
145 --verbose \
146 --ignore corpus \
147 $outfile.tar
148
149# populate files with version strings
150echo "including src/.git_version, ceph.spec"
151
9f95a23c 152(git rev-parse HEAD ; echo $version) 2> /dev/null > src/.git_version
7c673cae 153
f67539c2 154for spec in ceph.spec.in; do
7c673cae 155 cat $spec |
9f95a23c 156 sed "s/@PROJECT_VERSION@/$rpm_version/g" |
7c673cae
FG
157 sed "s/@RPM_RELEASE@/$rpm_release/g" |
158 sed "s/@TARBALL_BASENAME@/ceph-$version/g" > `echo $spec | sed 's/.in$//'`
159done
160ln -s . $outfile
f67539c2 161tar cvf $outfile.version.tar $outfile/src/.git_version $outfile/ceph.spec
b32b8144
FG
162# NOTE: If you change this version number make sure the package is available
163# at the three URLs referenced below (may involve uploading to download.ceph.com)
f67539c2
TL
164boost_version=1.73.0
165download_boost $boost_version 4eb3b8d442b426dc35346235c8733b5ae35ba431690e38c6a8263dce9fcbb402 \
522d829b 166 https://boostorg.jfrog.io/artifactory/main/release/$boost_version/source \
b32b8144
FG
167 https://downloads.sourceforge.net/project/boost/boost/$boost_version \
168 https://download.ceph.com/qa
f67539c2
TL
169download_liburing 0.7 8e2842cfe947f3a443af301bdd6d034455536c38a455c7a700d0c1ad165a7543 \
170 https://github.com/axboe/liburing/archive \
171 https://git.kernel.dk/cgit/liburing/snapshot
11fdf7f2 172build_dashboard_frontend
9f95a23c 173generate_rook_ceph_client
f67539c2
TL
174for tarball in $outfile.version \
175 $outfile.boost \
176 $outfile.liburing \
177 dashboard_frontend \
178 rook_ceph_client \
179 $outfile; do
180 tar --concatenate -f $outfile.all.tar $tarball.tar
181 rm $tarball.tar
182done
b32b8144 183mv $outfile.all.tar $outfile.tar
7c673cae 184rm $outfile
7c673cae
FG
185
186echo "compressing..."
187bzip2 -9 $outfile.tar
188
189echo "done."