File: gen-test-archives.pl

package info (click to toggle)
libalien-build-perl 2.84-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,116 kB
  • sloc: perl: 10,350; ansic: 134; sh: 66; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 918 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
use strict;
use warnings;
use File::Temp qw( tempdir );
use File::chdir;
use Path::Tiny qw( path );
use Capture::Tiny qw( capture_merged );

sub run
{
  my @cmd = @_;

  my($out, $exit) = capture_merged {
    print "+@cmd\n";
    system @cmd;
    $?;
  };
  if($exit)
  {
    print $out;
    print STDERR "command failed\n";
    exit 2;
  }
}

{
  local $CWD = tempdir( CLEANUP => 1 );

  path('xx.txt')->spew("xx\n");

  run 'tar', 'cvf', 'xx.tar', 'xx.txt';
  run 'cp', 'xx.tar', 'xx.tar.bak';
  run 'compress', 'xx.tar';
  run 'mv', 'xx.tar.bak', 'xx.tar';
  run 'gzip', '-k', 'xx.tar';
  run 'bzip2', '-k', 'xx.tar';
  run 'xz', '-k', 'xx.tar';
  run 'zip', 'xx.zip', 'xx.txt';
  run 'rm', '-f', 'xx.txt';

  foreach my $file (sort { $a->basename cmp $b->basename } path('.')->children)
  {
    my $content = $file->slurp_raw;
    print "[ @{[ $file->basename ]} ]\n";
    print pack('u', $content), "\n\n";
  }
}