Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
content badge
swh:1:cnt:0604c6696c7a9582dd2d250db1dd05d072bbe659

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
(requires biblatex-software package)
Generating citation ...
#! /usr/bin/perl -w

if (scalar @ARGV != 1) {
    print "syntax: show-duplication.pl PATH\n";
    exit 1;
}

my $root = $ARGV[0];


my $nameRE = "(?:(?:[A-Za-z0-9\+\_]|(?:-[^0-9]))+)";
my $versionRE = "(?:[A-Za-z0-9\.\-]+)";


my %pkgInstances;


my $pid = open(PATHS, "-|") || exec "nix-store", "-qR", $root;
while (<PATHS>) {
    chomp;
    /^.*\/[0-9a-z]*-(.*)$/;
    my $nameVersion = $1;
    $nameVersion =~ /^($nameRE)(-($versionRE))?$/;
    $name = $1;
    $version = $3;
    $version = "(unnumbered)" unless defined $version;
#    print "$nameVersion $name $version\n";
    push @{$pkgInstances{$name}}, {version => $version, path => $_};
}
close PATHS or exit 1;


sub pathSize {
    my $path = shift;
    my @st = lstat $path or die;

    my $size = $st[7];

    if (-d $path) {
        opendir DIR, $path or die;
        foreach my $name (readdir DIR) {
            next if $name eq "." || $name eq "..";
            $size += pathSize("$path/$name");
        }
    }
    
    return $size;
}


my $totalPaths = 0;
my $totalSize = 0, $totalWaste = 0;

foreach my $name (sort {scalar @{$pkgInstances{$b}} <=> scalar @{$pkgInstances{$a}}} (keys %pkgInstances)) {
    print "$name ", scalar @{$pkgInstances{$name}}, "\n";
    my $allSize = 0;
    foreach my $x (sort {$a->{version} cmp $b->{version}} @{$pkgInstances{$name}}) {
        $totalPaths++;
        my $size = pathSize $x->{path};
        $allSize += $size;
        print "    $x->{version} $size\n";
    }
    my $avgSize = int($allSize / scalar @{$pkgInstances{$name}});
    my $waste = $allSize - $avgSize;
    $totalSize += $allSize;
    $totalWaste += $waste;
    print "    average $avgSize, waste $waste\n";
}


my $avgDupl = $totalPaths / scalar (keys %pkgInstances);
my $wasteFactor = ($totalWaste / $totalSize) * 100;
print "average package duplication $avgDupl, total size $totalSize, total waste $totalWaste, $wasteFactor% wasted\n";

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API