File: tar.pl

package info (click to toggle)
glgrib 1.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,861,476 kB
  • sloc: cpp: 20,811; ansic: 6,530; perl: 2,902; sh: 513; makefile: 147; python: 58; sql: 18
file content (82 lines) | stat: -rwxr-xr-x 1,459 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl -w

use warnings FATAL => 'all';
use strict;
use FileHandle;
use File::Find;
use File::Path;
use Data::Dumper;
use Cwd;
use File::Temp;
use File::Basename;


sub slurp
{
  my $f = shift;
  my $fh = 'FileHandle'->new ("<$f");
  return '' unless ($fh);
  local $/ = undef; my $data = <$fh>;
  return $data;
}

my ($changelog) = &slurp ("packaging/debian/changelog");

my ($version) = ($changelog =~ m/glgrib\s+\((\S+)-\d+\)/goms);

my ($options) = &slurp ("packaging/debian/source/options");

my ($diff_ignore) = ($options =~ m/diff-ignore\s*=\s*"(\S+)"/goms);

$diff_ignore = qr/$diff_ignore/o;

my @f;

&find ({wanted => sub 
{ 
  my $f = $File::Find::name; 
  return if ($f =~ $diff_ignore); 
  return if ($f =~ m/\.(?:o|so|so\.\d+)$/o);
  return if ($f =~ m,bin/glgrib-(?:glfw|egl),o);
  return if ($f =~ m,blib,o);
  push @f, $f; 
}, no_chdir => 1}, '.');

my %f = map { ($_, 1) } @f;

# Remove intermediate directories

for my $f (@f)
  {
    my @d = split (m,/,o, $f);
    pop (@d);
    while (@d)
      {
        delete $f{join ('/', @d)};
        pop (@d);
      }
  }

@f = sort keys (%f);

my $dir = &basename (&cwd ());

for (@f)
  {
    $_ = 'File::Spec'->catfile ($dir, $_);
  }


chdir ('..');

'FileHandle'->new (">$dir.list")->print (join ("\n", @f, ""));

my @cmd = ('tar', '--verbatim-files-from', "--files-from=$dir.list", -zcvf => "${dir}_$version.orig.tar.gz");

system (@cmd)
  and die ("Command `@cmd' failed\n");