3 # Create a SMR packages from git Repository.
5 # The basic procedure is:
6 # - work on a specific branch of tag in the git repo
7 # - search for debug code and warn
8 # - generate GNU ChangeLog files
12 # Note: this script is 'raw' code and should only be used by developers.
18 # check and assign params
19 if [ "$1" = '--help' ] ||
[ "$1" = '-h' ]; then
20 echo -e "usage: $0 [ TAG ] [ PREV_TAG ]\n\n"
21 echo -e " TAG - package code from this tag\n"
22 echo -e " PREV_TAG - use this tag as starting point for ChangeLog files\n"
34 ###############################################################################
39 echo -e "\n--> removing temp directory"
45 # usage: $1 = tag or branch name (or whatever else got show understands)
47 REPLY
=`$git show $1 | head -1 |cut -d" " -f 2`
48 if [ -n "$REPLY" ]; then
55 # usage: $1 = Ruby filename
58 REPLY
=`grep -e ".*${2}.*=.*" ${1} |cut -d "'" -f 2`
60 if [ -n "$REPLY" ]; then
68 ###############################################################################
73 # initialize some paths
81 # checkout tag (if given) and determine current commit
82 if [ -n "${tag}" ]; then
86 echo "--> no tag given - using whatever commit we are in"
89 # make sure our store is there
90 package_store
=${oldpwd}/${SMR_PACKAGES}
91 if [ ! -d $package_store ]; then
92 echo "--> create package store ${package_store}"
93 mkdir
--parents $package_store
96 TMP
=`mktemp -d /tmp/devel-tools.XXXXXX`
97 echo "--> temp dir is ${TMP}"
99 # determine the commit we are in
102 echo "--> discovered commit $commit"
104 echo "--> exporting code to temp dir"
105 $git archive
$commit |
tar --totals -x -C ${TMP}
107 ###############################################################################
109 # inspect the exported code tree
111 echo -e "\n==> INSPECTING SOURCE TREE in ${TMP}/"
114 if [ ! -d "${SMR_GUI}" ] ; then
115 echo "--> exported dir structure is not as expected. Did the repository structure change?"
120 if [ -d ${SMR_DAEMON} ]; then
121 echo "--> found Daemon directory. Will be packaged separately."
125 if [ -d ${SMR_MANUAL} ]; then
126 echo "--> found Manual directory. Will be packaged separately."
129 echo " -> Manual directory not present, create it and attempt to build anyway"
134 if [ -d ${SMR_PLATFORM} ]; then
135 echo "--> found platform directory. Will be added to the raw source package."
140 # get version from sourcecode
141 if [ -e ${SMR_GUI}/config
/application.rb
]; then
142 smr_config
=${SMR_GUI}/config
/application.rb
144 echo "!!> could not find config file with VERSION constant"
145 echo "!!> Note: versions until 0.5 did not have a version tag."
146 echo "!!> Therefore this script does not work for them."
150 get_constant
${smr_config} VERSION
153 if [ -n "${version}" ]; then
154 echo "--> discovered version=${version} (from ${smr_config})"
156 echo "!!> could not extract release version from ${smr_config}"
160 # rename config file templates
161 #if [ $_build_daemon ]; then
162 # if [ -e ${SMR_DAEMON}/smrd.conf.template ]; then
163 # echo "--> renaming Daemon config file template..."
164 # mv ${SMR_DAEMON}/smrd.conf.template ${SMR_DAEMON}/smrd.conf
166 # echo "--> updating release version in daemon code..."
167 # sed -i "s/__VERSION__/${version}/" ${SMR_DAEMON}/lib/SMR/Config.pm
171 # walk back into the repository
175 echo "--> count things to be fixed: "
176 for i
in ${TMP}/${SMR_GUI} ${TMP}/${SMR_DAEMON}; do
177 echo " -> looking through $i"
178 grep --count --recursive -e 'FIXME' $i/* \
179 |
awk -F':' '{s=s+$2; if($2>0){l++}} END{print s, "FIXMEs in", l, "files"}'
182 ###############################################################################
184 # make ChangeLog file(s)
186 echo -e "\n==> GENERATE CHANGELOGS"
187 if [ -n "$tag" ] && [ -n "${commit}" ]; then
188 echo "--> this release is: ${tag} -> commit ${commit}"
190 echo "--> this release is: *** untagged *** -> commit ${commit}"
193 if [ -z "${prev_tag}" ]; then
194 # figure what the previous tag *could* be
195 # - pretty trivial, but works most of the time.
196 # - if the result is not sufficient, specify the previous tag as second
198 base
=`echo $tag | sed 's/_[0-9]*$//'`
199 patchlevel
=`echo $tag | sed 's/RELEASE_[0-9]*_[0-9]*_//'`
201 patchlevel
=$
((patchlevel-1
))
203 if [ $patchlevel -gt -1 ]; then
204 prev_tag
="${base}_${patchlevel}"
208 if [ -n "${prev_tag}" ]; then
209 get_git_commit
${prev_tag}
211 echo "--> previous release is: ${prev_tag} -> commit ${prev_commit}"
213 # fall back to when we went public
214 prev_commit
=43496b57d517aca217d452317a34ab2401d9c330
215 echo "--> previous release is: *** unknown *** -> commit ${prev_commit} (assumed)"
218 echo "--> writing $SMR_GUI/CHANGELOG"
220 $oldpwd/$git2cl $prev_commit $commit $SMR_GUI > $TMP/$SMR_GUI/CHANGELOG
222 if [ -n "$_build_daemon" ]; then
223 echo "--> writing $SMR_DAEMON/CHANGELOG"
224 $oldpwd/$git2cl $prev_commit $commit $SMR_DAEMON > $TMP/$SMR_DAEMON/CHANGELOG
227 ###############################################################################
229 # compile user & developer manual
231 if [ -n "$_build_manual" ] && [ -z "$rake" ]; then
232 echo "!!> rake command not found. Check that it is installed."
236 if [ -n "$_build_manual" ]; then
237 echo -e "\n==> COMPILE MANUAL"
241 mv .
/doc
/* "$TMP/$SMR_MANUAL/"
245 ###############################################################################
248 # - one for the gui (rails app)
249 # - one for the daemon
250 # - one for the manual
251 echo -e "\n==> BUILD PACKAGES"
254 if [ -n "${tag}" ]; then
255 package_src
="${SMR_PACKAGE_SOURCE}-$version.tar.gz"
256 package_gui
="${SMR_PACKAGE_GUI}-$version.tar.gz"
258 if [ -n "$_build_daemon" ]; then
259 package_daemon
="${SMR_PACKAGE_DAEMON}-$version.tar.gz"
261 if [ -n "$_build_manual" ]; then
262 package_manual
="${SMR_PACKAGE_MANUAL}-$version.tar.gz"
265 package_src
="${SMR_PACKAGE_SOURCE}-${commit}.tar.gz"
266 package_gui
="${SMR_PACKAGE_GUI}-${commit}.tar.gz"
268 if [ -n "$_build_daemon" ]; then
269 package_daemon
="${SMR_PACKAGE_DAEMON}-${commit}.tar.gz"
271 if [ -n "$_build_manual" ]; then
272 package_manual
="${SMR_PACKAGE_MANUAL}-${commit}.tar.gz"
276 echo "--> GUI package is: ${package_gui}"
277 tar --totals -zcf $package_store/$package_gui ${SMR_GUI}
279 if [ -n "$_build_daemon" ]; then
280 echo "--> Daemon package is: ${package_daemon}"
281 tar --totals -zcf $package_store/$package_daemon ${SMR_DAEMON}
284 if [ -n "$_build_manual" ]; then
285 echo "--> Manual package is: ${package_manual}"
286 tar --totals -zcf $package_store/$package_manual ${SMR_MANUAL}
289 ###############################################################################
291 # finally build the raw source package
292 # - this one is for further packaging (RPM, Deb, ...)
293 # - add platform specific files here
294 # - tradition says that raw sources should be stamped with versions to avoid
295 # conflicts on development systems and during further packaging... we do so
296 echo "--> SOURCE package is: ${package_src}"
297 echo "--> stamping versions..."
298 mv ${SMR_GUI} ${SMR_GUI}-${version}
300 if [ $_build_daemon ]; then
301 mv ${SMR_DAEMON} ${SMR_DAEMON}-${version}
304 if [ $_build_manual ]; then
305 mv ${SMR_MANUAL} ${SMR_MANUAL}-${version}
308 if [ $_build_platform ]; then
309 mv ${SMR_PLATFORM} ${SMR_PLATFORM}-${version}
312 # a little reminder...
315 echo " SMR Raw Source Package"
317 echo "This tarball contains raw sourcecode prepared for further packaging. It should"
318 echo "ONLY be used as basis for creating RPMs, Debs, ... or similar packages."
320 echo "Please do NOT use it for PRODUCTION installations. Take one (or all) of the files"
321 echo "below for manual installation:"
323 echo " - ${package_gui}"
324 echo " - ${package_daemon}"
325 echo " - ${package_manual}"
327 echo "or just use the final RPM, Deb, ... packages."
331 tar --totals --exclude=devel-tools
-zcf $package_store/$package_src *