#!/usr/bin/perl -w

use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use File::Basename;

my $verbose=0;
my $help=0;
my $offset=0;

my $result = GetOptions (
    "help"  => \$help,
    'quiet'=> sub {$verbose=0},
    "verbose+"  => \$verbose,
    "offset=i"  => \$offset,
);

if ($help) {
    pod2usage();
}

my @patches;
while (<>) {
    chomp;
    push @patches, $_;
}

print "# ------ generated by debian-patches-series2spec.in ----------\n";
for (my $i=0;$i<@patches;$i++) {print 'Patch',$i+$offset,': ',$patches[$i],"\n"};
print "# ------ end generated by debian-patches-series2spec.in ------\n";
print "# --- generated by debian-patches-series2spec.in -------\n";
for (my $i=0;$i<@patches;$i++) {print '#%patch',$i+$offset,' -p2',"\n"};
print "# --- end generated by debian-patches-series2spec.in ---\n";



=head1	NAME

debian-patches-series2spec.in - generate list of Patch: and %patch directives

=head1	SYNOPSIS

B<debian-patches-series2spec.in>
[B<-h|--help>]
[B<-q|--quiet>]
[B<-v|--verbose>]
[B<--offset> I<N>]

=head1	DESCRIPTION

B<debian-patches-series2spec.in>

=head1	OPTIONS

=over

=item	B<-h, --help>

Display this help and exit.

=item	B<--offset> I<N>

Count patches starting from offset (By default, offset=0, counting from 0).


=item	B<-v, --verbose>, B<-q, --quiet>

Verbosity level. Multiple -v increase the verbosity level, -q sets it to 0.

=back

=head1	AUTHOR

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

=head1	COPYING

Copyright (c) 2009-2020 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
