]> git.donarmstrong.com Git - unscd.git/blob - debian/repack
Merge tag 'upstream/0.49'
[unscd.git] / debian / repack
1 #!/usr/bin/perl
2 # repack repacks unscd upstream tarball
3 # and is released under the terms of the GNU GPL version 3, or any
4 # later version, at your option. See the file README and COPYING for
5 # more information.
6 # Copyright 2013 by Don Armstrong <don@donarmstrong.com>.
7
8
9 use warnings;
10 use strict;
11
12 use Getopt::Long;
13 use Pod::Usage;
14
15 =head1 NAME
16
17 repack - repacks unscd upstream tarball
18
19 =head1 SYNOPSIS
20
21 repack --upstream-version version filename
22
23  Options:
24
25 =head1 OPTIONS
26
27 =over
28
29 =item B<--upstream-version>
30
31 Upstream version
32
33 =back
34
35 =head1 EXAMPLES
36
37 repack --upstream-version 0.48 nscd-0.48.c
38
39 =cut
40
41 use vars qw($DEBUG);
42
43 use Cwd;
44 use File::Temp qw(tempdir);
45
46 my %options = (debug           => 0,
47                help            => 0,
48                man             => 0,
49               );
50
51 GetOptions(\%options,
52            'upstream_version|upstream-version=s',
53           );
54
55 $DEBUG = $options{debug};
56
57 my @USAGE_ERRORS;
58 if (not exists $options{upstream_version}) {
59      push @USAGE_ERRORS,"You must give the  --upstream-version option";
60 }
61 if (@ARGV!=1) {
62      push @USAGE_ERRORS,"You must give exactly one filename on the command line";
63 }
64
65
66 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
67
68
69 my $tdir = tempdir(CLEANUP => 1);
70 my $curdir = getcwd;
71
72 my $orig_dir_name = 'unscd-'.$options{upstream_version};
73 my $orig_dir_path = File::Spec->catfile($tdir,$orig_dir_name);
74 mkdir($orig_dir_path) or die "Unable to mkdir $orig_dir_path: $!";
75 rename($ARGV[0],File::Spec->catfile($orig_dir_path,'nscd.c')) or
76     die "Unable to copy $ARGV[0] to $orig_dir_path/nscd.c: $!";
77 system('tar','-zcf',File::Spec->catfile($curdir,
78                                         File::Spec->updir(),
79                                         'unscd_'.$options{upstream_version}.'.orig.tar.gz'),
80        '-C',$tdir,$orig_dir_name) == 0 or
81     die "Tar failed";
82
83 __END__
84