From 93efdb400a3f6cbd0920dfb13fd01e66abad5dab Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 11 Jul 2004 18:52:25 +0000 Subject: [PATCH] * Log support in the generic builder. Just set $logPhases to 1 and it will write the output of each phase to a separate log file in $out/log/. svn path=/nixpkgs/trunk/; revision=1152 --- pkgs/stdenv/generic-branch/setup.sh | 59 +++++++++++++++++++++--- pkgs/stdenv/nix-linux-branch/default.nix | 20 ++++++++ pkgs/stdenv/nix-linux-branch/prehook.sh | 1 + pkgs/system/stdenvs.nix | 2 +- 4 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 pkgs/stdenv/nix-linux-branch/default.nix create mode 100644 pkgs/stdenv/nix-linux-branch/prehook.sh diff --git a/pkgs/stdenv/generic-branch/setup.sh b/pkgs/stdenv/generic-branch/setup.sh index 072dea3bef36..44d6ec58c546 100644 --- a/pkgs/stdenv/generic-branch/setup.sh +++ b/pkgs/stdenv/generic-branch/setup.sh @@ -168,6 +168,44 @@ closeNest() { trap "closeNest" EXIT +# Ensure that the given directory exists. +ensureDir() { + local dir=$1 + if ! test -x "$dir"; then mkdir -p "$dir"; fi +} + + +# Redirect stdout/stderr to a `tee' process that writes the specified +# file (and also to our original stdout). This requires bash. The +# original stdout is saved in descriptor 3. +startLog() { + local logFile=${logNr}_$1 + logNr=$((logNr + 1)) + if test "$logPhases" = 1; then + ensureDir $logDir + exec 3>&1 + if test "$dontLogThroughTee" != 1; then + eval "exec > >(tee $logDir/$logFile) 2>&1" + else + exec > $logDir/$logFile 2>&1 + fi + fi +} + +if test -z "$logDir"; then + logDir=$out/log +fi + +logNr=0 + +# Restore the original stdout/stderr. +stopLog() { + if test "$logPhases" = 1; then + exec >&3 2>&1 + fi +} + + # Utility function: return the base name of the given path, with the # prefix `HASH-' removed, if present. stripHash() { @@ -178,13 +216,6 @@ stripHash() { } -# Ensure that the given directory exists. -ensureDir() { - local dir=$1 - if ! test -x "$dir"; then mkdir "$dir"; fi -} - - unpackFile() { local file=$1 local cmd @@ -287,7 +318,9 @@ unpackW() { unpackPhase() { header "unpacking sources" + startLog "unpack" unpackW + stopLog stopNest } @@ -309,7 +342,9 @@ patchW() { patchPhase() { if test -z "$patchPhase" -a -z "$patches"; then return; fi header "patching sources" + startLog "patch" patchW + stopLog stopNest } @@ -368,7 +403,9 @@ configureW() { configurePhase() { header "configuring" + startLog "configure" configureW + stopLog stopNest } @@ -389,7 +426,9 @@ buildPhase() { return fi header "building" + startLog "build" buildW + stopLog stopNest } @@ -414,7 +453,9 @@ checkPhase() { return fi header "checking" + startLog "check" checkW + stopLog stopNest } @@ -457,7 +498,9 @@ installPhase() { return fi header "installing" + startLog "install" installW + stopLog stopNest } @@ -495,7 +538,9 @@ distPhase() { return fi header "creating distribution" + startLog "dist" distW + stopLog stopNest } diff --git a/pkgs/stdenv/nix-linux-branch/default.nix b/pkgs/stdenv/nix-linux-branch/default.nix new file mode 100644 index 000000000000..6b25ea7dc28c --- /dev/null +++ b/pkgs/stdenv/nix-linux-branch/default.nix @@ -0,0 +1,20 @@ +{stdenv, glibc, pkgs, genericStdenv, gccWrapper}: + +genericStdenv { + name = "stdenv-nix-linux"; + preHook = ./prehook.sh; + initialPath = (import ../nix/path.nix) {pkgs = pkgs;}; + + inherit stdenv; + + gcc = gccWrapper { + name = pkgs.gcc.name; + nativeTools = false; + nativeGlibc = false; + inherit (pkgs) gcc binutils; + inherit stdenv glibc; + shell = pkgs.bash ~ /bin/sh; + }; + + shell = pkgs.bash ~ /bin/bash; +} diff --git a/pkgs/stdenv/nix-linux-branch/prehook.sh b/pkgs/stdenv/nix-linux-branch/prehook.sh new file mode 100644 index 000000000000..08bb6c0332c9 --- /dev/null +++ b/pkgs/stdenv/nix-linux-branch/prehook.sh @@ -0,0 +1 @@ +export NIX_ENFORCE_PURITY=1 diff --git a/pkgs/system/stdenvs.nix b/pkgs/system/stdenvs.nix index fb3c08967fb2..23bfa3c20ae1 100644 --- a/pkgs/system/stdenvs.nix +++ b/pkgs/system/stdenvs.nix @@ -150,7 +150,7 @@ # Testing the new stdenv-linux (TODO: remove this eventually). - stdenvLinuxTest = (import ../stdenv/nix-linux) { + stdenvLinuxTest = (import ../stdenv/nix-linux-branch) { stdenv = stdenvLinuxBoot2; pkgs = stdenvLinuxBoot2Pkgs; glibc = stdenvLinuxGlibc;