Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Using apt to set up a "chroot"

User discussion about Debian Development, Debian Project News and Announcements. Not for support questions.
Post Reply
Message
Author
jayen
Posts: 15
Joined: 2010-03-18 08:01

Using apt to set up a "chroot"

#1 Post by jayen »

I'm trying to set up a cross-build environment as an addon to another cross-build environment. I've got development packages in an apt repository and I'd like to use apt to manage the cross-build directory to hold the "installed" packages. I want to use /usr from the system for the dpkg & apt executables, but /var and /etc in the cross-build directory to hold the configuration and the metadata for apt/dpkg.

I can run apt-get with "-o Dir=cross-build-directory" and that works mostly, but is not honoured for accessing /var/lib/dpkg/lock.

I can use "-o Debug::NoLocking=True" to get around the lock problem.

I can see cross-build-directory/etc/apt is being used for the sources.list.d, but not for the apt.conf.d, and so it is picking up my system configuration from /etc/apt/apt.conf.d. How do I get around this? I tried "-o Dir::Etc::parts=cross-build-directory/etc/apt/apt.conf.d" but apt-get is still accessing the system /etc/apt/apt.conf.d

I don't want to use RootDir, as that will affect things like /usr/lib/apt/methods/http.

User avatar
aspnair
Posts: 1247
Joined: 2009-06-18 12:27
Location: Twitter: @anand_sivaram

Re: Using apt to set up a "chroot"

#2 Post by aspnair »

Why not try
chroot /path/to/chroot
apt-get .....
That works perfectly.
Compressed Air Energy Storage, Entropy and Efficiency
http://saurorja.org/2012/06/18/compress ... fficiency/

jayen
Posts: 15
Joined: 2010-03-18 08:01

Re: Using apt to set up a "chroot"

#3 Post by jayen »

Can I set up a chroot without root? Can I set up a chroot without libc and stuff? (libc and stuff is already in the original cross-build environment I don't want to modify in place.)

User avatar
aspnair
Posts: 1247
Joined: 2009-06-18 12:27
Location: Twitter: @anand_sivaram

Re: Using apt to set up a "chroot"

#4 Post by aspnair »

You need privileged access for chroot, CAP_SYS_CHROOT as per "man 2 chroot"
If you application is a statically linked one, then you dont need libc etc. for chroot.
Compressed Air Energy Storage, Entropy and Efficiency
http://saurorja.org/2012/06/18/compress ... fficiency/

jayen
Posts: 15
Joined: 2010-03-18 08:01

Re: Using apt to set up a "chroot"

#5 Post by jayen »

so rather than requiring root for my purposes, i set up this hacky script: http://runswift.cse.unsw.edu.au/opennao/apt-get-nao-dev

hopefully someone else will also find it useful.

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: Using apt to set up a "chroot"

#6 Post by llivv »

I'm not sure edit: there are no debian production tools for rooting a box..... right!
Last edited by llivv on 2011-01-05 16:42, edited 2 times in total.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

jayen
Posts: 15
Joined: 2010-03-18 08:01

Re: Using apt to set up a "chroot"

#7 Post by jayen »

I've set up an schroot before on my own machine, but I needed root to set it up. I'll look again.
chroot(2) wrote: Only a privileged process (Linux: one with the CAP_SYS_CHROOT capabil‐
ity) may call chroot().

jayen
Posts: 15
Joined: 2010-03-18 08:01

Re: Using apt to set up a "chroot"

#8 Post by jayen »

schroot(1) wrote: If the user is not an allowed user, or a member of the allowed groups
(or if changing to root, the allowed root users or allowed root groups)
for the specified chroot(s), permission will be immediately denied. If
switching users, and the user running the command has access, the user
will be required to authenticate themselves using the credentials of
the user being switched to.
So it looks like I need root to at least set up access. :(

jayen
Posts: 15
Joined: 2010-03-18 08:01

Re: Using apt to set up a "chroot"

#9 Post by jayen »

dchroot(1) wrote: · dchroot provides a restricted subset of the functionality imple‐
mented by schroot, but is still schroot underneath. Thus dch‐
root is still subject to schroot security checking, including
PAM authentication and authorisation, and session management,
for example, and hence may behave slightly differently to older
dchroot versions in some circumstances.

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: Using apt to set up a "chroot"

#10 Post by llivv »

edit
jayen wrote:I've set up an schroot before on my own machine, but I needed root to set it up.
rrrrrrr
Last edited by llivv on 2011-01-05 16:43, edited 3 times in total.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

jayen
Posts: 15
Joined: 2010-03-18 08:01

Re: Using apt to set up a "chroot"

#11 Post by jayen »

I'm trying to root a cross-build environment...

And now I've discovered apt-cross. I wonder if it works as well as my apt-get wrapper...

jayen
Posts: 15
Joined: 2010-03-18 08:01

Re: Using apt to set up a "chroot"

#12 Post by jayen »

I never tried apt-cross as the apt-get wrapper was working fine for the ~10 debian/ubuntu users using it to cross-build for opennao. http://runswift.cse.unsw.edu.au/opennao/apt-get-nao-dev

And since opennao is planning to move from apt to portage, it's unlikely I'll ever try apt-cross.

Post Reply