1 #!/bin/sh 2 3 # Configuration: 4 if [ -e userinstall-defaults ]; then 5 . "$PWD/userinstall-defaults" 6 elif [ -e /etc/default/userinstall ]; then 7 . /etc/default/userinstall 8 else 9 echo "No defaults found for userinstall." 1>&2 10 exit 1 11 fi 12 13 if [ "$1" = '--help' ]; then 14 echo "Usage: `basename $0` [ --root ] [ <country> ]" 1>&2 15 elif [ "$1" = '--root' ]; then 16 AS_ROOT="$1" 17 AS_USER="sudo" 18 shift 1 19 fi 20 21 export COUNTRY="$1" 22 23 THIS_DIR=`dirname "$0"` 24 25 if [ ! "$PACKAGEROOT" ] || [ "$PACKAGEROOT" = '/' ]; then 26 echo "The package root must be specified and not be set to / (the system root)." 1>&2 27 exit 1 28 fi 29 30 echo "Copying host DNS configuration..." 1>&2 31 "$AS_USER" cp /etc/resolv.conf "$PACKAGEROOT/etc/" 32 33 echo "Copying filesystems configuration..." 1>&2 34 "$AS_USER" cp /etc/fstab "$PACKAGEROOT/etc/" 35 36 echo "Copying network configuration..." 1>&2 37 "$AS_USER" cp /etc/hosts "$PACKAGEROOT/etc/" 38 "$AS_USER" cp /etc/network/interfaces "$PACKAGEROOT/etc/network/" 39 40 echo "Copying package repository configuration..." 1>&2 41 if [ "$USERINSTALL_CODENAME" = "$DISTRIB_CODENAME" ]; then 42 "$AS_USER" cp /etc/apt/sources.list "$PACKAGEROOT/etc/apt/" 43 elif [ -e "$USERINSTALL_CODENAME/sources.list" ]; then 44 "$AS_USER" cp "$USERINSTALL_CODENAME/sources.list" "$PACKAGEROOT/etc/apt/" 45 else 46 echo "Attempting to generate a repository definition for $USERINSTALL_CODENAME." 1>&2 47 "$AS_USER" USERINSTALL_ID="$USERINSTALL_ID" USERINSTALL_CODENAME="$USERINSTALL_CODENAME" \ 48 "$THIS_DIR/user-makesources" "$PACKAGEROOT/etc/apt/sources.list" "$COUNTRY" 49 fi 50 51 if [ "$AS_ROOT" ]; then 52 echo "Mounting filesystems..." 1>&2 53 "$THIS_DIR/user-do" $AS_ROOT mount -t proc proc /proc 54 fi 55 56 echo "Updating package details and upgrading..." 1>&2 57 "$THIS_DIR/user-do" $AS_ROOT apt-get update 58 "$THIS_DIR/user-do" $AS_ROOT apt-get upgrade 59 60 if [ "$AS_ROOT" ]; then 61 echo "Configuring a root installation..." 1>&2 62 "$THIS_DIR/user-do" $AS_ROOT apt-get install locales console-data 63 "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure locales 64 "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure tzdata 65 "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure console-data 66 67 echo "Unmounting filesystems..." 1>&2 68 "$THIS_DIR/user-do" $AS_ROOT umount /proc 69 fi