termux / proot

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

[Bug]: cp: cannot open '****' for reading: Too many levels of symbolic links #216

Closed JavisWiki closed 2 years ago

JavisWiki commented 2 years ago

Problem description

In termux,installed ubuntu(impish) with proot-distro,when I compile lede_openwrt firmware,logs oouput this error:

cp: cannot open '/home/javis/lede/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/initial/./bin/.l2s.mipsel-openwrt-linux-musl-objcopy0001' for reading: Too many levels of symbolic links cp: cannot open '/home/javis/lede/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/initial/./bin/.l2s.mipsel-openwrt-linux-musl-ar0001' for reading: Too many levels of symbolic links cp: cannot open '/home/javis/lede/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/initial/./bin/.l2s.mipsel-openwrt-linux-musl-nm0001' for reading: Too many levels of symbolic links

Steps to reproduce

Compile lede firmware.

Expected behavior

Too many levels of symbolic links,need to fix this.

Maybe we can install system in an img file,like this: emulate one virtual disk image file,make ext4 file system in image, emulate a folder related to this virtual disk image, then we can make links. I've tried use guestfs-tools to mount image file,but it doesn't work,lack of /dev/fuse permission. Expect fix it,thanks.

Additional information

michalbednarski commented 2 years ago

Looks like link2symlink-internal .l2s.* files got picked by build system and caused problems, delete built toolchain (build_dir/toolchain-* directory), run mkdir /.l2s inside proot-distro, exit and relaunch proot-distro after creating /.l2s directory.

That way newly created .l2s.* files will be put in separate directory and won't be causing conflicts

JavisWiki commented 2 years ago

Looks like link2symlink-internal .l2s.* files got picked by build system and caused problems, delete built toolchain (build_dir/toolchain-* directory), run mkdir /.l2s inside proot-distro, exit and relaunch proot-distro after creating /.l2s directory.

That way newly created .l2s.* files will be put in separate directory and won't be causing conflicts

That works,thank you so much! Amazing work! This is productivity! I'm so excited.ヾ(^▽^*))) But why create an folder can solve this? I looked up in bing but no much related information. Can not understand it. Anyway,thanks!~

JavisWiki commented 2 years ago

I've viewed source code,now I understand,awosome work!

michalbednarski commented 2 years ago

So to explain how does it work:

  1. Presence of that directory is checked by proot-distro and if it is present it is put into PROOT_L2S_DIR env variable
  2. When new link2symlink .l2s.* file pair is created, it is created in directory specified in PROOT_L2S_DIR or directory where original file is
JavisWiki commented 2 years ago

So to explain how does it work:

  1. Presence of that directory is checked by proot-distro and if it is present it is put into PROOT_L2S_DIR env variable
  2. When new link2symlink .l2s.* file pair is created, it is created in directory specified in PROOT_L2S_DIR or directory where original file is

Yep~~,you guys are genius.😁

SDRausty commented 2 years ago

explain how does it work

Hopefully, this will add a little more helpful info to this topic as it is a very interesting catch:

a catch 22 situation

It still is; But the most difficult hurdle seems overcome! However, the Termux PATH had to be dropped again. There must be an easy way to add it to the new login. Termux PATH collision with gcc (clang is installed, but gcc is not) and probably more programs when using yay and makeyay was one reason. The gcc package wants the --link2symlink option to be able to install in Arch Linux in Termux PRoot.

Another one is that reimplementation was consuming a lot of time, and I was not able to reimplement it. The new login is not designed to build and install packages with yay as the --link2symlink option is not present. So collisions should be trivial, if any as this login is not designed to build and install packages with yay. @sudomain could you see how Termux PATH can be implemented in the proot init string PROOTSTMNTU and probably completely removed from the .bash_profile file.

The solution you selected is simply awesome. I really like the idea of elogin and login.

I am really glad you like it @damionx7; I spent quite a lot of time thinking about this aspect of the catch 22. Thank you very much for helping! I hope many more users will enjoy this new feature too.

Originally posted by @SDRausty in https://github.com/SDRausty/TermuxArch/issues/249#issuecomment-687791616

SDRausty commented 2 years ago

Thank you @JavisWiki and @michalbednarski for assisting 🎵

JavisWiki commented 2 years ago

explain how does it work

Hopefully, this will add a little more helpful info to this topic as it is a very interesting catch:

a catch 22 situation

It still is; But the most difficult hurdle seems overcome! However, the Termux PATH had to be dropped again. There must be an easy way to add it to the new login. Termux PATH collision with gcc (clang is installed, but gcc is not) and probably more programs when using yay and makeyay was one reason. The gcc package wants the --link2symlink option to be able to install in Arch Linux in Termux PRoot.

Another one is that reimplementation was consuming a lot of time, and I was not able to reimplement it. The new login is not designed to build and install packages with yay as the --link2symlink option is not present. So collisions should be trivial, if any as this login is not designed to build and install packages with yay. @sudomain could you see how Termux PATH can be implemented in the proot init string PROOTSTMNTU and probably completely removed from the .bash_profile file.

The solution you selected is simply awesome. I really like the idea of elogin and login.

I am really glad you like it @damionx7; I spent quite a lot of time thinking about this aspect of the catch 22. Thank you very much for helping! I hope many more users will enjoy this new feature too.

Originally posted by @SDRausty in SDRausty/TermuxArch#249 (comment)

You are welcome,and thank you for your arch contribution~