From e9bc885c355babf7851de31db8e1920dde752993 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 7 Nov 2012 00:17:08 -0500 Subject: organize the files --- src/chroot-tools/libremkchroot | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 src/chroot-tools/libremkchroot (limited to 'src/chroot-tools/libremkchroot') diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot new file mode 100755 index 0000000..b576209 --- /dev/null +++ b/src/chroot-tools/libremkchroot @@ -0,0 +1,64 @@ +#!/bin/bash +# LibreMkChroot +# Creates a chroot + +# Copyright 2011, 2012 Luke Shumaker + +# ---------- GNU General Public License 3 ---------- + +# This file is part of Parabola. + +# Parabola is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# Parabola is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# 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 + +cmd=${0##*/} +function usage { + echo "Usage: $cmd [OPTIONS]" + 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 '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 ;; + esac +done + +if (( EUID )); then + error "This script must be run as root" + exit 1 +fi + +mkdir -p "${CHROOTDIR}" +xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/root" < /etc/libretools.d/cleansystem -- cgit v1.2.3-2-g168b 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.3-2-g168b From 8398652c850196d05e6ad9120d93993bebd6e918 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 18:55:23 -0500 Subject: libremkchroot: don't use cleansystem --- src/chroot-tools/libremkchroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/chroot-tools/libremkchroot') diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index 48b255a..cc5b431 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -64,7 +64,7 @@ main() { fi mkdir -p "${CHROOTDIR}/${CHROOT}" - xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" < /etc/libretools.d/cleansystem + mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" base base-devel sudo "${CHROOTEXTRAPKG[@]}" } main "$@" -- cgit v1.2.3-2-g168b From fd1e5a426713715d9c0e3fabbfe0d8a20b629bad Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 15:18:44 -0500 Subject: chroot-tools: disable overriding CHROOTDIR at the command line --- src/chroot-tools/libremkchroot | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/chroot-tools/libremkchroot') diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index cc5b431..08f69b1 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -35,7 +35,6 @@ usage() { echo 'Options:' echo ' -h Show this message' echo '' - echo ' -d Use this dir instead of "$CHROOTDIR".' echo ' -C Location of pacman config file.' echo ' -M Location of makepkg config file.' } @@ -45,7 +44,6 @@ main() { 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;; -- cgit v1.2.3-2-g168b From 00d67a5051e5d4163acffa80b7ef85f81f7e548f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 15:20:59 -0500 Subject: take (some) advantage of chroottools, fix some compatability things mkarchroot/archroot's option parsing is a little less flexible (but a lot more understandable) than it was before. --- src/chroot-tools/libremkchroot | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/chroot-tools/libremkchroot') diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index 08f69b1..3072b9e 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -40,10 +40,10 @@ usage() { } main() { - mkarchroot_args=(); + archroot_args=(); while getopts 'hfd:C:M:' arg; do case "$arg" in - C|M) mkarchroot_args+=("-$arg" "$OPTARG");; + C|M) archroot_args+=("-$arg" "$OPTARG");; h) usage; exit 0;; *) usage; exit 1;; @@ -62,7 +62,7 @@ main() { fi mkdir -p "${CHROOTDIR}/${CHROOT}" - mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" base base-devel sudo "${CHROOTEXTRAPKG[@]}" + archroot "${chroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}" } main "$@" -- cgit v1.2.3-2-g168b From 56f394ecbe65b5aba13759237f8a6cbc645e5e3d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 19:17:19 -0500 Subject: fix getopts for libremkchroot --- src/chroot-tools/libremkchroot | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/chroot-tools/libremkchroot') diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index 3072b9e..992c6e5 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -1,23 +1,20 @@ #!/bin/bash -# LibreMkChroot -# Creates a chroot +# libremkchroot # Copyright 2011, 2012 Luke Shumaker - -# ---------- GNU General Public License 3 ---------- - +# # This file is part of Parabola. - +# # Parabola is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. - +# # Parabola is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. - +# # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . @@ -41,7 +38,7 @@ usage() { main() { archroot_args=(); - while getopts 'hfd:C:M:' arg; do + while getopts 'hC:M:' arg; do case "$arg" in C|M) archroot_args+=("-$arg" "$OPTARG");; -- cgit v1.2.3-2-g168b From 06f10b87d16d4c83016ff3ef21217494f921d93b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 22:10:26 -0500 Subject: many fixes --- src/chroot-tools/libremkchroot | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/chroot-tools/libremkchroot') diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index 992c6e5..d3652a5 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -euE # libremkchroot # Copyright 2011, 2012 Luke Shumaker @@ -37,7 +37,7 @@ usage() { } main() { - archroot_args=(); + archroot_args=(-f); while getopts 'hC:M:' arg; do case "$arg" in C|M) archroot_args+=("-$arg" "$OPTARG");; @@ -59,7 +59,7 @@ main() { fi mkdir -p "${CHROOTDIR}/${CHROOT}" - archroot "${chroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}" + archroot "${archroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}" } main "$@" -- cgit v1.2.3-2-g168b