]> git.donarmstrong.com Git - unscd.git/blob - debian/repack
Migrate to salsa (with donarmstrong.com as a backup)
[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 use File::Copy qw(copy);
46
47 my %options = (debug           => 0,
48                help            => 0,
49                man             => 0,
50               );
51
52 GetOptions(\%options,
53            'upstream_version|upstream-version=s',
54           );
55
56 $DEBUG = $options{debug};
57
58 my @USAGE_ERRORS;
59 if (not exists $options{upstream_version}) {
60      push @USAGE_ERRORS,"You must give the  --upstream-version option";
61 }
62 if (@ARGV!=1) {
63      push @USAGE_ERRORS,"You must give exactly one filename on the command line";
64 }
65
66
67 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
68
69
70 my $tdir = tempdir(CLEANUP => 1);
71 my $curdir = getcwd;
72
73 my $orig_dir_name = 'unscd-'.$options{upstream_version};
74 my $orig_dir_path = File::Spec->catfile($tdir,$orig_dir_name);
75 mkdir($orig_dir_path) or die "Unable to mkdir $orig_dir_path: $!";
76 copy($ARGV[0],File::Spec->catfile($orig_dir_path,'nscd.c')) or
77     die "Unable to copy $ARGV[0] to $orig_dir_path/nscd.c: $!";
78 system('tar','-zcf',File::Spec->catfile($curdir,
79                                         File::Spec->updir(),
80                                         'unscd_'.$options{upstream_version}.'.orig.tar.gz'),
81        '-C',$tdir,$orig_dir_name) == 0 or
82     die "Tar failed";
83
84 __END__
85