#!/bin/sh -ex

# TODO: implement proper $opt_destdir and $prefix option support

shopt -s nullglob

# note on ./$stage && rm -f $stage are split in two lines:
# -e; if ./$stage fails, we do not get here; ./$stage must be the last for -e to work
set -x

for stage in .git/uupdate/__~.uupdate-step-*.sh ; do
    [ -x $stage ] && ./$stage
    rm -f $stage
done

exit 0


cat <<EOF

=head1	NAME

gear-uupdate-execute - execute gear-uupdate-prepare scripts.

=head1	SYNOPSIS

B<gear-uupdate,gear-uupdate-prepare>
[B<-h,--help>] 
[B<-v,--verbose>]
[B<-q,--quiet>]
[B<--force-unpack>]
[B<--destdir> I<dir>]
[B<--source> I<sourcenum>]
[B<--prefix> I<script prefix>]
[B<--hook> I<path/to/hook>]
[B<--unpack>]
[B<--merge>]
[B<--update-spec>]
[B<--upstream-version> I<new version>]
I<tarball> [ I<new version> ]

=head1	DESCRIPTION

B<gear-uupdate-execute> is an utility to execute scripts generated by
B<gear-uupdate-prepare>.

B<gear-uupdate> updates gear repository from tarball.
It can used manually or together with rpm-uscan. 
B<gear-uupdate> is a wrapper for B<gear-uupdate-prepare> and B<gear-uupdate-execute>.
B<gear-uupdate-prepare> generates scripts and B<gear-uupdate-execute>
executes them.

=head1	OPTIONS

=over

=item	[B<--prefix> I<script prefix>]

Use specified prefix for the scripts.
Default is '__~.uupdate-step-'.

=item	[B<--destdir> I<dir>]

Alternative directory to store generated scripts. 

=item	B<-h, --help>

Display this help and exit.

=back

=head1	SEE ALSO

gear-uupdate-prepare(1), gear-uupdate(1), rpm-uscan(1).

=head1	AUTHOR

Written by Igor Vlasenko <viy@altlinux.org>.

=head1	COPYING

Copyright (c) 2011-2014 Igor Vlasenko, ALT Linux Team.

This is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

=cut

EOF
