source: projects/vbootstrap/trunk/vchroot.sh.in @ 2718

Revision 2718, 2.2 KB checked in by munepi, 13 years ago (diff)

updated vbuilder: added --debug, --login options; applied vbootstrap-0.0.37-armhack.patch (Thanks to parrot-san)

  • Property svn:executable set to *
Line 
1#!/bin/bash
2# -*- coding: utf-8-unix -*-
3
4TEXTDOMAIN=vbootstrap
5TEXTDOMAINDIR=/usr/share/locale
6
7trap clean-vchroot EXIT
8
9Usage(){
10    cat<<EOF
11Usage:  $(basename $0) [OPTION...] [COMMAND] - run command or shell in a chroot
12
13Options:
14        --chroot:               use specified chroot [version] (default: ${DEFAULT_VERSION})
15$(/usr/sbin/vbootstrap | sed -e s/^Usage:.*// -e s/^E:.*//)
16EOF
17}
18
19##############################################################################
20
21. /usr/share/vbootstrap/libvbuilder.sh
22
23check-parameter(){
24    [ -z "$*" ] && Usage && return 1
25
26    while [ ! -z "$*" ]; do
27        case $1 in
28            --help|help)
29                Usage
30                return 1
31                ;;
32            --chroot)
33                shift
34                check-next-parameter $1 || return 1
35                ;;
36        esac
37        shift
38    done
39
40    return 0
41}
42
43check-next-parameter(){
44    [ -z "$1" ] && echo $"E: Missing some parameters after $1" && return 1
45
46    [ $(echo $1 | grep '^-') ] && \
47        echo $"E: Missing some parameters after $1" && return 1
48
49    return 0
50}
51
52clean-vchroot(){
53    # mount-chroot --umount /home
54    mount-chroot --umount /tmp
55    mount-chroot --umount vfs
56    mount-chroot  --umount archives_dir
57    apt-get-update --host
58
59    return 0
60}
61
62main(){
63    setup-vbootstrap || return 1
64
65    __chroot="/usr/sbin/chroot ${BUILD_ROOT}"
66    ## setarch ix86 if ix86 chroot on x86_64 host
67    [ $with_ix86_on_x86_64 -eq 1 ] && \
68        __chroot="/usr/sbin/chroot ${BUILD_ROOT} setarch ${VARCH}"
69
70    mount-chroot archives_dir
71    mount-chroot vfs
72    mount-chroot /tmp
73    # mount-chroot /home
74    apt-get-update --chroot
75
76    ## copy host's configurations of /etc
77    #passwd shadow group gshadow
78    for i in resolv.conf hosts; do
79        [ ! -f ${BUILD_ROOT}/etc/${i}.orig ] && \
80            cp -pf ${BUILD_ROOT}/etc/${i} ${BUILD_ROOT}/etc/${i}.orig && \
81            cp -pf /etc/${i} ${BUILD_ROOT}/etc
82    done
83    cp -Ppf /etc/localtime ${BUILD_ROOT}/etc
84
85    $__chroot $* || return 1
86   
87    return 0
88}
89
90##############################################################################
91
92# setup-vchroot || exit 1
93
94setup-vbuilder || exit 1
95
96check-parameter $* || exit 1
97
98while [ $# -gt 0 ]; do
99    tmpARG=$1
100    case $tmpARG in
101        --chroot|-c)
102            shift
103            ;;
104        *)
105            break
106            ;;
107    esac
108
109    case $tmpARG in
110        --chroot|-c)
111            VERSION=$1
112            ;;
113    esac
114    shift
115done
116
117main $* || exit 1
118
119exit
Note: See TracBrowser for help on using the repository browser.