Commit 49119155 authored by Jörg Thalheim's avatar Jörg Thalheim
Browse files

nixos/dockerTools: fixup proot/fakeroot code

Not sure how this ever worked but tar was trying to archive /proc and /sys, which failed to work.
Since this is never useful for containers to do, we exclude this now in the proot case.
Also fakeroot is not needed when proot is used as it provideds the same feature.
We now cleanly seperate those cases as both are kind of hacks and it's more likely
that the combination will just trigger new bugs.
parent 0ace63be
Loading
Loading
Loading
Loading
+24 −11
Original line number Diff line number Diff line
@@ -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 '
            ${if enableFakechroot then ''
              proot -r $PWD/old_out ${bind-paths} --pwd=/ --root-id bash -c '
                source $stdenv/setup
              ${optionalString (!enableFakechroot) ''cd old_out''}
                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