2024-01-13 08:15:51 +00:00
|
|
|
{ hello, checkpointBuildTools, runCommand, texinfo, stdenv, rsync }:
|
2024-01-02 11:29:13 +00:00
|
|
|
let
|
|
|
|
baseHelloArtifacts = checkpointBuildTools.prepareCheckpointBuild hello;
|
|
|
|
patchedHello = hello.overrideAttrs (old: {
|
|
|
|
buildInputs = [ texinfo ];
|
2024-01-13 08:15:51 +00:00
|
|
|
src = runCommand "patch-hello-src" { } ''
|
2024-01-02 11:29:13 +00:00
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
|
|
|
tar xf ${hello.src} --strip-components=1
|
|
|
|
patch -p1 < ${./hello.patch}
|
|
|
|
'';
|
|
|
|
});
|
2024-01-13 08:15:51 +00:00
|
|
|
checkpointBuiltHello = checkpointBuildTools.mkCheckpointBuild patchedHello baseHelloArtifacts;
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
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 ];
|
|
|
|
}));
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
preparedHelloRemoveFileSrc = runCommand "patch-hello-src" { } ''
|
2024-01-02 11:29:13 +00: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-13 08:15:51 +00:00
|
|
|
src = runCommand "patch-hello-src" { } ''
|
2024-01-02 11:29:13 +00:00
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
|
|
|
${rsync}/bin/rsync -cutU --chown=$USER:$USER --chmod=+w -r ${preparedHelloRemoveFileSrc}/* .
|
|
|
|
patch -p1 < ${./hello-removeFile.patch}
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
checkpointBuiltHelloWithRemovedFile = checkpointBuildTools.mkCheckpointBuild patchedHelloRemoveFile baseHelloRemoveFileArtifacts;
|
2024-01-02 11:29:13 +00:00
|
|
|
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!" ]
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
|