/usr/sbin/update-ccache-symlinks is in ccache 3.1.9-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 | #!/usr/bin/perl
use strict;
use warnings FATAL => "all";
my $ccache_dir = "/usr/lib/ccache";
my $old_gcc_dir = "/usr/lib/gcc";
my $new_gcc_dir = "/usr/lib/x86_64-linux-gnu/gcc";
my %old_symlinks; # Current compiler names in /usr/lib/ccache
my %new_symlinks; # Compiler names that should be in /usr/lib/ccache
my @standard_names = qw(cc c++);
sub consider {
my ($name) = @_;
if (-x "/usr/bin/$name") {
$new_symlinks{$name} = 1;
}
}
sub consider_gcc {
my ($prefix, $suffix) = @_;
consider "${prefix}gcc${suffix}";
consider "${prefix}g++${suffix}";
}
# Find existing standard compiler names.
foreach (@standard_names) {
consider $_;
}
# Find existing GCC variants.
consider_gcc "", "";
consider_gcc "c89-", "";
consider_gcc "c99-", "";
foreach my $dir (<$old_gcc_dir/*>, <$new_gcc_dir/*>) {
(my $kind = $dir) =~ s|.*/||;
consider_gcc "$kind-", "";
foreach (<$dir/*>) {
if (! -l $_ and -d $_) {
s|.*/||;
consider_gcc "", "-$_";
consider_gcc "$kind-", "-$_";
}
}
}
# Find existing symlinks.
foreach (<$ccache_dir/*>) {
if (-l) {
s|.*/||;
$old_symlinks{$_} = 1;
}
}
# Remove obsolete symlinks.
foreach (keys %old_symlinks) {
if (! exists $new_symlinks{$_}) {
unlink "$ccache_dir/$_";
}
}
# Add missing symlinks.
foreach (keys %new_symlinks) {
if (! exists $old_symlinks{$_}) {
symlink "../../bin/ccache", "$ccache_dir/$_";
}
}
|