#!/usr/bin/perl -w

use strict;
use warnings;

use RPM::Source::Transformation::GenericTransformationSet;
use RPM::Source::Transformation::Factory::RaiseRelease;
use RPM::Source::Transformation::GirarNMU;
use RPM::Source::Transformation::Provider::Name2Spec::GirarNMU::Prepare;

our @ISA=qw/RPM::Source::Transform/;

$RPM::Source::Transformation::Factory::RaiseRelease::nextrel='nmuadd';
$RPM::Source::Transformation::Factory::RaiseRelease::defaultchangelog='- rebuild (with the help of girar-nmu utility)';
$RPM::Source::Transformation::Component::GirarNMU::Options::gitbranch='nmu';

our @LONGOPT_POD2USAGE;
our @LONGOPT=(
# TODO: Repo::Pair -- origin, dest ?
    "b|branch=s"   => \$RPM::Source::Transformation::Component::GirarNMU::Options::origin_repo,
    );

my $converter=__PACKAGE__->new();
$converter->transform();


=head1	NAME

girar-nmu-prepare - generate NMU packages according to their upload method.

=head1	SYNOPSIS

B<girar-nmu-prepare>
[B<-h>] 

TODO_insert_pods_here

I<srpmname ...> | I<srpm ...>

=head1	DESCRIPTION

B<girar-nmu-prepare> 
generate NMU packages according to their upload method.
For each package girar-nmu-prepare generate either a git repository with
the NMU commmit or the NMU src.rpm according to the package's upload method.
Each result is stored either as OUT.gits/name.git or OUT.SRPMS/name/*src..rpm.

As an argument girar-nmu-prepare takes either a list of original src.rpms 
or the path to dir with src.rpms in --srpmdir option and a list of names.


=head1	OPTIONS

There are lots of srpm processing options that are inherited from RPM::Source::*
utilities. To view full list of available options, run girar-nmu-prepare --help.

=head2 girar-nmu-prepare specific OPTIONS

=over

=item	B<-b|--branch> I<repository name>

Name of the repository branch. Values are: sisyphus|5.1|p5|..
Default is sisyphus.

=item	B<--ch, --changelog> I<changelog text>

Changelog text. Default is like '- rebuild (with the help of girar-nmu utility)'

=item	B<-d> I<local branch name>

Git repository option.
Name of the local git branch to build from. Default is nmu.

=item	[B<-e, --exact-version>]

Die if version-release of src.rpm and git repository spec file does not match (Default).
Conversely, B<--no-e, --no-exact-version> allows to skip git repository version check.

=item	B<-G> I<dir>

name of output directory with Git repositories.
Default is "OUT.gits".

=item	B<-S> I<dir>

name of output directory for src.rpms.
Default is "OUT.SRPMS".

=item	B<--hashertar>

Generate hasher-ready .tar file instead of src.rpm file.
Some src.rpm require you to install extra rpm-build-* or rpm-macros-* packages
or else rpmbuild -bs --nodeps will fail. On the other hand, generating hasher-ready .tar
file does not require installing rpm-build-* or rpm-macros-* packages, but
this tar file should be first processed in hasher.
Use --hashertar option to avoid polluting your working environment with
unnecessary rpm-build-* or rpm-macros-* packages.

=item	B<-H|--gitery> [I<gitery ssh alias>]

By default, gitery.altlinux.org account should be configured as gitery in ~/.ssh/config.
If you do not follow that convention, use -H <your gitery ssh alias> option.

=item	B<-h, --help>

Display this help and exit.

=back

=head1	AUTHOR

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

=head1	COPYING

Copyright (c) 2010-2021 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

