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/>.
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).
44 [ "${opt_verbose}" = "yes" -o ${errs} -gt 0 ] && msg "exiting with code ${errs}"
50 msg
"quitting on keyboard interrupt"
57 [ "${opt_verbose}" = "yes" ] && msg
"quitting on TERM signal"
61 # setup the different trap functions
68 \rm
-f ${my_tmproot}.
*
74 [ $# -ge 2 ] && _eol
="${2}"
75 printf "[%s] %s${_eol}" ${me} "${1}"
81 msg
"error: ${1}" 1>&2
87 msg
"warning: ${1}" 1>&2
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}]"
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?')
111 ${pck_name} v ${pck_version}
112 Copyright (C) 2010, 2011, 2012 Pierre Wieser."
115 # returns version number from a tarball
117 # (stdout): version number
122 typeset _base
="${_f##*/}"
123 typeset _version
=$
(echo ${_base} |
sed "s?^.*-\(.*\)\.${sufix}?\1?")
127 # is the given tarball is named as a stable version ?
128 # yes if even (0, 2, 4, ...), no if odd
134 typeset _version
="$(get_version ${1})"
135 typeset _minor
=$
(echo ${_version} | cut
-d.
-f2)
137 if [ -z "${_minor}" ]; then
143 [ ${_rest} -eq 0 ] && _stable
="yes" || _stable
="no"
147 # initialize common command-line options
158 # a first loop over command line arguments to detect verbose mode
161 # break when all arguments have been read
168 # get and try to interpret the next argument
172 # make all options have two hyphens
173 _orig_option
=${_option}
182 # now process options and their argument
184 --noverb |
--noverbo |
--noverbos |
--noverbose)
187 --verb |
--verbo |
--verbos |
--verbose)
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
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"
208 pck_name
="$(grep AC_INIT configure.ac | sed -e 's?,.*$??' -e 's?^.*\[\(.*\)\]?\1?')"
209 product
=$
(echo ${pck_name} |
tr '[:upper:]' '[:lower:]')
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})"
215 opt_stable_def
="$(is_stable ${opt_tarname_def})"
217 # loop over command line arguments
221 # break when all arguments have been read
228 # get and try to interpret the next argument
232 # make all options have two hyphens
233 orig_option
=${option}
242 # split and extract argument for options that take one
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)
257 # now process options and their argument
259 --d |
--du |
--dum |
--dumm |
--dummy)
260 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_dummy to 'yes'"
263 --h |
--he |
--hel |
--help)
264 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_help to 'yes'"
267 --nod |
--nodu |
--nodum |
--nodumm |
--nodummy)
268 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_dummy to 'no'"
271 --noh |
--nohe |
--nohel |
--nohelp)
272 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_help to 'no'"
275 --nos |
--nost |
--nosta |
--nostab |
--nostabl |
--nostable)
276 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_stable to 'no'"
279 --noverb |
--noverbo |
--noverbos |
--noverbose)
281 --novers |
--noversi |
--noversio |
--noversion)
282 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_version to 'no'"
285 --s |
--st |
--sta |
--stab |
--stabl |
--stable)
286 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_stable to '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'"
300 msgerr
"unrecognized option: '${orig_option}'"
303 # positional parameters
306 #if [ ${pos} -eq 1 ]; then
307 # [ "${opt_verbose}" = "yes" ] && msg "setting opt_output to '${option}'"
308 # opt_output=${option}
310 msgerr
"unexpected positional parameter #${pos}: '${option}'"
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)"
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
347 if [ "${opt_version}" = "yes" ]; then
353 if [ ! -f "${builddir}/${opt_tarname}" ]; then
354 msgerr
"${builddir}/${opt_tarname} not found, do you have 'make distcheck' ?"
358 if [ ${errs} -gt 0 ]; then
359 msg
"${errs} error(s) have been detected"
360 msg
"try '${my_cmd} --help' for usage"
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
373 if [ "${opt_dummy}" = "yes" -o "${opt_verbose}" = "yes" ]; then
375 [ "${opt_dummy}" = "yes" ] && _prefix
="[dummy] "
376 msg
" ${_prefix}${_cmd}..." " "
379 if [ "${opt_dummy}" = "no" ]; then
383 if [ "${opt_verbose}" = "yes" ]; then
388 if [ "${opt_dummy}" = "yes" -o "${opt_verbose}" = "yes" ]; then
389 [ ${_ret} -eq 0 ] && echo "OK" ||
echo "NOT OK"
396 # ---------------------------------------------------------------------
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) ?" " "
405 key
=$
(echo $key |
tr '[:upper:]' '[:lower:]')
406 [ "$key" = "y" -o "$key" = "n" -o "$key" = "" ] && break
408 [ "$key" = "y" ] && echo "Yes" ||
echo "No"
409 [ "$key" != "y" ] && exit
411 # recomputing version of the released tarball
412 version
="$(get_version ${opt_tarname})"
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'"
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
"
463 msg "Successfully ended. You may now send your
mail.
"