2024-01-04 21:39:07 +01:00
|
|
|
{ hello, checkpointBuildTools, runCommand, texinfo, stdenv, rsync }:
|
2022-04-07 16:28:20 +02:00
|
|
|
let
|
2022-12-20 13:53:03 +01:00
|
|
|
baseHelloArtifacts = checkpointBuildTools.prepareCheckpointBuild hello;
|
2022-04-07 16:28:20 +02:00
|
|
|
patchedHello = hello.overrideAttrs (old: {
|
|
|
|
buildInputs = [ texinfo ];
|
2024-01-04 21:39:07 +01:00
|
|
|
src = runCommand "patch-hello-src" { } ''
|
2022-04-07 16:28:20 +02:00
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
|
|
|
tar xf ${hello.src} --strip-components=1
|
|
|
|
patch -p1 < ${./hello.patch}
|
|
|
|
'';
|
|
|
|
});
|
2024-01-07 11:47:47 +01:00
|
|
|
checkpointBuiltHello = checkpointBuildTools.mkCheckpointBuild patchedHello baseHelloArtifacts;
|
2022-04-07 16:28:20 +02:00
|
|
|
|
2022-12-20 13:53:03 +01:00
|
|
|
checkpointBuiltHelloWithCheck = checkpointBuiltHello.overrideAttrs (old: {
|
2022-04-07 16:28:20 +02:00
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
echo "checking if unchanged source file is not recompiled"
|
2022-06-20 11:17:09 +02:00
|
|
|
[ "$(stat --format="%Y" lib/exitfail.o)" = "$(stat --format="%Y" ${baseHelloArtifacts}/outputs/lib/exitfail.o)" ]
|
2022-04-07 16:28:20 +02:00
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2022-12-20 13:53:03 +01:00
|
|
|
baseHelloRemoveFileArtifacts = checkpointBuildTools.prepareCheckpointBuild (hello.overrideAttrs (old: {
|
2022-04-07 16:28:20 +02:00
|
|
|
patches = [ ./hello-additionalFile.patch ];
|
|
|
|
}));
|
|
|
|
|
2024-01-04 21:39:07 +01:00
|
|
|
preparedHelloRemoveFileSrc = runCommand "patch-hello-src" { } ''
|
2022-04-07 16:28:20 +02:00
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
|
|
|
tar xf ${hello.src} --strip-components=1
|
|
|
|
patch -p1 < ${./hello-additionalFile.patch}
|
|
|
|
'';
|
|
|
|
|
|
|
|
patchedHelloRemoveFile = hello.overrideAttrs (old: {
|
|
|
|
buildInputs = [ texinfo ];
|
2024-01-04 21:39:07 +01:00
|
|
|
src = runCommand "patch-hello-src" { } ''
|
2022-04-07 16:28:20 +02:00
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
|
|
|
${rsync}/bin/rsync -cutU --chown=$USER:$USER --chmod=+w -r ${preparedHelloRemoveFileSrc}/* .
|
|
|
|
patch -p1 < ${./hello-removeFile.patch}
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2024-01-07 11:47:47 +01:00
|
|
|
checkpointBuiltHelloWithRemovedFile = checkpointBuildTools.mkCheckpointBuild patchedHelloRemoveFile baseHelloRemoveFileArtifacts;
|
2022-04-07 16:28:20 +02:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "patched-hello-returns-correct-output";
|
|
|
|
buildCommand = ''
|
|
|
|
touch $out
|
|
|
|
|
|
|
|
echo "testing output of hello binary"
|
2022-12-20 13:53:03 +01:00
|
|
|
[ "$(${checkpointBuiltHelloWithCheck}/bin/hello)" = "Hello, incremental world!" ]
|
2022-04-07 16:28:20 +02:00
|
|
|
echo "testing output of hello with removed file"
|
2022-12-20 13:53:03 +01:00
|
|
|
[ "$(${checkpointBuiltHelloWithRemovedFile}/bin/hello)" = "Hello, incremental world!" ]
|
2022-04-07 16:28:20 +02:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
|