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