termux / proot

An chroot-like implementation using ptrace.
https://wiki.termux.com/wiki/PRoot
Other
751 stars 161 forks source link

dpkg failed with error "wait for tar subprocess failed: Unknown error 512. tar: .: Cannot mkdir: No such file or directory" #157

Closed fanlei closed 3 years ago

fanlei commented 3 years ago

Problem description

I need Debian on my Chrombook but after proot-distro install debian-buster, can not upgrade or install any packages. Error messages after running apt upgrade: u0_a72@localhost ~ $ proot-distro login debian-buster root@localhost:~# apt upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages will be upgraded: apt base-files ca-certificates debian-archive-keyring libapt-pkg5.0 libgnutls30 libp11-kit0 libssl1.1 libsystemd0 libudev1 libzstd1 openssl systemd tzdata 14 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/11.3 MB of archives. After this operation, 57.3 kB of additional disk space will be used. Do you want to continue? [Y/n] y debconf: delaying package configuration, since apt-utils is not installed dpkg-deb: unrecoverable fatal error, aborting: wait for tar subprocess failed: Unknown error 512 dpkg: error processing archive /var/cache/apt/archives/base-files_10.3+deb10u9_i386.deb (--unpack): dpkg-deb --control subprocess returned error exit status 2 tar: .: Cannot mkdir: No such file or directory tar: ./conffiles: Cannot open: No such file or directory tar: ./control: Cannot open: No such file or directory tar: ./md5sums: Cannot open: No such file or directory tar: ./postinst: Cannot open: No such file or directory tar: Exiting with failure status due to previous errors Errors were encountered while processing: /var/cache/apt/archives/base-files_10.3+deb10u9_i386.deb E: Sub-process /usr/bin/dpkg returned an error code (1)

Steps to reproduce

proot-distro install debian-buster proot-distro login debian-buster apt update apt upgrade - failed or apt install php7.3 -failed

Additional information

Packages CPU architecture:
i386
Subscribed repositories:
# sources.list
deb https://termux.org/packages/ stable main
# sources.list.d/science.list
deb https://grimler.se/science-packages-24 science stable
# sources.list.d/game.list
deb https://grimler.se/game-packages-24 games stable
Updatable packages:
Running as root. Cannot check package updates.
Android version:
9
Kernel build information:
Linux localhost 5.4.0-faked #1 SMP PREEMPT Tue Apr 27 20:22:15 PDT 2021 i686 GNU/Linux
Device manufacturer:
Google
Device model:
HP Chromebook 13 G1

Could anybody tell me if anything I missed? Or, if it's not possible on this Chromebook, then I will give up and no need to waste time to keep trying. Many thanks in advance!

fanlei commented 3 years ago

I also tried the distro ubuntu-18.04, but no luck. Same errors as debian-buster above.

michalbednarski commented 3 years ago
  1. Make sure you don't nest proot, such as running proot-distro while running termux-chroot.
  2. I've checked on i686 Android emulator that these commands work fine there, so to look further I'd need you to collect detailed logs: PROOT_VERBOSE=9 proot-distro login debian-buster -- apt upgrade -y >& trace.txt
fanlei commented 3 years ago

@michalbednarski Thanks a lot for your quick response! 1. I don't nest proot 2. the log was attached. trace.txt

michalbednarski commented 3 years ago

You could try LD_PRELOAD'ing following into apt upgrade

#include <sys/wait.h>
int waitpid(int pid, int *stat_loc, int options) {
        return wait4(pid, stat_loc, options, 0);
}

You can compile it with Termux's clang waitfix.c -nostdlib -shared -o waitfix.so and then use it from guest system as

LD_PRELOAD=/data/data/com.termux/files/home/waitfix.so apt upgrade

I'm somewhat unsure what actually happened but it looks like:

fanlei commented 3 years ago

@michalbednarski Thank you so much - apt upgrade and install work now! I can move to this crostini-linux-unsupported Chromebook now.