]> git.wh0rd.org - home.git/blobdiff - .bin/custom-chroot
le-renew: switch to cryptography module
[home.git] / .bin / custom-chroot
index 324405cc915c28fc20f2c8adec911a80bb17d788..67da2eaa286fedeae1350c457bd906903d347aef 100755 (executable)
@@ -6,7 +6,13 @@ bootstrap() {
        if [[ -z ${UNSHARE} ]] ; then
                mount_args=
                if type -P unshare >&/dev/null ; then
-                       UNSHARE=true exec unshare -m -- "$0" "$@"
+                       test_arg() { unshare "$@" -- true >&/dev/null && uargs+=( "$@" ) || :; }
+                       uargs=( -m )
+                       test_arg -u
+                       test_arg -i
+                       test_arg -p -f --mount-proc
+                       test_arg --propagation=private
+                       UNSHARE=true exec unshare "${uargs[@]}" -- "$0" "$@"
                fi
        else
                mount_args='-n'
@@ -31,6 +37,13 @@ get_type() {
        *64-bit*PowerPC*) echo ppc64;;
        *32-bit*S/390*)   echo s390;;
        *64-bit*S/390*)   echo s390x;;
+       *64-bit*MIPS*)    echo mips64;;
+       *32-bit*MIPS*N32*)echo mips64;;
+       *32-bit*MIPS*)    echo mips;;
+       *32-bit*PA-RISC*) echo parisc;;
+       *64-bit*PA-RISC*) echo parisc64;;
+       *32-bit*SPARC*)   echo sparc;;
+       *64-bit*SPARC*)   echo sparc64;;
        esac
 }
 
@@ -68,9 +81,11 @@ init_chroot() {
                fi
        done
 
-       f="${HOME}/.profile.d/aliases.sh"
-       if [[ -e ${f} ]] ; then
-               cat "${f}" > root/.bash_profile
+       if [[ ! -d root/.git ]] ; then
+               f="${HOME}/.profile.d/aliases.sh"
+               if [[ -e ${f} ]] ; then
+                       cat "${f}" > root/.bash_profile
+               fi
        fi
 }
 
@@ -93,7 +108,7 @@ usage() {
 main() {
        bootstrap "$@"
 
-       local mounts=( proc sys tmp dev dev/pts dev/shm usr/portage usr/portage/distfiles usr/local/src )
+       local mounts=( proc sys tmp dev dev/pts dev/shm run usr/portage usr/portage/distfiles usr/local/src )
 
        local chroot=${0%/*}
        case ${chroot} in
@@ -107,7 +122,7 @@ main() {
                -u) cmd='umount' ;;
                -m) mounts+=( "$2" ); shift ;;
                -d) chroot=$(realpath "$2"); shift ;;
-               -h) usage ;;
+               --help|-h) usage ;;
                -*) echo "${0##*/}: unknown option $1"; exit 1 ;;
                *)  break ;;
                esac