Sunday, December 29, 2019

Re: How to use proot?

Marc Espie <espie@nerim.net> writes:

> On Sun, Dec 29, 2019 at 05:46:04AM -0800, Xiyue Deng wrote:
>> Xiyue Deng <manphiz@gmail.com> writes:
>>
>> > Marc Espie <espie@nerim.net> writes:
>> >
>> >> On Sun, Dec 29, 2019 at 02:21:21AM -0800, Xiyue Deng wrote:
>> >>> Sure thing. It's not very interesting and looks like below:
>> >>>
>> >>> $ mount
>> >>> /dev/wd0a on / type ffs (local, wxallowed, softdep)
>> >>>
>> >>> (So basically my whole disk is mounted on /)
>> >>
>> >> ... and there was a bug in my logic because I never got a proot straight
>> >> mounted under /. It's now fixed.
>> >>
>> >>
>> >> Index: proot
>> >> ===================================================================
>> >> RCS file: /cvs/ports/infrastructure/bin/proot,v
>> >> retrieving revision 1.66
>> >> diff -u -p -r1.66 proot
>> >> --- proot 6 Dec 2019 13:40:46 -0000 1.66
>> >> +++ proot 29 Dec 2019 10:34:54 -0000
>> >> @@ -474,10 +474,15 @@ sub check_mountpoint
>> >> }
>> >> }
>> >> my $mnt = $root;
>> >> - do {{
>> >> + while (1) {
>> >> if (!defined $dev->{$mnt}) {
>> >> - $mnt = dirname($mnt);
>> >> - next;
>> >> + my $up = dirname($mnt);
>> >> + if ($mnt eq $up) {
>> >> + last;
>> >> + } else {
>> >> + $mnt = $up;
>> >> + next;
>> >> + }
>> >> }
>> >> $state->errsay("#1 is under #2 which is nodev", $root, $mnt)
>> >> if $dev->{$mnt} == 0;
>> >> @@ -485,8 +490,8 @@ sub check_mountpoint
>> >> $root, $mnt) if $nosuid->{$mnt} == 0;
>> >> $state->errsay("#1 is under #2 which does not have wxallowed",
>> >> $root, $mnt) if $wx->{$mnt} == 0;
>> >> - return;
>> >> - }} while ($mnt ne dirname($mnt));
>> >> + return;
>> >> + }
>> >> $state->fatal_error("Couldn't find mountpoint for #1 ???", $root);
>> >> }
>> >>
>> >
>> > It's working now! Thanks Marc for the quick fix!
>>
>> A follow up question: It seems dpb still cannot use the created chroot
>> by default. I created the chroot using the following command as
>> suggested in the man page:
>>
>> ,----
>> | $ proot -B /build actions=unpopulate_light check_symlinks
>> `----
>>
>> The error messages look like below:
>>
>> ,----
>> | $ sudo /usr/ports/infrastructure/bin/dpb -B /build -P ~/localports -DCOLOR=1
>> | Password:
>> | *** Parse error in /: Could not find /usr/ports/infrastructure/mk/bsd.port.mk (<bsd.port.mk>:5)
>> | dpb: Can't obtain vital information from the ports tree
>> | Usage: dpb [-acemqrRsuUvx] [-A arch] [-B chroot] [-C plist] [-f m] [-F m]
>> | [-I pathlist] [-J p] [-j n] [-p parallel] [-P pathlist] [-h hosts]
>> | [-L logdir] [-l lockdir] [-b log] [-M threshold] [-X pathlist]
>> | [pathlist ...]
>> `----
>>
>> I checked the chroot under /build and it seems
>> /build/usr/ports/infrastructure does not exist. Maybe the contents of
>> /usr/ports/infrastructure should be copied over as well? Or am I missing
>> some options in the dpb command?
>
> By default, proot does not take care of checking out the ports tree.
>
> You either do it manually through cvs, or you use the checkout_ports
> or the copy_ports action

Thanks Marc! "copy_ports" did the trick and dpb is working with the
new chroot now.

However "copy_ports" is kinda slow - the whole process now takes ~30min
compared to ~2min without copy_ports. I wonder is there a way to bind
mount directory under the chroot (similar to bind-mount in pbuilder[1])
to make this process faster?

[1] https://manpages.debian.org/stretch-backports/pbuilder/pbuilderrc.5.en.html

No comments:

Post a Comment