source: live-build/trunk/fuentes/scripts/build/lb_bootstrap_cdebootstrap @ 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: 3.9 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 cdebootstrap(1)')"
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}" != "cdebootstrap" ] && [ "${LB_BOOTSTRAP}" != "cdebootstrap-static" ]
28then
29        exit 0
30fi
31
32# Check architecture
33Check_crossarchitectures
34
35Echo_message "Begin bootstrapping system..."
36
37Check_package /usr/bin/${LB_BOOTSTRAP} cdebootstrap
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
56CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --include=bzip2"
57
58# Setting cdebootstrap options
59if [ -n "${LB_ARCHITECTURES}" ]
60then
61        CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --arch=${LB_ARCHITECTURES}"
62fi
63
64if [ -n "${LB_BOOTSTRAP_INCLUDE}" ]
65then
66        CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --include=$(echo ${LB_BOOTSTRAP_INCLUDE} | sed 's|  *|,|g')"
67fi
68
69if [ -n "${LB_BOOTSTRAP_EXCLUDE}" ]
70then
71        CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --exclude=$(echo ${LB_BOOTSTRAP_EXCLUDE} | sed 's|  *|,|g')"
72fi
73
74if [ -n "${LB_BOOTSTRAP_KEYRING}" ]
75then
76        CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --keyring=${LB_BOOTSTRAP_KEYRING}"
77fi
78
79if [ -n "${LB_BOOTSTRAP_FLAVOUR}" ]
80then
81        CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --flavour=${LB_BOOTSTRAP_FLAVOUR}"
82fi
83
84if [ "${_DEBUG}" = "true" ]
85then
86        CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --debug"
87fi
88
89if [ "${_QUIET}" = "true" ]
90then
91        CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --quiet"
92fi
93
94if [ "${_VERBOSE}" = "true" ]
95then
96        CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --verbose"
97fi
98
99if [ "${LB_APT_SECURE}" = "false" ]
100then
101        CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --allow-unauthenticated"
102fi
103
104if [ -x "/usr/bin/cdebootstrap" ] || [ -x "/usr/bin/cdebootstrap-static" ]
105then
106        if [ "${LB_CACHE_PACKAGES}" = "true" ]
107        then
108                if ls cache/packages.bootstrap/*.deb > /dev/null 2>&1
109                then
110                        mkdir -p chroot/var/cache/bootstrap
111                        cp cache/packages.bootstrap/*.deb chroot/var/cache/bootstrap
112                fi
113
114                Echo_breakage "Running ${LB_BOOTSTRAP} (download-only)... "
115                ${LB_ROOT_COMMAND} ${LB_BOOTSTRAP} ${CDEBOOTSTRAP_OPTIONS} --download-only "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
116
117                if [ -n "${LB_ROOT_COMMAND}" ]
118                then
119                        ${LB_ROOT_COMMAND} chown -R $(whoami):$(whoami) chroot
120                fi
121
122                # Removing old cache
123                rm -f cache/packages.bootstrap/*.deb
124
125                # Saving new cache
126                mkdir -p cache/packages.bootstrap
127                cp chroot/var/cache/bootstrap/*.deb cache/packages.bootstrap
128        fi
129
130        Echo_breakage "Running ${LB_BOOTSTRAP}... "
131        ${LB_ROOT_COMMAND} ${LB_BOOTSTRAP} ${CDEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
132
133        if [ -n "${LB_ROOT_COMMAND}" ]
134        then
135                ${LB_ROOT_COMMAND} chown -R $(whoami):$(whoami) chroot
136        fi
137
138        # Deconfiguring cdebootstrap configurations
139        rm -f chroot/etc/apt/sources.list
140        rm -f chroot/etc/hosts
141        rm -f chroot/etc/resolv.conf
142
143        # Removing bootstrap cache
144        rm -rf chroot/var/cache/bootstrap
145
146        # Creating stage file
147        Create_stagefile .build/bootstrap
148else
149        Echo_error "Can't process file /usr/bin/${LB_BOOTSTRAP} (FIXME)"
150        exit 1
151fi
Note: See TracBrowser for help on using the repository browser.