From 16e41597e98333f6383a3cb9aa6e9371f64522bf Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 17:32:40 -0500 Subject: chroot-tools: clean up, make play nice with new devtools * buildenv: delete; this is done by `mkarchroot` * librechroot: - adopt `archbuild`'s concept of CHROOT and CHROOTCOPY - add `-l` option to set the CHROOTCOPY * libremakepkg: - adopt `archbuild`'s concept of CHROOT and CHROOTCOPY - add `-l` option to set the CHROOTCOPY - pass options to `makechrootpkg` and `makepkg` the way `-h` always said it did * libremkchroot: - adopt `archbuild`'s concept of CHROOT and CHROOTCOPY - remove `-c` option to set the pacman cache - remove `-f` option to force overwrite --- src/chroot-tools/libremkchroot | 56 +++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 25 deletions(-) (limited to 'src/chroot-tools/libremkchroot') diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index b576209..48b255a 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -21,44 +21,50 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -source /etc/libretools.conf - -if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then - source "$XDG_CONFIG_HOME/libretools/libretools.conf" -fi +. /etc/libretools.conf cmd=${0##*/} -function usage { - echo "Usage: $cmd [OPTIONS]" + +usage() { + echo "Usage: $cmd [OPTIONS] [CHROOT]" echo 'This script will create a chroot to build packages in.' echo "Use \`librechroot' to interact with the chroot after it is created." echo '' + echo "The default CHROOT is \`${CHROOT}'." + echo '' echo 'Options:' echo ' -h Show this message' echo '' - echo ' -f Force overwrite of files in the working-dir' - echo '' echo ' -d Use this dir instead of "$CHROOTDIR".' - echo " -c Location of pacman cache. Default: \`/var/cache/pacman/pkg'." echo ' -C Location of pacman config file.' echo ' -M Location of makepkg config file.' } -mkchroot_args=(); -while getopts 'hfd:c:C:M:' arg; do - case "$arg" in - h) usage; exit 0 ;; - f) mkchroot_args+=("-$arg");; - c|C|M) mkchroot_args+=("-$arg" "$OPTARG");; - d) CHROOTDIR=$OPTARG ;; - ?) usage; exit 1 ;; +main() { + mkarchroot_args=(); + while getopts 'hfd:C:M:' arg; do + case "$arg" in + C|M) mkarchroot_args+=("-$arg" "$OPTARG");; + d) CHROOTDIR=$OPTARG;; + + h) usage; exit 0;; + *) usage; exit 1;; + esac + done + shift $(($OPTIND - 1)) + case $# in + 0) :;; + 1) CHROOT="$1";; + *) usage; exit 1;; esac -done -if (( EUID )); then - error "This script must be run as root" - exit 1 -fi + if (( EUID )); then + error "This script must be run as root" + exit 1 + fi + + mkdir -p "${CHROOTDIR}/${CHROOT}" + xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" < /etc/libretools.d/cleansystem +} -mkdir -p "${CHROOTDIR}" -xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/root" < /etc/libretools.d/cleansystem +main "$@" -- cgit v1.2.2