1 #!/bin/sh 2 3 # Copyright (C) 2007, 2008, 2010, 2011, 2012, 2013 Paul Boddie <paul@boddie.org.uk> 4 # 5 # This program is free software; you can redistribute it and/or modify it under 6 # the terms of the GNU General Public License as published by the Free Software 7 # Foundation; either version 3 of the License, or (at your option) any later 8 # version. 9 # 10 # This program is distributed in the hope that it will be useful, but WITHOUT 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 # details. 14 # 15 # You should have received a copy of the GNU General Public License along with 16 # this program. If not, see <http://www.gnu.org/licenses/>. 17 18 # Configuration: 19 if [ -e userinstall-defaults ]; then 20 . "$PWD/userinstall-defaults" 21 elif [ -e /etc/default/userinstall ]; then 22 . /etc/default/userinstall 23 else 24 echo "No defaults found for userinstall." 1>&2 25 exit 1 26 fi 27 28 if [ "$1" = "--help" ]; then 29 cat 1>&2 <<EOF 30 Usage: `basename $0` [ --root ] [ <mirror> ] 31 32 Examples: 33 34 user-setup 35 user-setup file:///tmp/$USERINSTALL_CODENAME/ 36 user-setup http://ftp.xx.debian.org/debian/ 37 user-setup --root http://ftp.xx.debian.org/debian/ 38 EOF 39 exit 1 40 elif [ "$1" = '--root' ]; then 41 AS_ROOT="$1" 42 shift 1 43 fi 44 45 if [ ! "$PACKAGEROOT" ] || [ "$PACKAGEROOT" = '/' ]; then 46 echo "The package root must be specified and not be set to / (the system root)." 1>&2 47 exit 1 48 fi 49 50 MIRROR="$1" 51 PATH=$PATH${PATH:+:}/usr/sbin:/sbin 52 53 if [ "$AS_ROOT" ]; then 54 if ! sudo debootstrap --include="gnupg,$KEYRING" "$USERINSTALL_CODENAME" "$PACKAGEROOT" "$MIRROR" ; then 55 cat 1>&2 <<EOF 56 Failed to complete an installation of the chosen distribution. 57 See the error messages above for more information. 58 EOF 59 exit 1 60 fi 61 else 62 if ! fakeroot fakechroot $FAKECHROOT_OPTIONS debootstrap --variant=fakechroot --include="gnupg,$KEYRING" \ 63 "$USERINSTALL_CODENAME" "$PACKAGEROOT" "$MIRROR" ; then 64 cat 1>&2 <<EOF 65 Failed to complete an installation of the chosen distribution. 66 See the error messages above for more information. 67 EOF 68 exit 1 69 fi 70 fi 71 72 cat 1>&2 <<EOF 73 Don't forget to run the following before installing packages: 74 75 user-postsetup $AS_ROOT [ <country> ] 76 EOF