sm-discuss AT lists.ibiblio.org
Subject: Public SourceMage Discussion List
List archive
- From: Vladimír Marek <vlmarek AT volny.cz>
- To: sm-discuss AT lists.ibiblio.org
- Subject: [SM-Discuss] chroot playground
- Date: Fri, 14 May 2004 20:21:53 +0200
Hello,
I'm currently playing with perl modules dependencties, and I got to
state I need some testing, which could eventually be dangerous to life
of my system :) With great help from Belxjander and great idea from
misantrop I put together theese three files, which can create chroot
from your /var/cache/sorcery, and set everything so that sorcery works
in the chroot too.
Usage is simple:
1) edit jail_params
2) run jail_create (best as a regular user)
3) run as root what previous step tells you at the end :)
4) you are in chroot now, run /root/jail_setup_inside to prepare sorcery
all done
Happy hacking, comments welcomed
--
Neuron
# Where the jail will be created
ROOT=/home/neuron/chroot
# Where _ALLREADY EXISTING_ precompiled binaries will be mounted
# If you put it into /var/cache/sorcery, sorcery will use them, but might
also overwrite
CACHE=/var/cache/sorcery
#CACHE=/binaries
# Where _ALLREADY EXISTING_ sources will be mounted
# If you put it into /var/spool/sorcery, sorcery will use them, but might
also overwrite
# CACHE=/var/cache/sorcery
SPOOL=/var/spool/sorcery
#SPOOL=/sources
# Packages needed to be able enter chroot
BASIC_PACKAGES='glibc glibc-kernel-headers bash ncurses gettext readline
coreutils tar bzip2 gzip'
# Packages needed for sorcery to work
# net-tools only neccessary if you plan to download sources from net
OTHER_PACKAGES='tar bzip2 gzip findutils sed dialog grep gcc less util-linux
wget gawk make file patch zlib binutils net-tools'
#!/bin/bash
. jail_params
. /etc/sorcery/config
function unpack_cached_spell () {
for SPELL in "$@"; do
run_details
FILE="$INSTALL_CACHE/$SPELL-$VERSION-$BUILD.tar$EXTENSION"
[ ! -e "$FILE" ] && echo "Can't locate $FILE" && exit 1
echo
echo echo $SPELL ...
tar xjf $FILE
done
}
[ -d $ROOT ] && echo "$ROOT allready exists" && exit
mkdir $ROOT
cd $ROOT
unpack_cached_spell $BASIC_PACKAGES
cp /etc/ld.so.conf etc/
cp /etc/passwd etc/
cp /etc/group etc/
cp /etc/resolv.conf etc/
mkdir -p dev
mkdir -p tpm
mkdir -p root
mkdir -p proc
mkdir -p $ROOT/$CACHE
mkdir -p $ROOT/$SPOOL
function ls_cached_spell {
for SPELL in "$@"; do
run_details
FILE="$INSTALL_CACHE/$SPELL-$VERSION-$BUILD.tar$EXTENSION"
[ ! -e "$FILE" ] && echo "Can't locate $FILE" && exit 1
echo echo $SPELL ...
echo "tar xjf \$CACHE/$SPELL-$VERSION-$BUILD.tar$EXTENSION -P"
done
}
function prepare_setup {
echo CACHE=$CACHE
echo SPOOL=$SPOOL
echo
ls_cached_spell $BASIC_PACKAGES
echo
ls_cached_spell $OTHER_PACKAGES
echo
echo ldconfig
echo
echo cd /root
echo tar xjf \$SPOOL/sorcery-devel.tar.bz2
echo cd sorcery
echo ./install
}
prepare_setup > root/jail_setup_inside
echo; echo; echo Run as root:; echo
echo mount --bind /var/cache/sorcery $ROOT$CACHE
echo mount --bind /var/spool/sorcery $ROOT$SPOOL
echo mount --bind /dev $ROOT/dev
echo mount --bind /proc $ROOT/proc
echo chroot $ROOT /sbin/ldconfig
echo 'PS1="CHROOT \$(pwd):"' chroot $ROOT /bin/bash
#vim
. jail_params
[ ! -d $ROOT ] && echo "$ROOT does not exist" && exit
umount $ROOT/$CACHE
umount $ROOT/$SPOOL
umount $ROOT/dev
umount $ROOT/proc
echo
echo Now do:
echo rm -rf $ROOT
Attachment:
pgpYgUHNHoN5Q.pgp
Description: PGP signature
- [SM-Discuss] chroot playground, Vladimír Marek, 05/14/2004
Archive powered by MHonArc 2.6.24.