File: vserver-build.debootstrap

package info (click to toggle)
util-vserver 0.30.204-5sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 5,452 kB
  • ctags: 2,353
  • sloc: sh: 28,471; ansic: 15,138; xml: 1,334; cpp: 938; makefile: 334; perl: 85
file content (142 lines) | stat: -rw-r--r-- 3,783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# $Id: vserver-build.debootstrap,v 1.9 2005/01/27 21:24:44 ensc Exp $	--*- sh -*--

# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
#  
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#  
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#  
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

function cleanUp
{
    test ! -d "$workdir"  || $_RM -rf "$workdir"
}

function init
{
    workdir=
    mirror=
    trap "cleanUp" EXIT
}

function initVariables
{
    base.initVariables

    test -n "${mirror-unset}" || {
	local aux
	findFile aux "$CONFDIR"/.defaults/apps/debootstrap/mirror ''
	test -z "$aux" || read mirror <"$aux"
    }
}

function initFilesystem
{
    base.initFilesystem "$1"

    mkdir -p "$SETUP_CONFDIR"/apps/pkgmgmt
    touch "$SETUP_CONFDIR"/apps/pkgmgmt/internal
}

function findDebootstrap
{
    pushd . &>/dev/null
    DEBOOTSTRAP=$(which debootstrap 2>/dev/null) || {
        dir=$($_MKTEMPDIR /var/tmp/debootstrap.XXXXXX)
        workdir=$dir
        dst=$dir/debootstrap.deb
        
        findFile DEBOOTSTRAP_URI "$CONFDIR"/.defaults/apps/debootstrap/uri "$PKGLIBDEFAULTDIR"/debootstrap.uri
        read tmp <$DEBOOTSTRAP_URI
        case "$tmp" in
    	(/*)			ln -s "$tmp" "$dst";;
    	(http://*|ftp://*)
	    $_WGET -nv -O "$dst" "$tmp" || {
		$_CAT <<EOF >&2
ERROR: Could not download the debootstrap package from

   $dst

Usually, this means that Debian released a new version which is unknown
to util-vserver and removed the known ones. To fix this, go to

   http://ftp.debian.org/debian/pool/main/d/debootstrap/

(or a nearby mirror) and search the URL for the most recent *.deb
package matching your platform. Then, put this URL into

   $CONFDIR/.defaults/apps/debootstrap/uri

and retry the vserver-build command again.
EOF
		exit 1
	    }
	    ;;
    	(*)			echo $"Unsupported URI scheme '$tmp'" >&2
    				exit 1;;
        esac
        cd $dir
        ar x "$dst"
        tar xzf data.tar.gz
        export DEBOOTSTRAP_DIR=`pwd`/usr/lib/debootstrap
        DEBOOTSTRAP=`pwd`/usr/sbin/debootstrap
    }
    popd &>/dev/null

    test -x "$DEBOOTSTRAP" || { echo $"Can not find debootstrap at '$DEBOOTSTRAP'" >&2; exit 1; }
}

function fixupDebian
{
    $_RM -rf "$1"/dev
    $_MV "$1"/dev.X "$1"/dev
}


###   main starts here <---

#Parameter s added for debootstrap use
tmp=$(getopt -o '+d:m:s:' --long debug -n "$0" -- "$@") || exit 1
eval set -- "$tmp"

init

while true; do
    case "$1" in
	-d)		DISTRIBUTION=$2; shift;;
	-m)		mirror=$2;       shift;;
#Parameter s added for debootstrap scripts
	-s)		script=$2;	 shift;;
	--debug)	set -x;;
	--)		shift; break ;;
	*)		echo "vserver-build.debootstrap: internal error: unrecognized option '$1'" >&2
			exit 1
			;;
    esac
    shift
done

getDistribution

initVariables  
initFilesystem "$OPTION_FORCE"

setup_writeOption "$VSERVER_NAME"
setup_writeInitialFstab

findDebootstrap

test -z "$BUILD_INITPRE"  || "$BUILD_INITPRE" "$SETUP_CONFDIR"  "$UTIL_VSERVER_VARS"
mv "$VDIR"/dev "$VDIR"/dev.X
#this adds the variable $script to the debootstrap call
"$DEBOOTSTRAP" "$@" "$DISTRIBUTION" "$VDIR" "$mirror" "$script" || :	## HACK: ignore all errors...
fixupDebian "$VDIR"
test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"