summaryrefslogtreecommitdiff
path: root/chroot-bootstrap.sh
blob: f23e0b2b346ea74e9236e8de2b181fd8fe5442f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
MAPLE=$(pwd)/maple

run_chroot() {
    SHELL=/bin/sh
    if [ -e $MAPLE/bin/zsh ]; then
        SHELL=/bin/zsh
    fi
    chroot $MAPLE $SHELL
}

if mount --rbind /dev $MAPLE/dev && mount --make-rslave $MAPLE/dev; then
    if mount -t proc /proc $MAPLE/proc; then
        if mount --rbind /sys $MAPLE/sys && mount --make-rslave $MAPLE/sys; then
            if mount --rbind /tmp $MAPLE/tmp; then
                if mount --bind /run $MAPLE/run; then
                    if [ -d $MAPLE/maple/sources ]; then
                        if mount --bind ./sources $MAPLE/maple/sources; then
                            if [ -d $MAPLE/maple/patches ]; then
                                if mount --bind ./patches $MAPLE/maple/patches; then
                                    run_chroot
                                    umount $MAPLE/maple/patches
                                fi
                            else
                                run_chroot
                            fi
                            umount $MAPLE/maple/sources
                        fi
                    else
                        run_chroot
                    fi
                    umount $MAPLE/run
                fi
                umount $MAPLE/tmp
            fi
            umount -R $MAPLE/sys
        fi
        umount $MAPLE/proc
    fi
    umount -R $MAPLE/dev
fi