File: repack

package info (click to toggle)
unscd 0.51-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 304 kB
  • ctags: 711
  • sloc: ansic: 5,719; sh: 83; perl: 35; makefile: 12
file content (84 lines) | stat: -rw-r--r-- 1,850 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl
# repack repacks unscd upstream tarball
# and is released under the terms of the GNU GPL version 3, or any
# later version, at your option. See the file README and COPYING for
# more information.
# Copyright 2013 by Don Armstrong <don@donarmstrong.com>.


use warnings;
use strict;

use Getopt::Long;
use Pod::Usage;

=head1 NAME

repack - repacks unscd upstream tarball

=head1 SYNOPSIS

repack --upstream-version version filename

 Options:

=head1 OPTIONS

=over

=item B<--upstream-version>

Upstream version

=back

=head1 EXAMPLES

repack --upstream-version 0.48 nscd-0.48.c

=cut

use vars qw($DEBUG);

use Cwd;
use File::Temp qw(tempdir);

my %options = (debug           => 0,
               help            => 0,
               man             => 0,
              );

GetOptions(\%options,
           'upstream_version|upstream-version=s',
          );

$DEBUG = $options{debug};

my @USAGE_ERRORS;
if (not exists $options{upstream_version}) {
     push @USAGE_ERRORS,"You must give the  --upstream-version option";
}
if (@ARGV!=1) {
     push @USAGE_ERRORS,"You must give exactly one filename on the command line";
}


pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;


my $tdir = tempdir(CLEANUP => 1);
my $curdir = getcwd;

my $orig_dir_name = 'unscd-'.$options{upstream_version};
my $orig_dir_path = File::Spec->catfile($tdir,$orig_dir_name);
mkdir($orig_dir_path) or die "Unable to mkdir $orig_dir_path: $!";
rename($ARGV[0],File::Spec->catfile($orig_dir_path,'nscd.c')) or
    die "Unable to copy $ARGV[0] to $orig_dir_path/nscd.c: $!";
system('tar','-zcf',File::Spec->catfile($curdir,
                                        File::Spec->updir(),
                                        'unscd_'.$options{upstream_version}.'.orig.tar.gz'),
       '-C',$tdir,$orig_dir_name) == 0 or
    die "Tar failed";

__END__