Merge pull request #82 from ceph/wip-rm-blkin
[autobuild-ceph.git] / build-cdep-rpm.sh
1 #!/bin/sh -x
2 set -e
3
4 # clear out any $@ potentially passed in
5 set --
6
7 DISTS=`cat ../../dists`
8 RPM_VERSION=`git describe --always | cut -c2- | cut -d- -f1`
9 RPM_RELEASE=`if expr index $(git describe --always) '-' > /dev/null ; then git describe --always | cut -d- -f2- | tr '-' '.' ; else echo "0"; fi`
10
11 VER=${RPM_VERSION}-${RPM_RELEASE}
12
13 # Build packages and sign repo
14 export GNUPGHOME="/srv/gnupg"
15 ./scripts/build-rpm.sh || exit 3
16
17 REV="$(git rev-parse HEAD)"
18 OUTDIR="../out/output/sha1/$REV"
19 OUTDIR_TMP="${OUTDIR}.tmp"
20 install -d -m0755 -- "$OUTDIR_TMP"
21 printf '%s\n' "$REV" >"$OUTDIR_TMP/sha1"
22 printf '%s\n' "$VER" >"$OUTDIR_TMP/version"
23 printf '%s\n' "ceph-deploy" >"$OUTDIR_TMP/name"
24
25 cp -a rpm-repo/*/SRPMS $OUTDIR_TMP
26 cp -a rpm-repo/*/RPMS/* $OUTDIR_TMP
27
28 # we're successful, the files are ok to be published; try to be as
29 # atomic as possible about replacing potentially existing OUTDIR
30 if [ -e "$OUTDIR" ]; then
31     rm -rf -- "$OUTDIR.old"
32     mv -- "$OUTDIR" "$OUTDIR.old"
33 fi
34 mv -- "$OUTDIR_TMP" "$OUTDIR"
35 rm -rf -- "$OUTDIR.old"
36
37 exit 0