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

Revision df716c98d203ab64cdf05f9c17fdae565b7daa1c authored by Eelco Dolstra on 23 June 2012, 04:28:35 UTC, committed by Eelco Dolstra on 23 June 2012, 04:28:35 UTC
In chroot builds, use a private network namespace
On Linux it's possible to run a process in its own network namespace,
meaning that it gets its own set of network interfaces, disjunct from
the rest of the system.  We use this to completely remove network
access to chroot builds, except that they get a private loopback
interface.  This means that:

- Builders cannot connect to the outside network or to other processes
  on the same machine, except processes within the same build.

- Vice versa, other processes cannot connect to processes in a chroot
  build, and open ports/connections do not show up in "netstat".

- If two concurrent builders try to listen on the same port (e.g. as
  part of a test), they no longer conflict with each other.

This was inspired by the "PrivateNetwork" flag in systemd.
1 parent 2f3f413
  • Files
  • Changes
  • 517c173
  • /
  • scripts
  • /
  • nix-pull.in
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.

  • revision
  • directory
  • content
revision badge
swh:1:rev:df716c98d203ab64cdf05f9c17fdae565b7daa1c
directory badge
swh:1:dir:d5f371433bd14235182cdc03cc8a5794b97fe4f4
content badge
swh:1:cnt:e59a38eec79fbfc5d9b34e4f85f1d6fe91ae5696

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.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
nix-pull.in
#! @perl@ -w @perlFlags@

use strict;
use File::Temp qw(tempdir);
use Nix::Config;
use Nix::Manifest;

my $tmpDir = tempdir("nix-pull.XXXXXX", CLEANUP => 1, TMPDIR => 1)
    or die "cannot create a temporary directory";

my $manifestDir = $Nix::Config::manifestDir;


# Prevent access problems in shared-stored installations.
umask 0022;


# Create the manifests directory if it doesn't exist.
if (! -e $manifestDir) {
    mkdir $manifestDir, 0755 or die "cannot create directory `$manifestDir'";
}


# Make sure that the manifests directory is scanned for GC roots.
my $gcRootsDir = "$Nix::Config::stateDir/gcroots";
my $manifestDirLink = "$gcRootsDir/manifests";
if (! -l $manifestDirLink) {
    symlink($manifestDir, $manifestDirLink) or die "cannot create symlink `$manifestDirLink'";
}


# Process the URLs specified on the command line.

sub downloadFile {
    my $url = shift;
    $ENV{"PRINT_PATH"} = 1;
    $ENV{"QUIET"} = 1;
    my ($dummy, $path) = `$Nix::Config::binDir/nix-prefetch-url '$url'`;
    die "cannot fetch `$url'" if $? != 0;
    die "nix-prefetch-url did not return a path" unless defined $path;
    chomp $path;
    return $path;
}

sub processURL {
    my $url = shift;

    $url =~ s/\/$//;

    my $manifest;

    my $origUrl = $ENV{'NIX_ORIG_URL'} || $url;

    # First see if a bzipped manifest is available.
    if (system("$Nix::Config::curl --fail --silent --location --head '$url'.bz2 > /dev/null") == 0) {
        print "fetching list of Nix archives at `$url.bz2'...\n";
        $manifest = downloadFile "$url.bz2";
    }

    # Otherwise, just get the uncompressed manifest.
    else {
        print "fetching list of Nix archives at `$url'...\n";
        $manifest = downloadFile $url;
    }

    my $baseName = "unnamed";
    if ($url =~ /\/([^\/]+)\/[^\/]+$/) { # get the forelast component
        $baseName = $1;
    }

    my $hash = `$Nix::Config::binDir/nix-hash --flat '$manifest'`
        or die "cannot hash `$manifest'";
    chomp $hash;

    my $urlFile = "$manifestDir/$baseName-$hash.url";
    open URL, ">$urlFile" or die "cannot create `$urlFile'";
    print URL $origUrl;
    close URL;
    
    my $finalPath = "$manifestDir/$baseName-$hash.nixmanifest";

    unlink $finalPath if -e $finalPath;
        
    symlink("$manifest", "$finalPath")
        or die "cannot link `$finalPath to `$manifest'";

    # Delete all old manifests downloaded from this URL.
    for my $urlFile2 (glob "$manifestDir/*.url") {
        next if $urlFile eq $urlFile2;
        open URL, "<$urlFile2" or die;
        my $url2 = <URL>;
        chomp $url2;
        close URL;
        next unless $origUrl eq $url2;
        my $base = $urlFile2; $base =~ s/.url$//;
        unlink "${base}.url";
        unlink "${base}.nixmanifest";
    }
}

while (@ARGV) {
    my $url = shift @ARGV;
    if ($url eq "--skip-wrong-store") {
        # No-op, no longer supported.
    } else {
        processURL $url;
    }
}


# Update the cache.
updateManifestDB();
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

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