README: add deprecation notice
[nautilus-actions.git] / maintainer / release-tarball.sh
blob64d9883aae3da61ffd2bde27038128f75f97d076
1 #!/bin/ksh
2 # FileManager-Actions
3 # A file-manager extension which offers configurable context menu actions.
5 # Copyright (C) 2005 The GNOME Foundation
6 # Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7 # Copyright (C) 2009-2015 Pierre Wieser and others (see AUTHORS)
9 # FileManager-Actions is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
14 # FileManager-Actions is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with FileManager-Actions; see the file COPYING. If not, see
21 # <http://www.gnu.org/licenses/>.
23 # Authors:
24 # Frederic Ruaudel <grumz@grumz.net>
25 # Rodrigo Moya <rodrigo@gnome-db.org>
26 # Pierre Wieser <pwieser@trychlos.org>
27 # ... and many others (see AUTHORS)
29 errs=0 # will be the exit code of the script
30 my_cmd="${0}" # e.g. "./make-ks.sh"
31 my_parms="$*" # e.g. "-host toaster"
32 my_cmdline="${my_cmd} ${my_parms}"
33 me="${my_cmd##*/}" # e.g. "make-ks.sh"
34 # used in msg and msgerr functions
35 my_tmproot="/tmp/$(echo ${me} | sed 's?\..*$??').$$"
36 # e.g. "/tmp/make-ks.1978"
38 # These three functions must be defined using the name() syntax in order
39 # to share traps with the caller process (cf. man (1) ksh).
41 trap_exit()
43 clear_tmpfiles
44 [ "${opt_verbose}" = "yes" -o ${errs} -gt 0 ] && msg "exiting with code ${errs}"
45 exit ${errs}
48 trap_int()
50 msg "quitting on keyboard interrupt"
51 let errs+=1
52 exit
55 trap_term()
57 [ "${opt_verbose}" = "yes" ] && msg "quitting on TERM signal"
58 exit
61 # setup the different trap functions
62 trap 'trap_term' TERM
63 trap 'trap_int' INT
64 trap 'trap_exit' EXIT
66 clear_tmpfiles()
68 \rm -f ${my_tmproot}.*
71 msg()
73 typeset _eol="\n"
74 [ $# -ge 2 ] && _eol="${2}"
75 printf "[%s] %s${_eol}" ${me} "${1}"
76 return 0
79 msgerr()
81 msg "error: ${1}" 1>&2
82 return $?
85 msgwarn()
87 msg "warning: ${1}" 1>&2
88 return $?
91 msg_help()
93 msg_version
94 echo "
95 This script releases a new FileManager-Actions version.
97 Usage: ${my_cmd} [options]
98 --[no]help print this message, and exit [${opt_help_def}]
99 --[no]version print script version, and exit [${opt_version_def}]
100 --[no]dummy dummy execution [${opt_dummy_def}]
101 --[no]verbose runs verbosely [${opt_verbose_def}]
102 --tarname=<tarname> the tarname to be released [${opt_tarname_def}]
103 --[no]stable whether this is a stable version [${opt_stable_def}]"
106 msg_version()
108 pck_name="$(grep AC_INIT configure.ac | sed -e 's?,.*$??' -e 's?^.*\[\(.*\)\]?\1?')"
109 pck_version=$(grep AC_INIT configure.ac | cut -d, -f2 | sed 's?^.*\[\(.*\)\]?\1?')
110 echo "
111 ${pck_name} v ${pck_version}
112 Copyright (C) 2010, 2011, 2012 Pierre Wieser."
115 # returns version number from a tarball
116 # (E): 1. tarball
117 # (stdout): version number
119 get_version()
121 typeset _f="${1}"
122 typeset _base="${_f##*/}"
123 typeset _version=$(echo ${_base} | sed "s?^.*-\(.*\)\.${sufix}?\1?")
124 echo "${_version}"
127 # is the given tarball is named as a stable version ?
128 # yes if even (0, 2, 4, ...), no if odd
129 # (E): tarball
130 # (stdout) yes/no
132 is_stable()
134 typeset _version="$(get_version ${1})"
135 typeset _minor=$(echo ${_version} | cut -d. -f2)
136 typeset -i _rest
137 if [ -z "${_minor}" ]; then
138 _rest=0
139 else
140 _rest=${_minor}%2
142 typeset _stable
143 [ ${_rest} -eq 0 ] && _stable="yes" || _stable="no"
144 echo "${_stable}"
147 # initialize common command-line options
148 nbopt=$#
149 opt_help=
150 opt_help_def="no"
151 opt_dummy=
152 opt_dummy_def="yes"
153 opt_version=
154 opt_version_def="no"
155 opt_verbose=
156 opt_verbose_def="no"
158 # a first loop over command line arguments to detect verbose mode
159 while :
161 # break when all arguments have been read
162 case $# in
164 break
166 esac
168 # get and try to interpret the next argument
169 _option=$1
170 shift
172 # make all options have two hyphens
173 _orig_option=${_option}
174 case ${_option} in
175 --*)
178 _option=-${_option}
180 esac
182 # now process options and their argument
183 case ${_option} in
184 --noverb | --noverbo | --noverbos | --noverbose)
185 opt_verbose="no"
187 --verb | --verbo | --verbos | --verbose)
188 opt_verbose="yes"
190 esac
191 done
193 [ "${opt_verbose}" = "yes" ] && msg "setting opt_verbose to 'yes'"
195 # we have scanned all command-line arguments in order to detect an
196 # opt_verbose option;
197 # reset now arguments so that they can be scanned again in main script
198 set -- ${my_parms}
200 # interpreting command-line arguments
201 # pck_name: FileManager-Actions
202 # product: filemanager-actions
203 # version: most recent found in builddir
204 thisdir=$(cd ${0%/*}; pwd)
205 rootdir=${thisdir%/*}
206 builddir="${rootdir}/_build"
207 sufix="tar.gz"
208 pck_name="$(grep AC_INIT configure.ac | sed -e 's?,.*$??' -e 's?^.*\[\(.*\)\]?\1?')"
209 product=$(echo ${pck_name} | tr '[:upper:]' '[:lower:]')
210 opt_tarname=
211 f="$(\ls -1 ${builddir}/${product}-*.${sufix} 2>/dev/null | head -1)"
212 opt_tarname_def="$(echo ${f##*/})"
213 version="$(get_version ${opt_tarname_def})"
214 opt_stable=
215 opt_stable_def="$(is_stable ${opt_tarname_def})"
217 # loop over command line arguments
218 pos=0
219 while :
221 # break when all arguments have been read
222 case $# in
224 break
226 esac
228 # get and try to interpret the next argument
229 option=$1
230 shift
232 # make all options have two hyphens
233 orig_option=${option}
234 case ${option} in
235 --*)
238 option=-${option}
240 esac
242 # split and extract argument for options that take one
243 case ${option} in
244 --*=*)
245 optarg=$(echo ${option} | sed -e 's/^[^=]*=//')
246 option=$(echo ${option} | sed 's/=.*//')
248 # these options take a mandatory argument
249 # since, we didn't find it in 'option', so it should be
250 # next word in the command line
251 --t | --ta | --tar | --tarn | --tarna | --tarnam | --tarname)
252 optarg=$1
253 shift
255 esac
257 # now process options and their argument
258 case ${option} in
259 --d | --du | --dum | --dumm | --dummy)
260 [ "${opt_verbose}" = "yes" ] && msg "setting opt_dummy to 'yes'"
261 opt_dummy="yes"
263 --h | --he | --hel | --help)
264 [ "${opt_verbose}" = "yes" ] && msg "setting opt_help to 'yes'"
265 opt_help="yes"
267 --nod | --nodu | --nodum | --nodumm | --nodummy)
268 [ "${opt_verbose}" = "yes" ] && msg "setting opt_dummy to 'no'"
269 opt_dummy="no"
271 --noh | --nohe | --nohel | --nohelp)
272 [ "${opt_verbose}" = "yes" ] && msg "setting opt_help to 'no'"
273 opt_help="no"
275 --nos | --nost | --nosta | --nostab | --nostabl | --nostable)
276 [ "${opt_verbose}" = "yes" ] && msg "setting opt_stable to 'no'"
277 opt_stable="no"
279 --noverb | --noverbo | --noverbos | --noverbose)
281 --novers | --noversi | --noversio | --noversion)
282 [ "${opt_verbose}" = "yes" ] && msg "setting opt_version to 'no'"
283 opt_version="no"
285 --s | --st | --sta | --stab | --stabl | --stable)
286 [ "${opt_verbose}" = "yes" ] && msg "setting opt_stable to 'yes'"
287 opt_stable="yes"
289 --t | --ta | --tar | --tarn | --tarna | --tarnam | --tarname)
290 [ "${opt_verbose}" = "yes" ] && msg "setting opt_tarname to '${optarg}'"
291 opt_tarname="${optarg}"
293 --verb | --verbo | --verbos | --verbose)
295 --vers | --versi | --versio | --version)
296 [ "${opt_verbose}" = "yes" ] && msg "setting opt_version to 'yes'"
297 opt_version="yes"
299 --*)
300 msgerr "unrecognized option: '${orig_option}'"
301 let errs+=1
303 # positional parameters
305 let pos+=1
306 #if [ ${pos} -eq 1 ]; then
307 # [ "${opt_verbose}" = "yes" ] && msg "setting opt_output to '${option}'"
308 # opt_output=${option}
309 #else
310 msgerr "unexpected positional parameter #${pos}: '${option}'"
311 let errs+=1
314 esac
315 done
317 # set option defaults
318 # does not work with /bin/sh ??
319 #set | grep -e '^opt_' | cut -d= -f1 | while read _name; do
320 # if [ "$(echo ${_name} | sed 's/.*\(_def\)/\1/')" != "_def" ]; then
321 # _value="$(eval echo "$"${_name})"
322 # if [ "${_value}" = "" ]; then
323 # eval ${_name}="$(eval echo "$"${_name}_def)"
324 # fi
325 # fi
326 #done
328 opt_help=${opt_help:-${opt_help_def}}
329 opt_dummy=${opt_dummy:-${opt_dummy_def}}
330 opt_verbose=${opt_verbose:-${opt_verbose_def}}
331 opt_version=${opt_version:-${opt_version_def}}
333 # if one forces the tarball without also forcing the 'stable' option
334 # then reconsider the default associated to the forced tarball
335 if [ ! -z ${opt_tarname} -a -z ${opt_stable} ]; then
336 opt_stable="$(is_stable ${opt_tarname})"
338 opt_tarname=${opt_tarname:-${opt_tarname_def}}
339 opt_stable=${opt_stable:-${opt_stable_def}}
341 if [ "${opt_help}" = "yes" -o ${nbopt} -eq 0 ]; then
342 msg_help
343 echo ""
344 exit
347 if [ "${opt_version}" = "yes" ]; then
348 msg_version
349 echo ""
350 exit
353 if [ ! -f "${builddir}/${opt_tarname}" ]; then
354 msgerr "${builddir}/${opt_tarname} not found, do you have 'make distcheck' ?"
355 let errs+=1
358 if [ ${errs} -gt 0 ]; then
359 msg "${errs} error(s) have been detected"
360 msg "try '${my_cmd} --help' for usage"
361 exit
364 # returns the last return code which happens to be the eval one
365 # (E): 1. command to be executed/evaluated/displayed
366 # (return): return code of the command
368 command()
370 typeset _cmd="${1}"
371 typeset -i _ret=0
373 if [ "${opt_dummy}" = "yes" -o "${opt_verbose}" = "yes" ]; then
374 typeset _prefix=""
375 [ "${opt_dummy}" = "yes" ] && _prefix="[dummy] "
376 msg " ${_prefix}${_cmd}..." " "
379 if [ "${opt_dummy}" = "no" ]; then
380 eval ${_cmd}
383 if [ "${opt_verbose}" = "yes" ]; then
384 eval ${_cmd}
385 let _ret=$?
388 if [ "${opt_dummy}" = "yes" -o "${opt_verbose}" = "yes" ]; then
389 [ ${_ret} -eq 0 ] && echo "OK" || echo "NOT OK"
392 let errs+=${_ret}
393 return ${_ret}
396 # ---------------------------------------------------------------------
397 # MAIN CODE
399 [ "${opt_stable}" = "yes" ] && lib_stable="stable" || lib_stable="unstable"
400 msg "releasing ${lib_stable} ${opt_tarname}"
402 msg " are you OK to release (y/N) ?" " "
403 while [ 1 ]; do
404 read -n1 -s key
405 key=$(echo $key | tr '[:upper:]' '[:lower:]')
406 [ "$key" = "y" -o "$key" = "n" -o "$key" = "" ] && break
407 done
408 [ "$key" = "y" ] && echo "Yes" || echo "No"
409 [ "$key" != "y" ] && exit
411 # recomputing version of the released tarball
412 version="$(get_version ${opt_tarname})"
414 # are we local ?
415 destdir="/net/data/free/tarballs/${product}"
416 desthost="stormy.trychlos.org"
417 [ "$(ls ${destdir} 2>/dev/null)" = "" ] && local="no" || local="yes"
418 [ "${local}" = "yes" ] && lib_desthost="" || lib_desthost="${desthost}:"
419 [ "${opt_verbose}" = "yes" ] && msg "stormy tarballs repository is local: ${local}"
421 # installing on stormy tarballs repository
422 msg "installing in ${lib_desthost}${destdir}"
423 cmd="mkdir -p "${destdir}""
424 [ "${local}" = "yes" ] && command "${cmd}" || command "ssh ${desthost} '${cmd}'"
425 command "scp "${builddir}/${opt_tarname}" "${lib_desthost}${destdir}/""
426 cmd="sha1sum ${destdir}/${opt_tarname} > ${destdir}/${opt_tarname}.sha1sum"
427 [ "${local}" = "yes" ] && command "${cmd}" || command "ssh ${desthost} '${cmd}'"
428 if [ "${opt_stable}" = "yes" ]; then
429 msg "updating ${lib_desthost}${destdir}/latest.tar.gz"
430 cmd="(cd ${destdir}; rm -f latest.tar.gz; ln -s ${opt_tarname} latest.tar.gz; ls -l latest.tar.gz ${opt_tarname}*)"
431 [ "${local}" = "yes" ] && command "${cmd}" || command "ssh ${desthost} '${cmd}'"
434 # installing on gnome.org
435 msg "installing on gnome.org"
436 command "scp "${builddir}/${opt_tarname}" pwieser@master.gnome.org:"
437 command "ssh pwieser@master.gnome.org ftpadmin install --unattended ${opt_tarname}"
439 # installing on kimsufi
440 msg "installing on kimsufi"
441 destdir="/home/www/${product}/tarballs"
442 command "scp "${builddir}/${opt_tarname}" maintainer@kimsufi:${destdir}/"
443 command "ssh maintainer@kimsufi 'sha1sum ${destdir}/${opt_tarname} > ${destdir}/${opt_tarname}.sha1sum'"
444 if [ "${opt_stable}" = "yes" ]; then
445 msg "updating kimsufi:${destdir}/latest.tar.gz"
446 command "ssh maintainer@kimsufi 'cd ${destdir}; rm -f latest.tar.gz; ln -s ${opt_tarname} latest.tar.gz; ls -l latest.tar.gz ${opt_tarname}*'"
447 msg "installing manuals on kimsufi"
448 command "ssh maintainer@kimsufi 'tools/kimsufi-install-manuals.sh -nodummy'"
451 # tagging git
452 msg "tagging git"
453 tag="$(echo ${product}-${version} | tr '[:lower:]' '[:upper:]' | sed 's?[-\.]?_?g')"
454 msg="Releasing ${pck_name} ${version}"
455 msg "git tag -s '${tag}' -m '${msg}' (unlock with GPG passphrase)"
456 command "git tag -s '${tag}' -m '${msg}'"
457 command "git pull --rebase && git push && git push --tags"
459 # compressing git local repository
460 msg "compressing local git repository"
461 command "git gc"
463 msg "Successfully ended. You may now send your mail."
465 exit