Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=13fc0c144781da632c71f53c76ee9720769af891
commit 13fc0c144781da632c71f53c76ee9720769af891 Author: Michel Hermier <[email protected]> Date: Tue Nov 27 11:50:37 2012 +0100 scripts/makepkg * New chroot command to enter chroot and fakeroot if required and perform action, it no command parameters are given have the default behaviour of chroot and fakeroot (spawn a shell). diff --git a/scripts/makepkg b/scripts/makepkg index 3e5a3eb..2d35cfb 100755 --- a/scripts/makepkg +++ b/scripts/makepkg @@ -1980,7 +1980,7 @@ makepkg_ccache() { while [ $# -gt 0 ]; do consumed=1 case "$1" in - --clean) ccache_clean_list+=("$2"); consumed=2 ;; + --clean) clean_list+=("$2"); consumed=2 ;; --clean-all) clean_all=1 ;; -h|--help) makepkg_ccache_usage; return 0 ;; # special options @@ -2008,7 +2008,7 @@ makepkg_ccache() { msg "Cleaning up the compiler cache." CCACHE_DIR="$CCACHE_BASEDIR" ccache -C else - for i in "$@"; do + for i in "${clean_list[@]}"; do if [ -n "$cache" -a -d "$CCACHE_BASEDIR/$i" ]; then msg "$cache: Cleaning up the compiler cache." CCACHE_DIR="$CCACHE_BASEDIR/$i" ccache -C @@ -2020,6 +2020,70 @@ makepkg_ccache() { return 0 } +makepkg_chroot_usage() { + $ECHO "makepkg" + $ECHO + $ECHO "Usage: $0 chroot [options] [command [args]...]" + $ECHO + $ECHO "Options for chroot command:" + $ECHO " --chroot <name> Enter in the chroot <name>." + $ECHO " --userspec <spec> See chroot userspec option." + $ECHO " --fakeroot Enter in fakeroot." + $ECHO " -h, --help This help" +} + +makepkg_chroot() { + local cmd consumed inchroot infakeroot=0 + + while [ $# -gt 0 ]; do + consumed=1 + case "$1" in + --chroot) inchroot="$2"; consumed=2 ;; + --userspec) userspec="$2"; consumed=2 ;; + --fakeroot) infakeroot=1 ;; + -h|--help) makepkg_do_usage; return 0 ;; +# special options + --) shift; break;; # End of options + --*|-?) makepkg_ccache_usage; return 1 ;; + -*) # Combined short options + split="$1" + shift + set -- \ + "$(echo "$split}" | cut -c -2)" \ + "-$(echo "${split}" | cut -c 3-)" \ + "$@" + continue ;; + *) break ;; # End of options + esac + if ! shift "$consumed"; then + consumed=$(($consumed - 1)) + error "Option $1 expects $consumed argument(s)" + return 1 + fi + done + + if [ -n "$inchroot" ]; then + if [ -n "$FAKEROOTKEY" ]; then + error "Cowardly refuse to chroot while in fakeroot!" + return 1 + fi + cmd+=('INCHROOT=1' 'chroot') + if [ -n "$userspec" ]; then + cmd+=("--userspec=$userspec") + fi + cmd+=("$CHROOTDIR/$inchroot") + fi + if [ $infakeroot -eq 1 ]; then + if [ -n "$FAKEROOTKEY" ]; then + error "Cowardly refuse to fakeroot while in fakeroot!" + return 1 + fi + cmd+=('fakeroot') + fi + "${cmd[@]}" "$@" + return $? +} + makepkg_clean() { return 1 } @@ -2033,6 +2097,7 @@ makepkg_main() { case "$1" in build) shift; makepkg_build_cmd "$@" ;; ccache) shift; makepkg_ccache "$@" ;; + chroot) shift; makepkg_chroot "$@" ;; clean) shift; makepkg_clean "$@" ;; install) shift; makepkg_install "$@" ;; *) makepkg_build_cmd ;; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
