root/current/host/trunk/emdebian-tools/trunk/pbuilder/emsandbox

Revision 4783, 4.1 kB (checked in by codehelp, 5 months ago)

pbuilder/emsandbox pbuilder/embootstrap : add support for -S|--suite
to allow building root filesystems from the Emdebian target testing
repository

  • Property svn:executable set to *
Line 
1#!/bin/bash
2set -e
3#  emsandbox : emdebian roots creation.
4#
5#  Copyright (C) 2006-2008  Neil Williams <codehelp@debian.org>
6#
7#  This package is free software; you can redistribute it and/or modify
8#  it under the terms of the GNU General Public License as published by
9#  the Free Software Foundation; either version 3 of the License, or
10#  (at your option) any later version.
11#
12#  This program is distributed in the hope that it will be useful,
13#  but WITHOUT ANY WARRANTY; without even the implied warranty of
14#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15#  GNU General Public License for more details.
16#
17#  You should have received a copy of the GNU General Public License
18#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19#
20
21# the name is not finalised
22PROG=emsandbox
23
24function usagehelp () {
25    # print out help message
26    cat <<EOF
27$PROG - cross-built chroot Emdebian rootfs builder
28version $OURVERSION
29
30Syntax: sudo $PROG [OPTIONS] [COMMAND]
31
32Commands:
33-?|-h|--help|--version:  print this help message and exit
34--create|create:         create a cross-built base tarball for ARCH
35
36Options:
37-a|--arch:               Override the default cross-build architecture (from dpkg-cross).
38-s|--script FILENAME:    Override the default package set and second-stage install.
39-S|--suite NAME:         Override the default suite [unstable]
40-m|--machine NAME:       Specify a machine name for customisation hooks
41-v|--variant NAME:       Specify a machine variant name for customisation hooks
42   --machine-path PATH:  Specify a path to replace the $WORK/machine default
43
44Although based on debootstrap, $PROG cannot support the full range of
45debootstrap commands or options.
46
47Some customised $PROG scripts are provided with emdebian-tools. The
48default uses the standard Emdebian 'busybox' package with 'dpkg' and 'apt'.
49Replacement scripts need to be full debootstrap suite shell scripts that specify
50how to complete the first and second stage installations. If the script uses
51'busybox', the second-stage install function must be compatible with the
52shell applet in busybox - avoid bashisms!
53
54Overriding the default suite also configures the root filesystem to look
55for updates within the specified suite.
56
57EOF
58}
59
60. /usr/lib/emdebian-tools/empbuilderlib
61
62SUITE=unstable
63PACKAGE=
64EXTRA_BASE=""
65EXTRA_REQ=""
66MACHINE=
67VARIANT=
68FILENAME=
69
70get_work_dir
71get_default_arch
72
73check_sudo()
74{
75        # test for sudo - normally empdebuild is installed in /usr/sbin so this
76        # test is really only for SVN users.
77        # make sure sudo is in use.
78        # bash cannot seem to do this when set -e is enabled
79        # because grep returns non-zero on a non-match
80        # so I use perl. :-)
81        ISSUDOSET=`perl -e '$e=\`printenv\`; ($e =~ /SUDO_USER/) ? print "yes" : print "no";'`
82        if [ $ISSUDOSET == "no" ] ; then
83                echo "$PROG needs to be run under sudo."
84                exit 2
85        fi
86}
87
88while [ -n "$1" ]; do
89case "$1" in
90        --help|-h|-\?|--version)
91                usagehelp
92                exit;
93        ;;
94        -a|--arch)
95                shift
96                ARCH=$1
97                # chomp the argument to --arch
98                shift
99        ;;
100        --create|create)
101                shift;
102        ;;
103        -s|--script)
104                shift
105                FILENAME=$1
106                shift
107        ;;
108        -S|--suite)
109                shift
110                SUITE=$1
111                shift
112        ;;
113        -m|--machine)
114                shift
115                MACHINE=$1
116                shift
117        ;;
118        -v|--variant)
119                shift
120                VARIANT=$1
121                shift
122        ;;
123        --machine-path)
124                shift
125                MACHINEPATH=$1
126                shift
127        ;;
128        *)
129                echo "Unrecognised option: $1"
130                echo
131                usagehelp
132                exit;
133        ;;
134esac
135done
136
137if [ $INCLUDE ]; then
138        INCLUDE="--include=$1"
139fi
140
141if [ $MACHINEPATH ]; then
142        CUSTOM="--machine-path $MACHINEPATH"
143fi
144
145if [ $MACHINE ]; then
146        CUSTOM+=" --machine $MACHINE"
147fi
148
149if [ $VARIANT ]; then
150        CUSTOM+=" --variant $VARIANT"
151fi
152
153if [ "$ARCH" = "None." ]; then
154        echo Error: No default architecture has been set.
155        echo Use the --arch option or \'sudo dpkg-reconfigure dpkg-cross\'
156        exit
157fi
158
159checkarch
160check_sudo
161CROSS=$ARCH
162if [ "x$SUITE" != "xunstable" ]; then
163        CUSTOM+=" --suite $SUITE"
164fi
165BASETGZ="${WORKDIR}/emdebian-$ARCH.tgz"
166if [ $FILENAME ]; then
167        BASETGZ="${WORKDIR}/$FILENAME"
168        /usr/lib/emdebian-tools/embootstrap --arch $ARCH --cross --script $FILENAME $CUSTOM $INCLUDE
169        echo " -> embootstrap complete"
170else
171        /usr/lib/emdebian-tools/embootstrap --arch $ARCH --cross $CUSTOM
172fi
Note: See TracBrowser for help on using the browser.