View previous topic :: View next topic |
Author |
Message |
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Sun Dec 29, 2013 1:51 pm Post subject: [solved] sandbox |
|
|
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 |
|
|
Kompi Apprentice
Joined: 05 Oct 2002 Posts: 252 Location: Germany
|
Posted: Mon Dec 30, 2013 9:43 am Post subject: |
|
|
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 |
|
|
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Mon Dec 30, 2013 2:09 pm Post subject: |
|
|
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 |
|
|
Kompi Apprentice
Joined: 05 Oct 2002 Posts: 252 Location: Germany
|
Posted: Mon Dec 30, 2013 3:01 pm Post subject: |
|
|
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 |
|
|
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Mon Dec 30, 2013 9:58 pm Post subject: |
|
|
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 |
|
|
Kompi Apprentice
Joined: 05 Oct 2002 Posts: 252 Location: Germany
|
Posted: Tue Dec 31, 2013 1:29 am Post subject: |
|
|
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 |
|
|
Navar Guru
Joined: 20 Aug 2012 Posts: 353
|
Posted: Tue Dec 31, 2013 8:06 am Post subject: |
|
|
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 |
|
|
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Tue Dec 31, 2013 9:02 am Post subject: |
|
|
Ok thx guys. |
|
Back to top |
|
|
|