/usr/bin/qtar is in hxtools 20170430-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | #!/usr/bin/perl
#
# quicker tar + better defaults
# written by Jan Engelhardt, 2007-2010
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the WTF Public License version 2 or
# (at your option) any later version.
#
# Achieves higher compression by using dedicated file sorting
# to put similar blocks next to each other.
#
use File::Find;
use Getopt::Long;
use IPC::Open2;
use strict;
my @excludes = ();
my $strategy = "by_normal";
my $packer = undef;
my @result;
&main();
sub main
{
Getopt::Long::Configure(qw(bundling pass_through));
GetOptions(
"x" => sub { push(@excludes, qr{(?:^|/)(?:\.git|\.svn|\.bzr|\.hg|CVS)(?:/|$)}); },
"svn" => sub { $strategy = "by_basename"; }, # lame alias I agree
"ext" => sub { $strategy = "by_extension"; },
"use=s" => sub { $packer = $_[1]; },
);
if (scalar(@ARGV) == 0) {
die "No output file. What gives?\n";
}
my $archive = shift @ARGV;
if (!defined($packer)) {
if (substr($archive, -3, 3) eq ".xz" ||
substr($archive, -4, 4) eq ".txz") {
$packer = "xz";
} elsif (substr($archive, -4, 4) eq ".bz2" ||
substr($archive, -5, 5) eq ".tbz2") {
$packer = "bzip2";
} elsif (substr($archive, -3, 3) eq ".gz" ||
substr($archive, -4, 4) eq ".tgz") {
$packer = "gzip";
} elsif (substr($archive, -4, 4) eq ".tar") {
$packer = undef;
} else {
$packer = "lzip";
}
}
my @targets = grep(/^[^-]/, @ARGV);
if (scalar(@targets) == 0) {
die "No input directories. What gives?\n";
}
foreach (@targets) {
if (!-e $_) {
warn "WARNING: Cannot find \"$_\": $!\n";
}
}
File::Find::find({
wanted => \&collect,
no_chdir => 1,
}, @targets);
@ARGV = grep /^-/, @ARGV;
@result = sort $strategy @result;
&push_files($archive, \@result, \@ARGV);
}
sub by_normal
{
return $a cmp $b;
}
sub by_basename
{
my($p, $q) = ($a, $b);
if (-d $p && !-d $q) {
return -1;
}
if (!-d $p && -d $q) {
return 1;
}
$p =~ s{.*/}{}g;
$q =~ s{.*/}{}g;
return $p cmp $q;
}
sub by_extension
{
my($p, $q) = ($a, $b);
if (-d $p && !-d $q) {
return -1;
}
if (!-d $p && -d $q) {
return 1;
}
if (-d $p && -d $q) {
return &by_basename();
}
# Both are files:
$p =~ s{.*\.(\w+)$}{$1};
$q =~ s{.*\.(\w+)$}{$1};
if ($p ne $q) {
return $p cmp $q;
}
# Same extension
return &by_basename();
}
sub collect
{
foreach my $regex (@excludes) {
if ($_ =~ $regex) {
return;
}
}
push(@result, $_);
}
sub push_files
{
local *COUT;
my @args = (
"tar", "--no-recursion", "--null", "-T-",
defined($packer) ? "--use=$packer" : (),
"--owner=root", "--group=root",
"-cvf", $_[0], @{$_[2]},
);
if (!open(\*COUT, "|-", @args)) {
die "Could not run tar: $!\n";
}
print COUT join("\x00", @{$_[1]});
close COUT;
return 0;
}
|