File checkin.sh of Package ceph-test
141
1
2
#
3
# checkin.sh
4
#
5
# This script automates generation of a new tarball and spec file from a
6
# git clone or repo+branch combination for the "ceph" package in OBS.
7
#
8
9
set -x
10
11
BASEDIR=$(pwd)
12
13
function usage {
14
set +x
15
echo "Usage:"
16
echo " ${0} [-h,--help] [-e,--existing CLONE]"
17
echo " [-r,--repo REPO] [-b,--branch BRANCH]"
18
echo ""
19
echo "Options:"
20
echo " --existing Use existing ceph clone CLONE"
21
echo " --repo Make a fresh clone of ceph repo REPO"
22
echo " --branch Use branch BRANCH with fresh clone"
23
echo ""
24
echo "Notes:"
25
echo " If existing clone is given, repo and branch are ignored."
26
echo " Repo defaults to https://github.com/SUSE/ceph.git"
27
echo " Branch defaults to ses7p"
28
exit 1
29
}
30
31
function _error_exit {
32
echo >&2 $1
33
exit $2
34
}
35
36
function _check_ceph_clone {
37
local OPT="$1"
38
if [ -z "$OPT" ] ; then
39
_error_exit "Empty string sent to internal function _check_ceph_clone"
40
fi
41
if [ -e "$OPT/make-dist" ] ; then
42
echo "$OPT looks like a ceph clone; using it"
43
else
44
_error_exit "$OPT does not appear to be a ceph clone" 1
45
fi
46
}
47
48
function _verify_git_describe {
49
git describe --match 'v*'
50
echo "Does this version number looks sane? y/[N]"
51
read a
52
if [ "x$a" != "xy" ] ; then
53
_error_exit "Aborting!" 1
54
fi
55
}
56
57
GETOPT=$(getopt -o b:e:hr: --long "branch:,existing:,help,repo:" \
58
-n 'checkin.sh' -- "$@")
59
test "$?" -eq 0 || _error_exit "Terminating..." 1
60
eval set -- "$GETOPT"
61
62
EXISTING=""
63
REPO="https://github.com/SUSE/ceph.git"
64
BRANCH="ses7p"
65
while true ; do
66
case "$1" in
67
-b|--branch) BRANCH="$2" ; shift 2 ;;
68
-e|--existing) EXISTING="$2" ; shift 2 ;;
69
-h|--help) usage ;; # does not return
70
-r|--repo) REPO="$2" ; shift 2 ;;
71
--) shift ; break ;;
72
*) echo "Internal error" ; exit 1 ;;
73
esac
74
done
75
76
if [ -n "$EXISTING" ] ; then
77
if [ ! -d "$EXISTING" ] ; then
78
_error_exit "Alleged directory ->$EXISTING<- is not a directory" 1
79
fi
80
if [ ! -r "$EXISTING" ] ; then
81
_error_exit "I cannot read directory ->$EXISTING<-" 1
82
fi
83
if [ ! -w "$EXISTING" ] ; then
84
_error_exit "I cannot write to directory ->$EXISTING<-" 1
85
fi
86
if [ ! -x "$EXISTING" ] ; then
87
_error_exit "I cannot cd to directory ->$EXISTING<-" 1
88
fi
89
CLONE="$EXISTING"
90
else
91
echo "Will make fresh clone of repo ->$REPO<- branch ->$BRANCH<-"
92
# TMPDIR=$(mktemp -d --tmpdir=$BASEDIR) # does not work due to http://tracker.ceph.com/issues/39556
93
TMPDIR=$(mktemp -d)
94
echo "Created temporary temporary $TMPDIR"
95
git clone --progress --branch $BRANCH $REPO $TMPDIR
96
CLONE="$TMPDIR"
97
fi
98
_check_ceph_clone "$CLONE"
99
100
pushd $CLONE
101
#_verify_git_describe
102
if [ -z "$TMPDIR" ] ; then
103
echo "Deleting stale tarballs from previous runs"
104
rm -rf *.bz2
105
fi
106
echo "Running make-dist inside clone"
107
export DASHBOARD_FRONTEND_LANGS="ALL"
108
./make-dist
109
popd
110
111
echo "Running \"osc rm *bz2\" to nuke previous tarball"
112
if type osc > /dev/null 2>&1 ; then
113
osc rm *bz2
114
else
115
_error_exit "osc not installed - cannot continue" 1
116
fi
117
118
if stat --printf='' *.bz2 2>/dev/null ; then
119
_error_exit "There are still files ending in bz2 in the current directory - clean up yourself!" 1
120
fi
121
122
echo "Copying new spec file and tarball from $CLONE"
123
cp $CLONE/ceph.spec $CLONE/ceph*bz2 .
124
125
if [ -n "$TMPDIR" ] ; then
126
echo "Nuking the clone"
127
rm -rf $TMPDIR
128
fi
129
130
echo "Running \"osc add *bz2\" to register the new tarball"
131
osc add *bz2
132
133
echo "Running pre_checkin.sh (if you touch the ceph.changes file after running this script, re-run pre_checkin.sh manually)"
134
if [ -f "pre_checkin.sh" ] ; then
135
bash pre_checkin.sh
136
else
137
echo "WARNING: no pre_checkin.sh script found!"
138
fi
139
140
echo "Done! Run \"osc ci --noservice\" to commit."
141