504525a148
GitOrigin-RevId: bd645e8668ec6612439a9ee7e71f7eac4099d4f6
57 lines
2 KiB
Nix
57 lines
2 KiB
Nix
{ hello, checkpointBuildTools, runCommandNoCC, texinfo, stdenv, rsync }:
|
|
let
|
|
baseHelloArtifacts = checkpointBuildTools.prepareCheckpointBuild hello;
|
|
patchedHello = hello.overrideAttrs (old: {
|
|
buildInputs = [ texinfo ];
|
|
src = runCommandNoCC "patch-hello-src" { } ''
|
|
mkdir -p $out
|
|
cd $out
|
|
tar xf ${hello.src} --strip-components=1
|
|
patch -p1 < ${./hello.patch}
|
|
'';
|
|
});
|
|
checkpointBuiltHello = checkpointBuildTools.mkCheckpointedBuild patchedHello baseHelloArtifacts;
|
|
|
|
checkpointBuiltHelloWithCheck = checkpointBuiltHello.overrideAttrs (old: {
|
|
doCheck = true;
|
|
checkPhase = ''
|
|
echo "checking if unchanged source file is not recompiled"
|
|
[ "$(stat --format="%Y" lib/exitfail.o)" = "$(stat --format="%Y" ${baseHelloArtifacts}/outputs/lib/exitfail.o)" ]
|
|
'';
|
|
});
|
|
|
|
baseHelloRemoveFileArtifacts = checkpointBuildTools.prepareCheckpointBuild (hello.overrideAttrs (old: {
|
|
patches = [ ./hello-additionalFile.patch ];
|
|
}));
|
|
|
|
preparedHelloRemoveFileSrc = runCommandNoCC "patch-hello-src" { } ''
|
|
mkdir -p $out
|
|
cd $out
|
|
tar xf ${hello.src} --strip-components=1
|
|
patch -p1 < ${./hello-additionalFile.patch}
|
|
'';
|
|
|
|
patchedHelloRemoveFile = hello.overrideAttrs (old: {
|
|
buildInputs = [ texinfo ];
|
|
src = runCommandNoCC "patch-hello-src" { } ''
|
|
mkdir -p $out
|
|
cd $out
|
|
${rsync}/bin/rsync -cutU --chown=$USER:$USER --chmod=+w -r ${preparedHelloRemoveFileSrc}/* .
|
|
patch -p1 < ${./hello-removeFile.patch}
|
|
'';
|
|
});
|
|
|
|
checkpointBuiltHelloWithRemovedFile = checkpointBuildTools.mkCheckpointedBuild patchedHelloRemoveFile baseHelloRemoveFileArtifacts;
|
|
in
|
|
stdenv.mkDerivation {
|
|
name = "patched-hello-returns-correct-output";
|
|
buildCommand = ''
|
|
touch $out
|
|
|
|
echo "testing output of hello binary"
|
|
[ "$(${checkpointBuiltHelloWithCheck}/bin/hello)" = "Hello, incremental world!" ]
|
|
echo "testing output of hello with removed file"
|
|
[ "$(${checkpointBuiltHelloWithRemovedFile}/bin/hello)" = "Hello, incremental world!" ]
|
|
'';
|
|
}
|
|
|