uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead

https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948
this can do it nicely.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
Anton Arapov 2021-04-03 12:58:10 +02:00 committed by Alan Daniels
commit 56de2bcd43
30691 changed files with 3076956 additions and 0 deletions

View file

@ -0,0 +1,78 @@
/* This function builds a binary tarball. The resulting binaries are
usually only useful if they are don't have any runtime dependencies
on any paths in the Nix store, since those aren't distributed in
the tarball. For instance, the binaries should be statically
linked: they can't depend on dynamic libraries in the store
(including Glibc).
The binaries are built and installed with a prefix of /usr/local by
default. They are installed by setting DESTDIR to a temporary
directory, so the Makefile of the package should support DESTDIR.
*/
{ src, stdenv
, name ? "binary-tarball"
, ... } @ args:
stdenv.mkDerivation (
{
# Also run a `make check'.
doCheck = true;
showBuildStats = true;
prefix = "/usr/local";
postPhases = "finalPhase";
}
// args //
{
name = name + (if src ? version then "-" + src.version else "");
postHook = ''
mkdir -p $out/nix-support
echo "$system" > $out/nix-support/system
. ${./functions.sh}
origSrc=$src
src=$(findTarball $src)
if test -e $origSrc/nix-support/hydra-release-name; then
releaseName=$(cat $origSrc/nix-support/hydra-release-name)
fi
installFlagsArray=(DESTDIR=$TMPDIR/inst)
# Prefix hackery because of a bug in stdenv (it tries to `mkdir
# $prefix', which doesn't work due to the DESTDIR).
configureFlags="--prefix=$prefix $configureFlags"
dontAddPrefix=1
prefix=$TMPDIR/inst$prefix
'';
doDist = true;
distPhase = ''
mkdir -p $out/tarballs
tar cvfj $out/tarballs/''${releaseName:-binary-dist}.tar.bz2 -C $TMPDIR/inst .
'';
finalPhase = ''
for i in $out/tarballs/*; do
echo "file binary-dist $i" >> $out/nix-support/hydra-build-products
done
# Propagate the release name of the source tarball. This is
# to get nice package names in channels.
test -n "$releaseName" && (echo "$releaseName" >> $out/nix-support/hydra-release-name)
'';
meta = (if args ? meta then args.meta else {}) // {
description = "Build of a generic binary distribution";
};
}
)

View file

@ -0,0 +1,96 @@
# This function compiles a source tarball in a virtual machine image
# that contains a Debian-like (i.e. dpkg-based) OS.
{ name ? "debian-build"
, diskImage
, src, lib, stdenv, vmTools, checkinstall
, fsTranslation ? false
, # Features provided by this package.
debProvides ? []
, # Features required by this package.
debRequires ? []
, ... } @ args:
vmTools.runInLinuxImage (stdenv.mkDerivation (
{
doCheck = true;
prefix = "/usr";
prePhases = "installExtraDebsPhase sysInfoPhase";
}
// removeAttrs args ["vmTools" "lib"] //
{
name = name + "-" + diskImage.name + (if src ? version then "-" + src.version else "");
# !!! cut&paste from rpm-build.nix
postHook = ''
. ${./functions.sh}
propagateImageName
src=$(findTarball $src)
'';
installExtraDebsPhase = ''
for i in $extraDebs; do
dpkg --install $(ls $i/debs/*.deb | sort | head -1)
done
'';
sysInfoPhase = ''
[ ! -f /etc/lsb-release ] || (source /etc/lsb-release; echo "OS release: $DISTRIB_DESCRIPTION")
echo "System/kernel: $(uname -a)"
if test -e /etc/debian_version; then echo "Debian release: $(cat /etc/debian_version)"; fi
header "installed Debian packages"
dpkg-query --list
stopNest
'';
installPhase = ''
eval "$preInstall"
export LOGNAME=root
# otherwise build hangs when it wants to display
# the log file
export PAGER=cat
${checkinstall}/sbin/checkinstall --nodoc -y -D \
--fstrans=${if fsTranslation then "yes" else "no"} \
--requires="${lib.concatStringsSep "," debRequires}" \
--provides="${lib.concatStringsSep "," debProvides}" \
${if (src ? version) then "--pkgversion=$(echo ${src.version} | tr _ -)"
else "--pkgversion=0.0.0"} \
''${debMaintainer:+--maintainer="'$debMaintainer'"} \
''${debName:+--pkgname="'$debName'"} \
$checkInstallFlags \
-- \
$SHELL -c "''${installCommand:-make install}"
mkdir -p $out/debs
find . -name "*.deb" -exec cp {} $out/debs \;
[ "$(echo $out/debs/*.deb)" != "" ]
for i in $out/debs/*.deb; do
header "Generated DEB package: $i"
dpkg-deb --info "$i"
pkgName=$(dpkg-deb -W "$i" | awk '{print $1}')
echo "file deb $i" >> $out/nix-support/hydra-build-products
stopNest
done
dpkg -i $out/debs/*.deb
for i in $extraDebs; do
echo "file deb-extra $(ls $i/debs/*.deb | sort | head -1)" >> $out/nix-support/hydra-build-products
done
eval "$postInstall"
'';
meta = (if args ? meta then args.meta else {}) // {
description = "Deb package for ${diskImage.fullName}";
};
}
))

View file

@ -0,0 +1,120 @@
{ lib, pkgs }:
with pkgs;
rec {
sourceTarball = args: import ./source-tarball.nix (
{ inherit stdenv autoconf automake libtool;
} // args);
makeSourceTarball = sourceTarball; # compatibility
binaryTarball = args: import ./binary-tarball.nix (
{ inherit stdenv;
} // args);
mvnBuild = args: import ./maven-build.nix (
{ inherit stdenv;
} // args);
nixBuild = args: import ./nix-build.nix (
{ inherit lib stdenv;
} // args);
coverageAnalysis = args: nixBuild (
{ inherit lcov enableGCOVInstrumentation makeGCOVReport;
doCoverageAnalysis = true;
} // args);
clangAnalysis = args: nixBuild (
{ inherit clang-analyzer;
doClangAnalysis = true;
} // args);
coverityAnalysis = args: nixBuild (
{ inherit cov-build xz;
doCoverityAnalysis = true;
} // args);
rpmBuild = args: import ./rpm-build.nix (
{ inherit vmTools;
} // args);
debBuild = args: import ./debian-build.nix (
{ inherit lib stdenv vmTools checkinstall;
} // args);
aggregate =
{ name, constituents, meta ? { } }:
pkgs.runCommand name
{ inherit constituents meta;
preferLocalBuild = true;
_hydraAggregate = true;
}
''
mkdir -p $out/nix-support
touch $out/nix-support/hydra-build-products
echo $constituents > $out/nix-support/hydra-aggregate-constituents
# Propagate build failures.
for i in $constituents; do
if [ -e $i/nix-support/failed ]; then
touch $out/nix-support/failed
fi
done
'';
/* Create a channel job which success depends on the success of all of
its contituents. Channel jobs are a special type of jobs that are
listed in the channel tab of Hydra and that can be suscribed.
A tarball of the src attribute is distributed via the channel.
- constituents: a list of derivations on which the channel success depends.
- name: the channel name that will be used in the hydra interface.
- src: should point to the root folder of the nix-expressions used by the
channel, typically a folder containing a `default.nix`.
channel {
constituents = [ foo bar baz ];
name = "my-channel";
src = ./.;
};
*/
channel =
{ name, src, constituents ? [], meta ? {}, isNixOS ? true, ... }@args:
stdenv.mkDerivation ({
preferLocalBuild = true;
_hydraAggregate = true;
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
patchPhase = lib.optionalString isNixOS ''
touch .update-on-nixos-rebuild
'';
installPhase = ''
mkdir -p $out/{tarballs,nix-support}
tar cJf "$out/tarballs/nixexprs.tar.xz" \
--owner=0 --group=0 --mtime="1970-01-01 00:00:00 UTC" \
--transform='s!^\.!${name}!' .
echo "channel - $out/tarballs/nixexprs.tar.xz" > "$out/nix-support/hydra-build-products"
echo $constituents > "$out/nix-support/hydra-aggregate-constituents"
# Propagate build failures.
for i in $constituents; do
if [ -e "$i/nix-support/failed" ]; then
touch "$out/nix-support/failed"
fi
done
'';
meta = meta // {
isHydraChannel = true;
};
} // removeAttrs args [ "meta" ]);
}

View file

@ -0,0 +1,17 @@
findTarball() {
local suffix i
if [ -d "$1/tarballs/" ]; then
for suffix in tar.gz tgz tar.bz2 tbz2 tbz tar.xz txz tar.lzma; do
for i in $1/tarballs/*.$suffix; do echo $i; break; done
done | sort | head -1
return
else
echo "$1"
return
fi
}
propagateImageName() {
mkdir -p $out/nix-support
cat "$diskImage"/nix-support/full-name > $out/nix-support/full-name
}

View file

@ -0,0 +1,98 @@
{ stdenv
, name
, src
, doTest ? true
, doTestCompile ? true
, doJavadoc ? false
, doCheckstyle ? false
, doRelease ? false
, includeTestClasses ? true
, extraMvnFlags ? ""
, ...
} @ args :
let
mvnFlags = "-Dmaven.repo.local=$M2_REPO ${if doTest then "" else "-Dmaven.test.skip.exec=true"} ${extraMvnFlags}";
in
stdenv.mkDerivation ( {
inherit name src;
phases = "setupPhase unpackPhase patchPhase mvnCompile ${if doTestCompile then "mvnTestCompile mvnTestJar" else ""} ${if doTest then "mvnTest" else ""} ${if doJavadoc then "mvnJavadoc" else ""} ${if doCheckstyle then "mvnCheckstyle" else ""} mvnJar mvnAssembly mvnRelease finalPhase";
setupPhase = ''
runHook preSetupPhase
mkdir -p $out/nix-support
export LANG="en_US.UTF-8"
export LOCALE_ARCHIVE=$glibcLocales/lib/locale/locale-archive
export M2_REPO=$TMPDIR/repository
runHook postSetupPhase
'';
mvnCompile = ''
mvn compile ${mvnFlags}
'';
mvnTestCompile = ''
mvn test-compile ${mvnFlags}
'';
mvnTestJar = ''
mvn jar:test-jar ${mvnFlags}
'';
mvnTest = ''
mvn test ${mvnFlags}
if [ -d target/site/cobertura ] ; then
echo "report coverage $out/site/cobertura" >> $out/nix-support/hydra-build-products
fi
if [ -d target/surefire-reports ] ; then
mvn surefire-report:report-only
echo "report coverage $out/site/surefire-report.html" >> $out/nix-support/hydra-build-products
fi
'';
mvnJavadoc = ''
mvn javadoc:javadoc ${mvnFlags}
echo "report javadoc $out/site/apidocs" >> $out/nix-support/hydra-build-products
'';
mvnCheckstyle = ''
mvn checkstyle:checkstyle ${mvnFlags}
echo "report checkstyle $out/site/checkstyle.html" >> $out/nix-support/hydra-build-products
'';
mvnJar = ''
mvn jar:jar ${mvnFlags}
'';
mvnAssembly = ''
mvn assembly:assembly -Dmaven.test.skip=true ${mvnFlags}
'';
mvnRelease = ''
mkdir -p $out/release
zip=$(ls target/*.zip| head -1)
releaseName=$(basename $zip .zip)
releaseName="$releaseName-r${toString src.rev or "0"}"
cp $zip $out/release/$releaseName.zip
echo "$releaseName" > $out/nix-support/hydra-release-name
${if doRelease then ''
echo "file zip $out/release/$releaseName.zip" >> $out/nix-support/hydra-build-products
'' else ""}
'';
finalPhase = ''
if [ -d target/site ] ; then
cp -R target/site $out/
echo "report site $out/site" >> $out/nix-support/hydra-build-products
fi
'';
} // args
)

View file

@ -0,0 +1,175 @@
# This function builds and tests an Autoconf-style source tarball.
# The result can be installed normally in an environment (e.g., after
# making it available through a channel). If `doCoverageAnalysis' is
# true, it does an ordinary build from a source tarball, except that
# it turns on GCC's coverage analysis feature. It then runs `make
# check' and produces a coverage analysis report using `lcov'.
{ buildOutOfSourceTree ? false
, preConfigure ? null
, doCoverageAnalysis ? false
, doClangAnalysis ? false
, doCoverityAnalysis ? false
, lcovFilter ? []
, lcovExtraTraceFiles ? []
, src, lib, stdenv
, name ? if doCoverageAnalysis then "nix-coverage" else "nix-build"
, failureHook ? null
, prePhases ? []
, postPhases ? []
, buildInputs ? []
, preHook ? ""
, postHook ? ""
, ... } @ args:
let
doingAnalysis = doCoverageAnalysis || doClangAnalysis || doCoverityAnalysis;
in
stdenv.mkDerivation (
{
# Also run a `make check'.
doCheck = true;
# When doing coverage analysis, we don't care about the result.
dontInstall = doingAnalysis;
useTempPrefix = doingAnalysis;
showBuildStats = true;
finalPhase =
''
# Propagate the release name of the source tarball. This is
# to get nice package names in channels.
if test -e $origSrc/nix-support/hydra-release-name; then
cp $origSrc/nix-support/hydra-release-name $out/nix-support/hydra-release-name
fi
# Package up Coverity analysis results
if [ ! -z "${toString doCoverityAnalysis}" ]; then
if [ -d "_coverity_$name/cov-int" ]; then
mkdir -p $out/tarballs
NAME=`cat $out/nix-support/hydra-release-name`
cd _coverity_$name
tar caf $out/tarballs/$NAME-coverity-int.xz cov-int
echo "file cov-build $out/tarballs/$NAME-coverity-int.xz" >> $out/nix-support/hydra-build-products
fi
fi
# Package up Clang analysis results
if [ ! -z "${toString doClangAnalysis}" ]; then
if [ ! -z "`ls _clang_analyze_$name`" ]; then
cd _clang_analyze_$name && mv * $out/analysis
else
mkdir -p $out/analysis
echo "No bugs found." >> $out/analysis/index.html
fi
echo "report analysis $out/analysis" >> $out/nix-support/hydra-build-products
fi
'';
failureHook = (lib.optionalString (failureHook != null) failureHook) +
''
if test -n "$succeedOnFailure"; then
if test -n "$keepBuildDirectory"; then
KEEPBUILDDIR="$out/`basename $TMPDIR`"
header "Copying build directory to $KEEPBUILDDIR"
mkdir -p $KEEPBUILDDIR
cp -R "$TMPDIR/"* $KEEPBUILDDIR
stopNest
fi
fi
'';
}
// removeAttrs args [ "lib" ] # Propagating lib causes the evaluation to fail, because lib is a function that can't be converted to a string
// {
name = name + (if src ? version then "-" + src.version else "");
postHook = ''
. ${./functions.sh}
origSrc=$src
src=$(findTarball $src)
${postHook}
'';
preHook = ''
# Perform Coverity Analysis
if [ ! -z "${toString doCoverityAnalysis}" ]; then
shopt -s expand_aliases
mkdir _coverity_$name
alias make="cov-build --dir _coverity_$name/cov-int make"
fi
# Perform Clang Analysis
if [ ! -z "${toString doClangAnalysis}" ]; then
shopt -s expand_aliases
alias make="scan-build -o _clang_analyze_$name --html-title='Scan results for $name' make"
fi
${preHook}
'';
# Clean up after analysis
postBuild = ''
if [ ! -z "${toString (doCoverityAnalysis || doClangAnalysis)}" ]; then
unalias make
fi
'';
initPhase = ''
mkdir -p $out/nix-support
echo "$system" > $out/nix-support/system
if [ -z "${toString doingAnalysis}" ]; then
for i in $outputs; do
if [ "$i" = out ]; then j=none; else j="$i"; fi
mkdir -p ''${!i}/nix-support
echo "nix-build $j ''${!i}" >> ''${!i}/nix-support/hydra-build-products
done
fi
'';
prePhases = ["initPhase"] ++ prePhases;
buildInputs =
buildInputs ++
(lib.optional doCoverageAnalysis args.makeGCOVReport) ++
(lib.optional doClangAnalysis args.clang-analyzer) ++
(lib.optional doCoverityAnalysis args.cov-build) ++
(lib.optional doCoverityAnalysis args.xz);
lcovFilter = ["/nix/store/*"] ++ lcovFilter;
inherit lcovExtraTraceFiles;
postPhases = postPhases ++ ["finalPhase"];
meta = (if args ? meta then args.meta else {}) // {
description = if doCoverageAnalysis then "Coverage analysis" else "Nix package for ${stdenv.hostPlatform.system}";
};
}
//
(if buildOutOfSourceTree
then {
preConfigure =
# Build out of source tree and make the source tree read-only. This
# helps catch violations of the GNU Coding Standards (info
# "(standards) Configuration"), like `make distcheck' does.
'' mkdir "../build"
cd "../build"
configureScript="../$sourceRoot/configure"
chmod -R a-w "../$sourceRoot"
echo "building out of source tree, from \`$PWD'..."
${if preConfigure != null then preConfigure else ""}
'';
}
else {})
)

View file

@ -0,0 +1,54 @@
# This function builds an RPM from a source tarball that contains a
# RPM spec file (i.e., one that can be built using `rpmbuild -ta').
{ name ? "rpm-build"
, diskImage
, src, vmTools
, ... } @ args:
vmTools.buildRPM (
removeAttrs args ["vmTools"] //
{
name = name + "-" + diskImage.name + (if src ? version then "-" + src.version else "");
preBuild = ''
. ${./functions.sh}
propagateImageName
src=$(findTarball $src)
'';
postInstall = ''
declare -a rpms rpmNames
for i in $out/rpms/*/*.rpm; do
if echo $i | grep -vq "\.src\.rpm$"; then
echo "file rpm $i" >> $out/nix-support/hydra-build-products
rpms+=($i)
rpmNames+=("$(rpm -qp "$i")")
fi
done
echo "installing ''${rpms[*]}..."
rpm -Up ''${rpms[*]} --excludepath /nix/store
eval "$postRPMInstall"
echo "uninstalling ''${rpmNames[*]}..."
rpm -e ''${rpmNames[*]} --nodeps
for i in $out/rpms/*/*.src.rpm; do
echo "file srpm $i" >> $out/nix-support/hydra-build-products
done
for rpmdir in $extraRPMs ; do
echo "file rpm-extra $(ls $rpmdir/rpms/*/*.rpm | grep -v 'src\.rpm' | sort | head -1)" >> $out/nix-support/hydra-build-products
done
'';
meta = (if args ? meta then args.meta else {}) // {
description = "RPM package for ${diskImage.fullName}";
};
}
)

View file

@ -0,0 +1,130 @@
# This function converts an un-Autoconfed source tarball (typically a
# checkout from a Subversion or CVS repository) into a source tarball
# by running `autoreconf', `configure' and `make dist'.
{ officialRelease ? false
, buildInputs ? []
, name ? "source-tarball"
, version ? "0"
, versionSuffix ?
if officialRelease
then ""
else "pre${toString (src.rev or src.revCount or "")}"
, src, stdenv, autoconf, automake, libtool
, # By default, provide all the GNU Build System as input.
bootstrapBuildInputs ? [ autoconf automake libtool ]
, ... } @ args:
stdenv.mkDerivation (
# First, attributes that can be overriden by the caller (via args):
{
# By default, only configure and build a source distribution.
# Some packages can only build a distribution after a general
# `make' (or even `make install').
dontBuild = true;
dontInstall = true;
doDist = true;
# If we do install, install to a dummy location.
useTempPrefix = true;
showBuildStats = true;
preConfigurePhases = "autoconfPhase";
postPhases = "finalPhase";
# Autoconfiscate the sources.
autoconfPhase = ''
export VERSION=${version}
export VERSION_SUFFIX=${versionSuffix}
# `svn-revision' is set for backwards compatibility with the old
# Nix buildfarm. (Stratego/XT's autoxt uses it. We should
# update it eventually.)
echo ${versionSuffix} | sed -e s/pre// > svn-revision
eval "$preAutoconf"
if test -x ./bootstrap && test -f ./bootstrap; then ./bootstrap
elif test -x ./bootstrap.sh; then ./bootstrap.sh
elif test -x ./autogen.sh; then ./autogen.sh
elif test -x ./autogen ; then ./autogen
elif test -x ./reconf; then ./reconf
elif test -f ./configure.in || test -f ./configure.ac; then
autoreconf --install --force --verbose
else
echo "No bootstrap, bootstrap.sh, configure.in or configure.ac. Assuming this is not an GNU Autotools package."
fi
eval "$postAutoconf"
'';
failureHook = ''
if test -n "$succeedOnFailure"; then
if test -n "$keepBuildDirectory"; then
KEEPBUILDDIR="$out/`basename $TMPDIR`"
header "Copying build directory to $KEEPBUILDDIR"
mkdir -p $KEEPBUILDDIR
cp -R "$TMPDIR/"* $KEEPBUILDDIR
stopNest
fi
fi
'';
}
# Then, the caller-supplied attributes.
// args //
# And finally, our own stuff.
{
name = name + "-" + version + versionSuffix;
buildInputs = buildInputs ++ bootstrapBuildInputs;
preUnpack = ''
mkdir -p $out/nix-support
'';
postUnpack = ''
# Set all source files to the current date. This is because Nix
# resets the timestamp on all files to 0 (1/1/1970), which some
# people don't like (in particular GNU tar prints harmless but
# frightening warnings about it).
touch now
touch -d "1970-01-01 00:00:00 UTC" then
find $sourceRoot ! -newer then -print0 | xargs -0r touch --reference now
rm now then
eval "$nextPostUnpack"
'';
nextPostUnpack = if args ? postUnpack then args.postUnpack else "";
# Cause distPhase to copy tar.bz2 in addition to tar.gz.
tarballs = "*.tar.gz *.tar.bz2 *.tar.xz";
finalPhase = ''
for i in "$out/tarballs/"*; do
echo "file source-dist $i" >> $out/nix-support/hydra-build-products
done
# Try to figure out the release name.
releaseName=$( (cd $out/tarballs && ls) | head -n 1 | sed -e 's^\.[a-z].*^^')
test -n "$releaseName" && (echo "$releaseName" >> $out/nix-support/hydra-release-name)
'';
passthru = {
inherit src;
version = version + versionSuffix;
};
meta = (if args ? meta then args.meta else {}) // {
description = "Source distribution";
# Tarball builds are generally important, so give them a high
# default priority.
schedulingPriority = 200;
};
}
)