termux / proot

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

Zypper doesn't work on openSUSE Leap/Tumbleweed #111

Closed radumamy closed 4 years ago

radumamy commented 4 years ago

I have been using openSUSE via Proot/Termux but Zypper doesn't work. It fails to install any software or update the Distro.

This behaviour doesn't happen if I chroot using the same images on a PC.

Please advise if you need any logs, etc. that may assist in solving this issue. Thank you.

`localhost:~ # zypper ref Retrieving repository 'openSUSE-Tumbleweed-Oss' me[done] Retrieving repository 'openSUSE-Tumbleweed-Update'[done] All repositories have been refreshed. localhost:~ # zypper in pidgin Retrieving repository 'openSUSE-Tumbleweed-Oss' me[done] Retrieving repository 'openSUSE-Tumbleweed-Update'[done] Loading repository data... Retrieving repository 'openSUSE-Tumbleweed-Oss' data... Retrieving repository 'openSUSE-Tumbleweed-Oss' me[done] Retrieving repository 'openSUSE-Tumbleweed-Update' data... Retrieving repository 'openSUSE-Tumbleweed-Update'[done] Reading installed packages... 'pidgin' not found in package names. Trying capabilities. No provider of 'pidgin' found. Resolving package dependencies...

Nothing to do.`

As a workaround, I can use DNF to install packages or perform an upgrade.

michalbednarski commented 4 years ago

Primary issue here is that Zypper uses link syscall to copy updated index from temporary directory and then deletes that temporary directory (link2symlink handles this by making symlink and keeping original file in same directory, which in this case is deleted when it is about to be used)

You can solve this particular issue by setting PROOT_L2S_DIR variable to point to directory when .l2s files should be stored. (This variable should be set for proot, path is in host filesystem)

There are however further problems with package updates I have yet to look into (so far looks like permissions package (or actually its chkstat --system trigger) causes assertion failure in proot) and there are installation problems with gimp-help, glibc and some others I haven't yet investigated.

radumamy commented 4 years ago

Thank you @michalbednarski.

Am I right in thinking that this variable needs to be set to one of the /var/tmp/AP_0x*/repodata/ directories?

I have noticed these directories get created each time I run a Zypper command, so they are not unique.

How can I set this variable if I don't know the exact name of the directory? Should I remove any of these directories in my startup script? Can you please advise what is the actual command that I need to use?

Kind Regards, Radu

michalbednarski commented 4 years ago

This should be pointing to directory that won't be deleted as long as you won't be deleting whole rootfs, so not in /tmp. I'd suggest creating new subdirectory of rootfs (such as /links in guest), although it can be also outside rootfs.

For testing this issue I've used following startup script (rootfs at ~/opensuse, L2S dir at ~/opensuse/links, note that PROOT_L2S_DIR needs absolute path in host fs)

#!/data/data/com.termux/files/usr/bin/sh
unset LD_PRELOAD
cd /data/data/com.termux/files/home/opensuse || exit 1
PROOT_L2S_DIR=`pwd`/links exec proot --link2symlink -0 -R . usr/bin/env PATH=/usr/bin:/bin:/usr/sbin:/sbin HOME=/root /bin/bash
radumamy commented 4 years ago

Excellent, it looks like it worked. Thanks @michalbednarski. I've managed to install and remove packages. I haven't tried an upgrade yet, but as soon as one is available, I'll let you know.

radumamy commented 4 years ago

Good Afternoon @michalbednarski.

Yesterday I was able to install XFCE using your script and the JeOS openSUSE image which is great.

When I've connected to the JeOS image using the AnLinux script https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/Installer/openSUSE/Leap/opensuse-leap.sh I've been normally using (including the PROOT_L2S_DIR,) zypper didn't work.

What's the reason for it? What does || exit 1 do? Thanks.

michalbednarski commented 4 years ago

I think something is missing from your comment (error message/details?)

Looks like zypper update is fine after setting PROOT_L2S_DIR and doing zypper addlock permissions (this workarounds assertion failure I yet have to fix)

|| exit 1 means that script will be terminated if command before || fails (returns nonzero exit status)

radumamy commented 4 years ago

@michalbednarski, could you please advise how I can incorporate your script into the existing one I've been using? I've tried and I couldn't get it to work. Thank you.

`#!/data/data/com.termux/files/usr/bin/bash cd $(dirname $0)

unset LD_PRELOAD in case termux-exec is installed

unset LD_PRELOAD command="proot" command+=" --link2symlink" command+=" -0" command+=" -r opensuse-tumbleweed-fs" if [ -n "$(ls -A opensuse-tumbleweed-binds)" ]; then for f in opensuse-tumbleweed-binds/* ;do . $f done fi command+=" -b /proc" command+=" -b /sys" command+=" -b /dev" command+=" -b /dev/pts" command+=" -b opensuse-tumbleweed-fs/root:/dev/shm"

uncomment the following line to have access to the home>

command+=" -b /data/data/com.termux/files/home:/root"

uncomment the following line to mount /sdcard directly >

command+=" -b /sdcard"

command+=" -w /root" command+=" /usr/bin/env -i" command+=" HOME=/root" command+=" PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/b> command+=" TERM=$TERM" command+=" LANG=C.UTF-8" command+=" /bin/bash --login" com="$@" if [ -z "$1" ];then exec $command else $command -c "$com" fi`

michalbednarski commented 4 years ago

You'd need to insert near beginning of script (for example after unset LD_PRELOAD)

export PROOT_L2S_DIR=`pwd`/opensuse-tumbleweed-fs/links

Once you are in guest you'd need to run once

mkdir /links
radumamy commented 4 years ago

Thank you @michalbednarski. It works as expected. I'm going to close this issue now. Could you please let me know if you manage to fix the permissions assertion failure?