~ubuntu-branches/ubuntu/breezy/debootstrap/breezy

« back to all changes in this revision

Viewing changes to debootstrap

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, warty
  • Date: 2004-10-13 00:02:10 UTC
  • Revision ID: james.westby@ubuntu.com-20041013000210-6kxir6wy5l3x0qm0
Tags: 0.2.39ubuntu22
[warty] Remove pcmcia-cs from Base.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
 
 
3
unset TMP TEMP TMPDIR || true
 
4
 
 
5
if [ "$DEBOOTSTRAP_DIR" = "" ]; then
 
6
    DEBOOTSTRAP_DIR=/usr/lib/debootstrap
 
7
fi
 
8
 
 
9
if [ -x "/usr/bin/gettext" ]; then
 
10
    USE_GETTEXT_INTERACTION=yes
 
11
fi
 
12
 
 
13
DEVICES_TARGZ=$DEBOOTSTRAP_DIR/devices.tar.gz
 
14
 
 
15
. $DEBOOTSTRAP_DIR/functions
 
16
 
 
17
GETTEXT_LANG=$LANG
 
18
LANG=C
 
19
USE_COMPONENTS=main
 
20
VARIANT=""
 
21
DEBCONF_ADMIN_EMAIL=""
 
22
 
 
23
export LANG USE_COMPONENTS DEBCONF_ADMIN_EMAIL
 
24
umask 022
 
25
 
 
26
usage_err()
 
27
{
 
28
  info USAGE1 "usage: [OPTION]... <suite> <target> [<mirror> [<script>]]"
 
29
  info USAGE2 "Try \`${0##*/} --help' for more information."
 
30
  error "$@"
 
31
}
 
32
 
 
33
usage()
 
34
{
 
35
    echo "Usage: ${0##*/} [OPTION]... <suite> <target> [<mirror> [<script>]]"
 
36
    echo "Bootstrap Debian base system."
 
37
    echo
 
38
    cat <<EOF
 
39
      --arch                 set the target architecture (use if no dpkg)
 
40
                               [ --arch powerpc ]
 
41
      --download-only        download packages, but don't perform installation
 
42
      --print-debs           print the packages to be installed, and exit
 
43
      --unpack-tarball       acquire .debs from a tarball instead of http
 
44
      --boot-floppies        used for internal purposes by boot-floppies
 
45
      --debian-installer     used for internal purposes by debian-installer
 
46
      --help                 display this help and exit
 
47
      --include=A,B,C        adds specified names to the list of base packages
 
48
      --exclude=A,B,C        removes specified packages from the list
 
49
      --verbose              don't turn off the output of wget
 
50
      --components=A,B,C     use packages from the listed components of the 
 
51
                             archive
 
52
      --variant=X            use variant X of the bootstrap scripts
 
53
                             (currently supported variants: buildd)
 
54
EOF
 
55
}
 
56
 
 
57
if [ $# != 0 ] ; then
 
58
  while true ; do
 
59
    case "$1" in
 
60
        --help)
 
61
          usage
 
62
          exit 0
 
63
          ;;
 
64
        --boot-floppies)
 
65
          if [ -n "$USE_DEBIANINSTALLER_INTERACTION" ] ; then
 
66
            error 1 ARG_BFDI "Can only use one of --boot-floppies and --debian-installer"
 
67
          fi
 
68
          if ! (echo -n "" >&3) 2>/dev/null; then
 
69
            error 1 ARG_BFBYHAND "If running debootstrap by hand, don't use --boot-floppies"
 
70
          fi
 
71
          USE_BOOTFLOPPIES_INTERACTION=yes
 
72
          shift
 
73
          ;;
 
74
        --debian-installer)
 
75
          if [ -n "$USE_BOOTFLOPPIES_INTERACTION" ] ; then
 
76
            error 1 ARG_BFDI "Can only use one of --boot-floppies and --debian-installer"
 
77
          fi
 
78
          if ! (echo -n "" >&3) 2>/dev/null; then
 
79
            error 1 ARG_DIBYHAND "If running debootstrap by hand, don't use --debian-installer"
 
80
          fi
 
81
          USE_DEBIANINSTALLER_INTERACTION=yes
 
82
          shift
 
83
          ;;
 
84
        --print-debs)
 
85
          JUST_PRINT_DEBS=yes
 
86
          shift
 
87
          ;;
 
88
        --download-only)
 
89
          DOWNLOAD_ONLY=yes
 
90
          shift
 
91
          ;;
 
92
        --arch)
 
93
          if [ -n "$2" ] ; then
 
94
            ARCH="$2"
 
95
            shift 2
 
96
          else
 
97
            error 1 NEEDARG "option requires an argument %s" "$1"
 
98
          fi
 
99
          ;;
 
100
        --unpack-tarball)
 
101
          if [ -n "$2" ] ; then
 
102
            if [ ! -f "$2" ] ; then
 
103
              error 1 NOTARBALL "%s: No such file or directory" "$2"
 
104
            fi
 
105
            UNPACK_TARBALL="$2"
 
106
            shift 2
 
107
          else
 
108
            error 1 NEEDARG "option requires an argument %s" "$1"
 
109
          fi
 
110
          ;;
 
111
  --include*)
 
112
    additional="$(echo $1 | cut -f2 -d"="|tr , " ")"
 
113
    shift 1
 
114
    ;;
 
115
  --exclude*)
 
116
    exclude="$(echo $1 | cut -f2 -d"="|tr , " ")"
 
117
    shift 1
 
118
    ;;
 
119
  --verbose)
 
120
    verbose=true
 
121
    export verbose
 
122
    shift 1
 
123
    ;;
 
124
  --components*)
 
125
    USE_COMPONENTS="$(echo "$1" | cut -f2 -d"="|tr , "|")"
 
126
    export USE_COMPONENTS
 
127
    shift 1
 
128
    ;;
 
129
  --variant*)
 
130
    VARIANT="$(echo "$1" | cut -f2 -d"=")"
 
131
    shift 1
 
132
    ;;
 
133
        *)
 
134
          break
 
135
          ;;
 
136
    esac
 
137
  done
 
138
else
 
139
  usage_err 1 NEEDSUITETARGET "You must specify a suite and a target."
 
140
fi
 
141
 
 
142
if [ "$1" = "" -o \( "$2" = "" -a "$JUST_PRINT_DEBS" = "" \) ]; then
 
143
  usage_err 1 NEEDSUITETARGET "You must specify a suite and a target."
 
144
fi
 
145
 
 
146
SUITE="$1"
 
147
TARGET="$2"
 
148
if [ "${TARGET#/}" = "${TARGET}" ]; then
 
149
  if [ "${TARGET%/*}" = "$TARGET" ] ; then
 
150
    TARGET="$(echo `pwd`/$TARGET)"
 
151
  else
 
152
    TARGET="$(cd ${TARGET%/*}; echo `pwd`/${TARGET##*/})"
 
153
  fi
 
154
fi
 
155
 
 
156
MIRRORS="http://ftp.debian.org/debian"
 
157
SCRIPT="$DEBOOTSTRAP_DIR/scripts/$1"
 
158
if [ -n "$VARIANT" ]; then
 
159
    SCRIPT="${SCRIPT}.${VARIANT}"
 
160
fi
 
161
if [ "$3" != "" ]; then
 
162
  MIRRORS="$3"
 
163
  if [ "$4" != "" ]; then
 
164
    SCRIPT="$4"
 
165
  fi
 
166
fi
 
167
 
 
168
# Remove trailing /'s
 
169
TARGET="${TARGET%/}"
 
170
MIRRORS="${MIRRORS%/}"
 
171
 
 
172
if [ "$ARCH" != "" ]; then
 
173
        true
 
174
elif [ -x /usr/bin/dpkg ] && /usr/bin/dpkg --print-installation-architecture >/dev/null 2>&1
 
175
then
 
176
        ARCH=`/usr/bin/dpkg --print-installation-architecture`
 
177
elif [ -e $DEBOOTSTRAP_DIR/arch ]; then
 
178
        ARCH=`cat $DEBOOTSTRAP_DIR/arch`
 
179
else
 
180
        error 1 WHATARCH "Couldn't work out current architecture"
 
181
fi
 
182
 
 
183
export MIRRORS ARCH SUITE TARGET
 
184
 
 
185
if [ "$JUST_PRINT_DEBS" = "" -a "$DOWNLOAD_ONLY" = "" -a -x /usr/bin/id ] && [ `id -u` -ne 0 ]; then
 
186
  error 1 NEEDROOT "debootstrap can only run as root"
 
187
fi
 
188
 
 
189
if [ ! -e "$SCRIPT" ]; then
 
190
  error 1 NOSCRIPT "No such script: %s" "$SCRIPT"
 
191
fi
 
192
 
 
193
mkdir -p "$TARGET"
 
194
 
 
195
PKGDETAILS=$DEBOOTSTRAP_DIR/pkgdetails
 
196
 
 
197
if [ "$UNPACK_TARBALL" ]; then
 
198
  if [ "${UNPACK_TARBALL#/}" = "$UNPACK_TARBALL" ]; then
 
199
    error 1 TARPATH "Tarball must be given a complete path"
 
200
  fi
 
201
  if [ "${UNPACK_TARBALL%.tar}" != "$UNPACK_TARBALL" ]; then
 
202
    (cd "$TARGET" && tar -xf "$UNPACK_TARBALL")
 
203
  elif [ "${UNPACK_TARBALL%.tgz}" != "$UNPACK_TARBALL" ]; then
 
204
    (cd "$TARGET" && zcat "$UNPACK_TARBALL" | tar -xf -)
 
205
  else
 
206
    error 1 NOTTAR "Unknown tarball: must be either .tar or .tgz"
 
207
  fi
 
208
fi
 
209
 
 
210
. "$SCRIPT"
 
211
 
 
212
work_out_debs
 
213
 
 
214
if [ "$JUST_PRINT_DEBS" ]; then
 
215
  echo "$all_debs"
 
216
  exit 0
 
217
fi
 
218
 
 
219
download $all_debs
 
220
 
 
221
if [ "$DOWNLOAD_ONLY" ]; then
 
222
  exit 0
 
223
fi
 
224
 
 
225
install_debs
 
226
 
 
227
if [ -e "$TARGET/etc/apt/sources.list" ]; then
 
228
  rm -f "$TARGET/etc/apt/sources.list"
 
229
fi
 
230
 
 
231
sync
 
232
 
 
233
if [ -n "$USE_BOOTFLOPPIES_INTERACTION" ] ; then
 
234
  echo "I: debootstrap: Successfully completed" # goes to /dev/tty4
 
235
  sleep 1 || true # give the user a second to see the success notice.
 
236
fi
 
237