storebackup: enable strictDeps, split phases

the result only changes in the outpath (creating diff in all wrapped binaries)
and in some of the shebangs due to relying on patchShebangs instead of manually
patching them with sed
This commit is contained in:
quantenzitrone
2026-07-05 04:34:58 +02:00
parent d83657c9d0
commit e739993fea
+32 -8
View File
@@ -9,6 +9,7 @@
diffutils,
writeScriptBin,
bzip2,
runtimeShellPackage,
}:
# quick usage:
@@ -22,6 +23,8 @@
let
dummyMount = writeScriptBin "mount" "#!${stdenv.shell}";
perl' = perl.withPackages (p: [ p.DBFile ]);
in
stdenv.mkDerivation (finalAttrs: {
@@ -31,8 +34,18 @@ stdenv.mkDerivation (finalAttrs: {
__structuredAttrs = true;
enableParallelBuilding = true;
strictDeps = true;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ perl ];
nativeInstallCheckInputs = [
diffutils
perl'
];
buildInputs = [
perl'
which
bzip2
runtimeShellPackage
];
src = fetchurl {
url = "mirror://savannah/storebackup/storeBackup-${finalAttrs.version}.tar.bz2";
@@ -45,15 +58,20 @@ stdenv.mkDerivation (finalAttrs: {
];
installPhase = ''
runHook preInstall
mkdir -p $out/scripts
mv * $out
mv $out/_ATTENTION_ $out/doc
mv $out/{correct.sh,cron-storebackup} $out/scripts
find $out -name "*.pl" | xargs sed -i \
-e 's@/bin/pwd@${coreutils}/bin/pwd@' \
-e 's@/bin/sync@${coreutils}/bin/sync@' \
-e '1 s@/usr/bin/env perl@${perl.withPackages (p: [ p.DBFile ])}/bin/perl@'
runHook postInstall
'';
preFixup = ''
find $out -name "*.pl" -print0 | xargs --null sed -i \
-e 's@/bin/pwd@${coreutils}/bin/pwd@g' \
-e 's@/bin/sync@${coreutils}/bin/sync@g'
for p in $out/bin/*
do wrapProgram "$p" --prefix PATH ":" "${
@@ -63,8 +81,12 @@ stdenv.mkDerivation (finalAttrs: {
]
}"
done
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
patchShebangs $out
# do a dummy test ensuring this works
PATH=$PATH:${dummyMount}/bin
@@ -84,7 +106,7 @@ stdenv.mkDerivation (finalAttrs: {
$out/bin/storeBackup.pl --sourceDir "$source" --backupDir backup
latestBackup=backup/default/$(ls -1 backup/default | sort | tail -n 1)
$out/bin/storeBackupRecover.pl -b "$latestBackup" -t restored -r /
${diffutils}/bin/diff -r "$source" restored
diff -r "$source" restored
# storeBackupCheckSource should return 0
$out/bin/storeBackupCheckSource.pl -s "$source" -b "$latestBackup"
@@ -98,7 +120,7 @@ stdenv.mkDerivation (finalAttrs: {
rm -fr restored
}
testDir=$TMP/testDir
testDir=$HOME/testDir
mkdir $testDir
echo X > $testDir/X
@@ -120,6 +142,8 @@ stdenv.mkDerivation (finalAttrs: {
backupRestore 'test 3: backup, restore' $out
backupRestore 'test 4: backup diffutils to same backup locations, restore' ${diffutils}
}
runHook postInstallCheck
'';
meta = {