initial code repo
[stor4nfv.git] / src / ceph / make-dist
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
23 download_boost() {
24     boost_version=$1
25     shift
26     boost_md5=$1
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"
42         elif [ $(md5sum $boost_fname | awk '{print $1}') != $boost_md5 ]; then
43             echo "Error: failed to download boost: MD5 mismatch."
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
64 # clean out old cruft...
65 echo "cleanup..."
66 rm -f $outfile*
67
68 # build new tarball
69 echo "building tarball..."
70 bin/git-archive-all.sh --prefix ceph-$version/ \
71                        --verbose \
72                        --ignore corpus \
73                        $outfile.tar
74
75 # populate files with version strings
76 echo "including src/.git_version, ceph.spec"
77
78 (git rev-parse HEAD ; git describe) 2> /dev/null > src/.git_version
79
80 # if the version has '-' in it, it has a 'release' part,
81 # like vX.Y.Z-N-g<shortsha1>.  If it doesn't, it's just
82 # vX.Y.Z.  Handle both, and translate - to . for rpm
83 # naming rules (the - separates version and release).
84
85 if expr index $version '-' > /dev/null; then
86         rpm_version=`echo $version | cut -d - -f 1-1`
87         rpm_release=`echo $version | cut -d - -f 2- | sed 's/-/./'`
88 else
89         rpm_version=$version
90         rpm_release=0
91 fi
92
93 for spec in ceph.spec.in alpine/APKBUILD.in; do
94     cat $spec |
95         sed "s/@VERSION@/$rpm_version/g" |
96         sed "s/@RPM_RELEASE@/$rpm_release/g" |
97         sed "s/@TARBALL_BASENAME@/ceph-$version/g" > `echo $spec | sed 's/.in$//'`
98 done
99 ln -s . $outfile
100 tar cvf $outfile.version.tar $outfile/src/.git_version $outfile/ceph.spec $outfile/alpine/APKBUILD
101 # NOTE: If you change this version number make sure the package is available
102 # at the three URLs referenced below (may involve uploading to download.ceph.com)
103 boost_version=1.63.0
104 download_boost $boost_version 1c837ecd990bb022d07e7aab32b09847 \
105                https://dl.bintray.com/boostorg/release/$boost_version/source \
106                https://downloads.sourceforge.net/project/boost/boost/$boost_version \
107                https://download.ceph.com/qa
108 tar --concatenate -f $outfile.all.tar $outfile.version.tar
109 tar --concatenate -f $outfile.all.tar $outfile.boost.tar
110 tar --concatenate -f $outfile.all.tar $outfile.tar
111 mv $outfile.all.tar $outfile.tar
112 rm $outfile
113 rm -f $outfile.version.tar
114 rm -f $outfile.boost.tar
115
116 echo "compressing..."
117 bzip2 -9 $outfile.tar
118
119 echo "done."