diff options
author | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2011-05-16 19:14:47 -0300 |
---|---|---|
committer | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2011-05-16 19:14:47 -0300 |
commit | bf87a77517cb5d960865faaf820decaa338c4f63 (patch) | |
tree | 6c10ea4f2a80ae3d5df3ae08b40f6ad5c9195ed6 /librechroot | |
parent | 56e183631d6e4e12df4990d119456dd81423938e (diff) | |
parent | 76c75b8971e4ad2f6c336c9413088e6fd0e70f69 (diff) |
Merge branch 'master' of ssh://vparabola/srv/git/projects/libretools
Conflicts:
libremakepkg
Diffstat (limited to 'librechroot')
-rwxr-xr-x | librechroot | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/librechroot b/librechroot index ec437de..b308b7d 100755 --- a/librechroot +++ b/librechroot @@ -23,6 +23,19 @@ source /etc/libretools.conf +function usage { + echo "Usage: $0 chrootname" + echo "Change to a chroot in $CHROOTDIR. Use it as root." + echo + echo "Default chroot name: $CHCOPY" +} + +while getopts 'h' arg; do + case $arg in + h) usage; exit 0 ;; + esac +done + [[ "$UID" != "0" ]] && { error "This script must be run as root." exit 1 @@ -32,28 +45,28 @@ custom_config=${XDG_CONFIG_HOME}/libretools/libretools.conf [[ -e ${custom_config} ]] && source ${custom_config} # Enter the chroot copy by default -root=${1:-$CHCOPY} +chrootname=${1:-$CHCOPY} CACHEDIR=${CACHEDIR:-/var/cache/pacman/pkg} -[[ ! -d ${CHROOTDIR}/${root} ]] && { - error "${CHROOTDIR}/$root is not a dir." +[[ ! -d ${CHROOTDIR}/${chrootname} ]] && { + error "${CHROOTDIR}/${chrootname} is not a dir." exit 1 } -mount -t proc proc ${CHROOTDIR}/${root}/proc/ -mount -t sysfs sys ${CHROOTDIR}/${root}/sys/ -mount -o bind /dev ${CHROOTDIR}/${root}/dev/ +mount -t proc proc ${CHROOTDIR}/${chrootname}/proc/ +mount -t sysfs sys ${CHROOTDIR}/${chrootname}/sys/ +mount -o bind /dev ${CHROOTDIR}/${chrootname}/dev/ # Share pacman cache -mount -o bind ${CACHEDIR} ${CHROOTDIR}/${root}/var/cache/pacman/pkg +mount -o bind ${CACHEDIR} ${CHROOTDIR}/${chrootname}/var/cache/pacman/pkg -cp -L /etc/resolv.conf ${CHROOTDIR}/${root}/etc/resolv.conf +cp -L /etc/resolv.conf ${CHROOTDIR}/${chrootname}/etc/resolv.conf -chroot ${CHROOTDIR}/${root} /bin/bash +chroot ${CHROOTDIR}/${chrootname} /bin/bash -umount ${CHROOTDIR}/${root}/proc/ -umount ${CHROOTDIR}/${root}/sys/ -umount ${CHROOTDIR}/${root}/dev/ -umount ${CHROOTDIR}/${root}/var/cache/pacman/pkg +umount ${CHROOTDIR}/${chrootname}/proc/ +umount ${CHROOTDIR}/${chrootname}/sys/ +umount ${CHROOTDIR}/${chrootname}/dev/ +umount ${CHROOTDIR}/${chrootname}/var/cache/pacman/pkg exit 0 |