-
Notifications
You must be signed in to change notification settings - Fork 12
/
mktar.pl
executable file
·44 lines (37 loc) · 1.12 KB
/
mktar.pl
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
#! /usr/bin/perl -w
#
# create a tar ball snapshot from cvs repository.
#
# 2005-12-15, jw
#
use Data::Dumper;
my $srcdir = 'src';
my $version_file = "$srcdir/patchlevel.h";
my %symlinks =
(
'FAQ' => 'doc/FAQ',
'doc/install.sh' => '../install.sh'
);
for my $l (keys %symlinks)
{
my $ll = "$srcdir/$l";
next if -l $ll;
print "replacing $ll with a symlink to $symlinks{$l}\n";
unlink $ll;
symlink $symlinks{$l}, $ll;
}
my %version;
open IN, "<", $version_file or die "unable to read $version_file: $!";
while (defined(my $line = <IN>))
{
$version{$1} = (defined $3) ? $3 : $4 if $line =~ m{^#\s*define\s+(\w+)\s+("([^"]*)"|(\S+))};
}
close IN;
my $version = "$version{REV}.$version{VERS}.$version{PATCHLEVEL}";
my $tmpdir = "/tmp/mktar-$^T";
mkdir $tmpdir or die "cannot mkdir $tmpdir: $!";
system "cp -a $srcdir $tmpdir" and die "'cp -a $srcdir $tmpdir' failed: $!";
rename "$tmpdir/$srcdir", "$tmpdir/screen-$version" or die "rename to screen-$version failed: $!";
system "tar zcf - -C $tmpdir > screen-$version.tar.gz screen-$version";
system "rm -rf $tmpdir";
print "screen-$version.tar.gz written.\n";