Merge pull request #268458 from Mic92/dockertools

nixos/dockerTools: fixup proot/fakeroot code (fixes dockertools nixos test)
This commit is contained in:
Robert Hensing 2023-11-19 21:50:16 +01:00 committed by GitHub
commit 2834c0cf2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -914,17 +914,30 @@ rec {
(cd old_out; eval "$extraCommands" )
mkdir $out
${optionalString enableFakechroot ''proot -r $PWD/old_out ${bind-paths} --pwd=/ ''}fakeroot bash -c '
source $stdenv/setup
${optionalString (!enableFakechroot) ''cd old_out''}
eval "$fakeRootCommands"
tar \
--sort name \
--numeric-owner --mtime "@$SOURCE_DATE_EPOCH" \
--hard-dereference \
-cf $out/layer.tar .
'
${if enableFakechroot then ''
proot -r $PWD/old_out ${bind-paths} --pwd=/ --root-id bash -c '
source $stdenv/setup
eval "$fakeRootCommands"
tar \
--sort name \
--exclude=./proc \
--exclude=./sys \
--numeric-owner --mtime "@$SOURCE_DATE_EPOCH" \
--hard-dereference \
-cf $out/layer.tar .
'
'' else ''
fakeroot bash -c '
source $stdenv/setup
cd old_out
eval "$fakeRootCommands"
tar \
--sort name \
--numeric-owner --mtime "@$SOURCE_DATE_EPOCH" \
--hard-dereference \
-cf $out/layer.tar .
'
''}
sha256sum $out/layer.tar \
| cut -f 1 -d ' ' \
> $out/checksum