source: live-build/trunk/fuentes/scripts/build/lb_bootstrap_debootstrap @ 900

Last change on this file since 900 was 900, checked in by kbut, 3 years ago

add original source

  • Property svn:executable set to *
File size: 4.7 KB
Line 
1#!/bin/sh
2
3## live-build(7) - System Build Scripts
4## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
5##
6## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7## This is free software, and you are welcome to redistribute it
8## under certain conditions; see COPYING for details.
9
10
11set -e
12
13# Including common functions
14( . "${LIVE_BUILD}/scripts/build.sh" > /dev/null 2>&1 || true ) || . /usr/lib/live/build.sh
15
16# Setting static variables
17DESCRIPTION="$(Echo 'bootstrap a Debian system with debootstrap(8)')"
18HELP=""
19USAGE="${PROGRAM} [--force]"
20
21Arguments "${@}"
22
23# Reading configuration files
24Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
25Set_defaults
26
27if [ "${LB_BOOTSTRAP}" != "debootstrap" ]
28then
29        exit 0
30fi
31
32# Check architecture
33Check_crossarchitectures
34
35Echo_message "Begin bootstrapping system..."
36
37Check_package /usr/sbin/debootstrap debootstrap
38
39# Ensure that a system is built as root
40lb testroot
41
42# Checking stage file
43Check_stagefile .build/bootstrap
44Check_stagefile .build/bootstrap_cache.restore
45
46# Checking lock file
47Check_lockfile .lock
48
49# Creating lock file
50Create_lockfile .lock
51
52# Creating chroot directory
53mkdir -p chroot
54
55# Temporarily including bzip2 manually until #657560 has been fixed in unstable
56DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --include=bzip2"
57
58# Setting debootstrap options
59if [ -n "${LB_ARCHITECTURES}" ]
60then
61        DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --arch=${LB_ARCHITECTURES}"
62fi
63
64if [ "${LB_ARCHIVE_AREAS}" != "main" ]
65then
66        # Modify archive areas to remove leading/trailing whitespaces and replace other whitepspace with commas
67        DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --components=$(echo ${LB_ARCHIVE_AREAS} | sed -e 's| |,|g')"
68fi
69
70if [ -n "${LB_BOOTSTRAP_INCLUDE}" ]
71then
72        DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --include=$(echo ${LB_BOOTSTRAP_INCLUDE} | sed 's|  *|,|g')"
73fi
74
75if [ -n "${LB_BOOTSTRAP_EXCLUDE}" ]
76then
77        DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --exclude=$(echo ${LB_BOOTSTRAP_EXCLUDE} | sed 's|  *|,|g')"
78fi
79
80case "${LB_USE_FAKEROOT}" in
81        true)
82                DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --variant=fakechroot"
83                ;;
84        false)
85                if [ -n "${LB_BOOTSTRAP_FLAVOUR}" ]
86                then
87                        case "${LB_BOOTSTRAP_FLAVOUR}" in
88                                minimal)
89                                        DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --variant=minbase"
90                                        ;;
91
92                                standard)
93                                        ;;
94
95                                *)
96                                        DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --variant=${LB_BOOTSTRAP_FLAVOUR}"
97                                        ;;
98                        esac
99                fi
100                ;;
101esac
102
103if [ "${_VERBOSE}" = "true" ]
104then
105        DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --verbose"
106fi
107
108# If LB_APT_SECURE is false, do not check signatures of the Release file
109# (requires debootstrap >= 1.0.30)
110if [ "${LB_APT_SECURE}" = "false" ] && /usr/sbin/debootstrap --help  | grep -qs '\-\-no-check-gpg'
111then
112        DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --no-check-gpg"
113fi
114
115if [ -x "/usr/sbin/debootstrap" ]
116then
117        if [ "${LB_CACHE_PACKAGES}" = "true" ]
118        then
119                if ls cache/packages.bootstrap/*.deb > /dev/null 2>&1
120                then
121                        mkdir -p chroot/var/cache/apt/archives
122                        cp cache/packages.bootstrap/*.deb chroot/var/cache/apt/archives
123                fi
124
125                Echo_breakage "Running debootstrap (download-only)... "
126                ${LB_ROOT_COMMAND} debootstrap ${DEBOOTSTRAP_OPTIONS} --download-only "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
127
128                if [ -n "${LB_ROOT_COMMAND}" ]
129                then
130                        ${LB_ROOT_COMMAND} chown -R $(whoami):$(whoami) chroot
131                fi
132
133                # Removing old cache
134                rm -f cache/packages.bootstrap/*.deb
135
136                # Saving new cache
137                mkdir -p cache/packages.bootstrap
138                cp chroot/var/cache/apt/archives/*.deb cache/packages.bootstrap
139        fi
140
141        Echo_breakage "Running debootstrap... "
142
143        # Run appropriate bootstrap, i.e. foreign or regular bootstrap
144        if [ "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" = "${LB_ARCHITECTURES}" ]; then
145
146                if [ -n "${LB_BOOTSTRAP_QEMU_EXCLUDE}" ]
147                then
148                        DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --exclude=$(echo ${LB_BOOTSTRAP_QEMU_EXCLUDE} | sed 's|  *|,|g')"
149                fi
150
151                Echo_message "Bootstrap will be foreign"
152                ${LB_ROOT_COMMAND} debootstrap ${DEBOOTSTRAP_OPTIONS} --foreign "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
153
154                Echo_message "Running debootstrap second stage under QEMU"
155                cp ${LB_BOOTSTRAP_QEMU_STATIC} chroot/usr/bin
156                Chroot chroot /bin/sh /debootstrap/debootstrap --second-stage
157        else
158                ${LB_ROOT_COMMAND} debootstrap ${DEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
159        fi
160
161        if [ -n "${LB_ROOT_COMMAND}" ]
162        then
163                ${LB_ROOT_COMMAND} chown -R $(whoami):$(whoami) chroot
164        fi
165
166        # Deconfiguring debootstrap configurations
167        rm -f chroot/etc/hosts
168
169        # Removing bootstrap cache
170        rm -f chroot/var/cache/apt/archives/*.deb
171
172        # Creating stage file
173        Create_stagefile .build/bootstrap
174else
175        Echo_error "Can't process file /usr/bin/debootstrap (FIXME)"
176        exit 1
177fi
Note: See TracBrowser for help on using the repository browser.