Factor out repeated scriptlets from build-support/release/*.nix.

This commit is contained in:
Petr Rockai 2012-07-13 20:58:39 +02:00 committed by Peter Simons
parent 1eb5450bd4
commit ce77a5ceec
6 changed files with 27 additions and 40 deletions

View file

@ -100,15 +100,10 @@ stdenv.mkDerivation (
postHook = ''
mkdir -p $out/nix-support
echo "$system" > $out/nix-support/system
. ${./functions.sh}
# If `src' is the result of a call to `makeSourceTarball', then it
# has a subdirectory containing the actual tarball(s). If there are
# multiple tarballs, just pick the first one.
origSrc=$src
if test -d $src/tarballs; then
src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz | sort | head -1)
fi
src=$(findTarballs $src | head -1)
'';
}
)

View file

@ -36,13 +36,8 @@ stdenv.mkDerivation (
mkdir -p $out/nix-support
echo "$system" > $out/nix-support/system
# If `src' is the result of a call to `makeSourceTarball', then it
# has a subdirectory containing the actual tarball(s). If there are
# multiple tarballs, just pick the first one.
origSrc=$src
if test -d $src/tarballs; then
src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz | sort | head -1)
fi
src=$(findTarballs $src | head -1)
if test -e $origSrc/nix-support/hydra-release-name; then
releaseName=$(cat $origSrc/nix-support/hydra-release-name)

View file

@ -30,17 +30,10 @@ vmTools.runInLinuxImage (stdenv.mkDerivation (
# !!! cut&paste from rpm-build.nix
postHook = ''
mkdir -p $out/nix-support
cat "$diskImage"/nix-support/full-name > $out/nix-support/full-name
# If `src' is the result of a call to `makeSourceTarball', then it
# has a subdirectory containing the actual tarball(s). If there are
# multiple tarballs, just pick the first one.
echo $src
if test -d $src/tarballs; then
src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz | sort | head -1)
fi
''; # */
. ${./functions.sh}
propagateImageName
src=$(findTarballs $src | head -1) # Find a tarball.
'';
installExtraDebsPhase = ''
for i in $extraDebs; do

View file

@ -0,0 +1,14 @@
findTarballs() {
local suffix
test -d "$1/tarballs/" && {
for suffix in tar.gz tgz tar.bz2 tbz2 tar.xz tar.lzma; do
ls $1/tarballs/*.$suffix 2> /dev/null
done | sort
}
echo "$1"
}
propagateImageName() {
ensureDir $out/nix-support
cat "$diskImage"/nix-support/full-name > $out/nix-support/full-name
}

View file

@ -58,13 +58,9 @@ stdenv.mkDerivation (
name = name + (if src ? version then "-" + src.version else "");
postHook = ''
# If `src' is the result of a call to `makeSourceTarball', then it
# has a subdirectory containing the actual tarball(s). If there are
# multiple tarballs, just pick the first one.
. ${./functions.sh}
origSrc=$src
if test -d $src/tarballs; then
src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz $src/tarballs/*.tar.xz | sort | head -1)
fi
src=$(findTarballs $src | head -1)
# Set GCC flags for coverage analysis, if desired.
if test -n "${toString doCoverageAnalysis}"; then

View file

@ -14,16 +14,10 @@ vmTools.buildRPM (
name = name + "-" + diskImage.name + (if src ? version then "-" + src.version else "");
preBuild = ''
mkdir -p $out/nix-support
cat "$diskImage"/nix-support/full-name > $out/nix-support/full-name
# If `src' is the result of a call to `makeSourceTarball', then it
# has a subdirectory containing the actual tarball(s). If there are
# multiple tarballs, just pick the first one.
if test -d $src/tarballs; then
src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz | sort | head -1)
fi
''; # */
. ${./functions.sh}
propagateImageName
src=$(findTarballs $src | head -1) # Pick the first tarball.
'';
postInstall = ''
declare -a rpms rpmNames