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