Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] sandbox
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Sun Dec 29, 2013 1:51 pm    Post subject: [solved] sandbox Reply with quote

Hi,
Latly I found 'sandbox' a gentoo tool. What for (dan how) I can use it. Maybe for testing ebuilds?


Last edited by emc on Mon Dec 30, 2013 9:58 pm; edited 1 time in total
Back to top
View user's profile Send private message
Kompi
Apprentice
Apprentice


Joined: 05 Oct 2002
Posts: 252
Location: Germany

PostPosted: Mon Dec 30, 2013 9:43 am    Post subject: Reply with quote

Sandbox is used by portage to prevent badly written ebuild from messing with your system. AFAIK, it prevents packages beeing built from modifying anything outside the build dir while compiling / installing to a temp dir. Changes to root are only made afterwards in the merge stage, that is, when the compiled files are copied to your root.

See http://devmanual.gentoo.org/general-concepts/sandbox/

You can enable sandboxing in /etc/portage/make.conf with:

Code:
FEATURES="${FEATURES} sandbox"


or manually by:

Code:
FEATURES="sandbox" emerge ...
Back to top
View user's profile Send private message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Mon Dec 30, 2013 2:09 pm    Post subject: Reply with quote

ok, get it. But what can I use to test new ebuilds and not mess around system. I want learn writing ebuilds, where to start beside:
http://devmanual.gentoo.org/index.html
Back to top
View user's profile Send private message
Kompi
Apprentice
Apprentice


Joined: 05 Oct 2002
Posts: 252
Location: Germany

PostPosted: Mon Dec 30, 2013 3:01 pm    Post subject: Reply with quote

hmm, I'm not an expert on writing ebuild, so far I only have written some basic stuff or patched some existing ebuilds, so I don't know the best sources for docs on writing ebuilds besides the gentoo dev guide.

But If you want to play it safe you could create a second gentoo root in a chroot to develop the ebuilds.

For example, create a new root in a chroot just like with a fresh install and test your ebuilds there:

Code:
mkdir /mnt/gentoo-chroot
cd /mnt/gentoo-chroot/
tar -jvxf <gentoo-stage3.tar.bz2>
mount -o bind /dev dev
mount -o bind /proc proc
mount -o bind /sys sys
mount -o bind /usr/portage usr/portage
chroot /mnt/gentoo-chroot /bin/bash


and voila, a clean gentoo root. Now you can create your local overlay in /usr/local/portage from there and start testing your ebuilds in that chroot. If anything breaks, you can just re-create that chroot.

You could also use btrfs and take snapshots before attempting anything dangerous, that way you can just roll back your root if neccessary.
Back to top
View user's profile Send private message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Mon Dec 30, 2013 9:58 pm    Post subject: Reply with quote

Kompi wrote:
But If you want to play it safe you could create a second gentoo root in a chroot to develop the ebuilds.

I was thinkin about chroot but wasn't sure.
Kompi wrote:
You could also use btrfs and take snapshots before attempting anything dangerous, that way you can just roll back your root if neccessary.

Nice idea, can you give me a hint about btrfs snapshots, how to make it and how to restore?
Back to top
View user's profile Send private message
Kompi
Apprentice
Apprentice


Joined: 05 Oct 2002
Posts: 252
Location: Germany

PostPosted: Tue Dec 31, 2013 1:29 am    Post subject: Reply with quote

Taking snapshots is fairly easy with the btrfs utility (from sys-fs/btrfs-progs):

Say you have a btrfs filesystem mounted at /mnt/gentoo. To take a snapshot and call it "checkpoint":
Code:
btrfs subvolume snapshot /mnt/gentoo checkpoint

You now have a new subvolume that is accessible via /mnt/gentoo/checkpoint (the name of a snapshot is like a directory. You can also have it in subdirectories).

If you later want to go back and use that snapshot as your filesystem you can either mount that subvolume manually:
Code:
umount /mnt/gentoo
mount -t btrfs -o subvol=checkpoint /dev/<DEVICE> /mnt/gentoo

or, if you want to permanently revert the default subvolume (the root of the fs) to that snapshot:
Code:
btrfs subvolume list /mnt/gentoo
btrfs subvolume set-default <ID> /mnt/gentoo

The list command shows you the id you have to fill in in the set-default option.

If you want to get rid of a snapshot:
Code:
btrfs subvolume delete /mnt/gentoo/snapshot
Back to top
View user's profile Send private message
Navar
Guru
Guru


Joined: 20 Aug 2012
Posts: 353

PostPosted: Tue Dec 31, 2013 8:06 am    Post subject: Reply with quote

sandbox should be enabled in FEATURES by default and rarely disabled. You should be seeing it in your emerge --info output (along with other defaults) without needing to add in your make.conf. For more info, check make.conf manpage.
_________________
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
Back to top
View user's profile Send private message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Tue Dec 31, 2013 9:02 am    Post subject: Reply with quote

Ok thx guys.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum