1.1 --- a/README.txt Sat Jan 16 22:12:19 2010 +0100
1.2 +++ b/README.txt Sun Mar 21 01:28:59 2010 +0100
1.3 @@ -31,13 +31,16 @@
1.4 debootstrap Tested with 0.3.3.2ubuntu3 on Ubuntu Hoary 5.04, 1.0.7~feisty1
1.5 on Ubuntu Feisty 7.04, 1.0.20~hardy1 on Ubuntu Hardy
1.6
1.7 -New in userinstall 0.1.1 (Changes since userinstall 0.1)
1.8 ---------------------------------------------------------
1.9 +New in userinstall 0.2 (Changes since userinstall 0.1)
1.10 +------------------------------------------------------
1.11
1.12 * Fixed an argument parsing error in the user-setup script.
1.13 * Adopted lsb-release environment variables instead of new ones like
1.14 - DISTNAME.
1.15 + DISTNAME, exposing derivatives of these variables by default.
1.16 * Added explicit keyring package installation.
1.17 + * Added scripts for configuring and entering the chroot.
1.18 + * Added support for UML instance construction from distribution
1.19 + installations.
1.20
1.21 Configuration
1.22 -------------
1.23 @@ -45,26 +48,30 @@
1.24 If the system defaults are not to be used, or if userinstall is not installed
1.25 as a system package, the userinstall-defaults file supplied with the
1.26 distribution may be edited to specify the nature and location of the personal
1.27 -package manager. After commenting out or removing this line...
1.28 +package manager.
1.29
1.30 -source /etc/lsb-release
1.31 +The following settings can be edited:
1.32
1.33 -...the following settings can be edited:
1.34 -
1.35 -DISTRIB_ID This should reflect the distribution being used or, in
1.36 - special cases, a different distribution. Examples include
1.37 - Debian and Ubuntu.
1.38 +USERINSTALL_ID This should reflect the distribution being used or, in
1.39 + special cases, a different distribution. Examples
1.40 + include Debian and Ubuntu.
1.41
1.42 -DISTRIB_CODENAME This should reflect the version of the distribution being
1.43 - used and need only be altered in special situations (such as
1.44 - the creation of a sandbox for testing other distributions).
1.45 - Examples of codenames include hardy and jaunty for Ubuntu
1.46 - and lenny and squeeze for Debian. Note that the setup
1.47 - process may not work with different distributions due to
1.48 - library incompatibilities.
1.49 +USERINSTALL_CODENAME This should reflect the version of the distribution
1.50 + being used and need only be altered in special
1.51 + situations (such as the creation of a sandbox for
1.52 + testing other distributions).
1.53
1.54 -PACKAGEROOT The location of the personal package manager in the
1.55 - filesystem.
1.56 + Examples of codenames include hardy and jaunty for
1.57 + Ubuntu and lenny and squeeze for Debian. Note that the
1.58 + setup process may not work with different distributions
1.59 + due to library incompatibilities.
1.60 +
1.61 +PACKAGEROOT The location of the personal package manager in the
1.62 + filesystem.
1.63 +
1.64 +See the /etc/lsb-release file for example values describing your own system,
1.65 +with the DISTRIB prefix used instead of the USERINSTALL prefix for each of the
1.66 +settings.
1.67
1.68 If a completely new userinstall-defaults file is created, it is essential that
1.69 the above variables be defined so that the scripts know where to create or to
1.70 @@ -95,6 +102,19 @@
1.71
1.72 An URI must be specified as the "mirror" location, not a normal filename.
1.73
1.74 +Once the installation is complete, some post-installation is necessary:
1.75 +
1.76 +user-postsetup
1.77 +
1.78 +If a different distribution is being used for the package manager than that
1.79 +being run on the system, it might be necessary to specify a country code so
1.80 +that the configuration of package repositories can be performed successfully.
1.81 +For example, for repositories mirrored in the United Kingdom (UK):
1.82 +
1.83 +user-postsetup uk
1.84 +
1.85 +At this point, the package manager should be ready to use.
1.86 +
1.87 Adding Package Repositories to the Package Manager
1.88 --------------------------------------------------
1.89
1.90 @@ -180,3 +200,55 @@
1.91 export LD_LIBRARY_PATH=`./user-path /usr/lib`
1.92 export PYTHONPATH=`./user-path /usr/lib/python2.5/site-packages/`
1.93 export PYTHONPATH=${PYTHONPATH}:`./user-path /var/lib/python-support/python2.5`
1.94 +
1.95 +Entering the Package Manager
1.96 +----------------------------
1.97 +
1.98 +It is also possible to administer the package manager from within the
1.99 +installation:
1.100 +
1.101 +user-enter
1.102 +
1.103 +This should provide a "root" prompt which can then be used to issue commands
1.104 +within the package manager environment. For example:
1.105 +
1.106 +apt-get update
1.107 +
1.108 +Constructing UML Instances
1.109 +--------------------------
1.110 +
1.111 +For some applications, it can be desirable to provide a completely isolated
1.112 +environment for package installation and testing. This can be performed using
1.113 +the User Mode Linux (UML) software.
1.114 +
1.115 +To convert a package manager installation into a UML instance, start with the
1.116 +uml-postsetup script which changes the installation's configuration in a
1.117 +number of areas:
1.118 +
1.119 +uml-postsetup
1.120 +
1.121 +Then, as a privileged user, run the user-setupdev script to initialise some
1.122 +UML-specific device files:
1.123 +
1.124 +sudo uml-setupdev
1.125 +
1.126 +Since UML needs to see its filesystems as images, not directories within an
1.127 +existing filesystem, the uml-setupfs script needs to create these image files.
1.128 +For example, to create a root filesystem 1GB in size, along with a swap file
1.129 +512MB in size:
1.130 +
1.131 +uml-setupfs 4 512
1.132 +
1.133 +Again, as a privileged user, these images are then populated with the package
1.134 +manager contents as follows:
1.135 +
1.136 +uml-postsetupfs
1.137 +
1.138 +NOTE: Add Linux build process.
1.139 +
1.140 +Entering or Starting UML Instances
1.141 +----------------------------------
1.142 +
1.143 +To enter a UML instance, use the uml-enter script:
1.144 +
1.145 +uml-enter
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/UML/fstab Sun Mar 21 01:28:59 2010 +0100
2.3 @@ -0,0 +1,7 @@
2.4 +# /etc/fstab: static file system information.
2.5 +#
2.6 +# <file system> <mount point> <type> <options> <dump> <pass>
2.7 +proc /proc proc defaults 0 0
2.8 +/dev/ubda / ext3 defaults,errors=remount-ro 0 1
2.9 +/dev/ubdb none swap sw 0 0
2.10 +/dev/ubdc /mnt/cdrom iso9660 defaults 0 0
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/uml-enter Sun Mar 21 01:28:59 2010 +0100
3.3 @@ -0,0 +1,18 @@
3.4 +#!/bin/bash
3.5 +# Usage: uml-enter <memory>
3.6 +
3.7 +# Configuration:
3.8 +if [ -e userinstall-defaults-uml ]; then
3.9 + source userinstall-defaults-uml
3.10 +elif [ -e /etc/default/userinstall-uml ]; then
3.11 + source /etc/default/userinstall-uml
3.12 +else
3.13 + echo "No defaults found for userinstall (UML)."
3.14 + exit 1
3.15 +fi
3.16 +
3.17 +export IMAGE=$UMLROOT/rootfs
3.18 +export SWAPIMAGE=$UMLROOT/swap
3.19 +
3.20 +# Now we start the virtual machine...
3.21 +`dirname $0`/linux ubd0=$IMAGE ubd1=$SWAPIMAGE mem=$1
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/uml-postsetup Sun Mar 21 01:28:59 2010 +0100
4.3 @@ -0,0 +1,45 @@
4.4 +#!/bin/bash
4.5 +# Usage: uml-postsetup
4.6 +
4.7 +# Configuration:
4.8 +if [ -e userinstall-defaults ]; then
4.9 + source userinstall-defaults
4.10 +elif [ -e /etc/default/userinstall ]; then
4.11 + source /etc/default/userinstall
4.12 +else
4.13 + echo "No defaults found for userinstall."
4.14 + exit 1
4.15 +fi
4.16 +
4.17 +echo "Removing any linked /dev entry..."
4.18 +if [ -h "$PACKAGEROOT/dev" ]; then
4.19 + rm $PACKAGEROOT/dev
4.20 + mkdir $PACKAGEROOT/dev
4.21 +fi
4.22 +
4.23 +cp /dev/MAKEDEV $PACKAGEROOT/dev
4.24 +
4.25 +echo "Removing any linked /proc entry..."
4.26 +if [ -h "$PACKAGEROOT/proc" ]; then
4.27 + rm $PACKAGEROOT/proc
4.28 + mkdir $PACKAGEROOT/proc
4.29 +fi
4.30 +
4.31 +echo "Using a special fstab..."
4.32 +if [ -e "$PACKAGEROOT/etc/fstab" ]; then
4.33 + mv $PACKAGEROOT/etc/fstab $PACKAGEROOT/etc/fstab.orig
4.34 +fi
4.35 +cp `dirname $0`/UML/fstab $PACKAGEROOT/etc/fstab
4.36 +
4.37 +# Tweak the inittab to only use tty0 and add it to securetty.
4.38 +echo "Reconfiguring the console settings..."
4.39 +if [ ! -e "$PACKAGEROOT/etc/inittab.save" ]; then
4.40 + cp $PACKAGEROOT/etc/inittab $PACKAGEROOT/etc/inittab.save
4.41 + grep -v "getty" $PACKAGEROOT/etc/inittab.save > $PACKAGEROOT/etc/inittab
4.42 + echo "# We launch just one console for UML:" >> $PACKAGEROOT/etc/inittab
4.43 + echo "c0:1235:respawn:/sbin/getty 38400 tty0 linux" >> $PACKAGEROOT/etc/inittab
4.44 +
4.45 + echo "# UML modification: use tty0 or vc/0" >> $PACKAGEROOT/etc/securetty
4.46 + echo "tty0" >> $PACKAGEROOT/etc/securetty
4.47 + echo "vc/0" >> $PACKAGEROOT/etc/securetty
4.48 +fi
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/uml-postsetupfs Sun Mar 21 01:28:59 2010 +0100
5.3 @@ -0,0 +1,44 @@
5.4 +#!/bin/bash
5.5 +# Usage: uml-postsetupfs
5.6 +
5.7 +# Configuration:
5.8 +if [ -e userinstall-defaults-uml ]; then
5.9 + source userinstall-defaults-uml
5.10 +elif [ -e /etc/default/userinstall-uml ]; then
5.11 + source /etc/default/userinstall-uml
5.12 +else
5.13 + echo "No defaults found for userinstall (UML)."
5.14 + exit 1
5.15 +fi
5.16 +
5.17 +# Ensure that images have been set up.
5.18 +if [ ! -e $UMLROOT ]; then
5.19 + echo "No UML instances set up at $UMLROOT."
5.20 + exit 1
5.21 +fi
5.22 +
5.23 +export IMAGE=$UMLROOT/rootfs
5.24 +
5.25 +if [ ! -e $IMAGE ]; then
5.26 + echo "No image set up at $IMAGE."
5.27 + exit 1
5.28 +fi
5.29 +
5.30 +export IMAGEDIR=$UMLROOT/rootfsdir
5.31 +
5.32 +if [ ! -e $IMAGEDIR ]; then
5.33 + mkdir $IMAGEDIR
5.34 +fi
5.35 +
5.36 +echo "Accessing the image..."
5.37 +mount -o loop $IMAGE $IMAGEDIR || exit 1
5.38 +
5.39 +echo "Copying the filesystem into the image..."
5.40 +cp -a $PACKAGEROOT/* $IMAGEDIR
5.41 +
5.42 +echo "Initialising device files..."
5.43 +chroot $PACKAGEROOT /bin/bash -c 'mount -t proc proc /proc; cd /dev; MAKEDEV generic; umount /proc'
5.44 +
5.45 +echo "Unmounting the image..."
5.46 +umount $IMAGEDIR
5.47 +rmdir $IMAGEDIR
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/uml-setupdev Sun Mar 21 01:28:59 2010 +0100
6.3 @@ -0,0 +1,29 @@
6.4 +#!/bin/bash
6.5 +# From UMLconfig...
6.6 +
6.7 +# Configuration:
6.8 +if [ -e userinstall-defaults ]; then
6.9 + source userinstall-defaults
6.10 +elif [ -e /etc/default/userinstall ]; then
6.11 + source /etc/default/userinstall
6.12 +else
6.13 + echo "No defaults found for userinstall."
6.14 + exit 1
6.15 +fi
6.16 +
6.17 +echo "Creating special UML devices..."
6.18 +if [ ! -e "$PACKAGEROOT/dev/ubda" ]; then
6.19 + if [ -e "$PACKAGEROOT/dev" ]; then
6.20 + for ((i=0; i<8; i++))
6.21 + do
6.22 + let=$(echo $i|tr '0-7' 'a-z')
6.23 + mknod $PACKAGEROOT/dev/ubd$let b 98 $[16 * $i]
6.24 + for ((p=1; p<=16; p++)) do
6.25 + mknod $PACKAGEROOT/dev/ubd$let$p b 98 $[16 * $i + $p]
6.26 + done
6.27 + done
6.28 + else
6.29 + echo "/dev not found!"
6.30 + exit 1
6.31 + fi
6.32 +fi
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/uml-setupfs Sun Mar 21 01:28:59 2010 +0100
7.3 @@ -0,0 +1,37 @@
7.4 +#!/bin/bash
7.5 +# Usage: uml-setupfs <root-filesystem-size-in-GB> <swap-size-in-MB>
7.6 +
7.7 +# Configuration:
7.8 +if [ -e userinstall-defaults-uml ]; then
7.9 + source userinstall-defaults-uml
7.10 +elif [ -e /etc/default/userinstall-uml ]; then
7.11 + source /etc/default/userinstall-uml
7.12 +else
7.13 + echo "No defaults found for userinstall (UML)."
7.14 + exit 1
7.15 +fi
7.16 +
7.17 +# Ensure arguments have been provided.
7.18 +if [[ ! $1 || ! $2 ]]; then
7.19 + echo "$0 <root-filesystem-size-in-GB> <swap-size-in-MB>"
7.20 + exit 1
7.21 +fi
7.22 +
7.23 +# Make the UML instance directory if not already present.
7.24 +
7.25 +echo "Making the UML instance directory at $UMLROOT..."
7.26 +if [ ! -e $UMLROOT ]; then
7.27 + mkdir $UMLROOT
7.28 +fi
7.29 +
7.30 +export IMAGE=$UMLROOT/rootfs
7.31 +export IMAGESIZE=$1
7.32 +export SWAPIMAGE=$UMLROOT/swap
7.33 +export SWAPSIZE=$2
7.34 +
7.35 +echo "Making the filesystem with size ${IMAGESIZE}GB..."
7.36 +dd if=/dev/zero of=$IMAGE bs=1024 count=1 seek=$((${IMAGESIZE}*1024*1024-1024))
7.37 +mkfs.ext3 $IMAGE
7.38 +
7.39 +echo "Making the swap file with size ${SWAPSIZE}MB..."
7.40 +dd if=/dev/zero of=$SWAPIMAGE bs=1M count=$SWAPSIZE
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/user-enter Sun Mar 21 01:28:59 2010 +0100
8.3 @@ -0,0 +1,14 @@
8.4 +#!/bin/bash
8.5 +# Usage: user-enter
8.6 +
8.7 +# Configuration:
8.8 +if [ -e userinstall-defaults ]; then
8.9 + source userinstall-defaults
8.10 +elif [ -e /etc/default/userinstall ]; then
8.11 + source /etc/default/userinstall
8.12 +else
8.13 + echo "No defaults found for userinstall."
8.14 + exit 1
8.15 +fi
8.16 +
8.17 +fakeroot fakechroot chroot $PACKAGEROOT
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/user-makesources Sun Mar 21 01:28:59 2010 +0100
9.3 @@ -0,0 +1,53 @@
9.4 +#!/usr/bin/env python
9.5 +
9.6 +templates = {
9.7 +
9.8 + "Debian" : """
9.9 +deb http://ftp.%(country)s.debian.org/debian %(codename)s main
9.10 +deb-src http://ftp.%(country)s.debian.org/debian %(codename)s main
9.11 +
9.12 +deb http://security.debian.org/ %(codename)s/updates main
9.13 +deb-src http://security.debian.org/ %(codename)s/updates main
9.14 +""",
9.15 +
9.16 + "Ubuntu" : """
9.17 +deb http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s main universe
9.18 +deb-src http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s main universe
9.19 +
9.20 +deb http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s-security main universe
9.21 +deb-src http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s-security main universe
9.22 +
9.23 +deb http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s-updates main universe
9.24 +deb-src http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s-updates main universe
9.25 +"""
9.26 +
9.27 + }
9.28 +
9.29 +if __name__ == "__main__":
9.30 + import os, sys
9.31 +
9.32 + if len(sys.argv) < 2:
9.33 + print "Need a filename for the generated file."
9.34 + sys.exit(1)
9.35 +
9.36 + elif len(sys.argv) < 3:
9.37 + print "Need a country to generate source lists."
9.38 + sys.exit(1)
9.39 +
9.40 + filename, country = sys.argv[1:3]
9.41 + distribution = os.environ["USERINSTALL_ID"]
9.42 + codename = os.environ["USERINSTALL_CODENAME"]
9.43 +
9.44 + try:
9.45 + template = templates[distribution]
9.46 + except KeyError:
9.47 + print "Distribution %s not supported." % distribution
9.48 + sys.exit(1)
9.49 +
9.50 + f = open(filename, "w")
9.51 + try:
9.52 + f.write(template % {"codename" : codename, "country" : country})
9.53 + finally:
9.54 + f.close()
9.55 +
9.56 +# vim: tabstop=4 expandtab shiftwidth=4
10.1 --- a/user-path Sat Jan 16 22:12:19 2010 +0100
10.2 +++ b/user-path Sun Mar 21 01:28:59 2010 +0100
10.3 @@ -1,5 +1,5 @@
10.4 #!/bin/bash
10.5 -# Usage: user-dirpath <path-inside-package-root>
10.6 +# Usage: user-path <path-inside-package-root>
10.7
10.8 # Configuration:
10.9 if [ -e userinstall-defaults ]; then
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/user-postsetup Sun Mar 21 01:28:59 2010 +0100
11.3 @@ -0,0 +1,32 @@
11.4 +#!/bin/bash
11.5 +# Usage: user-postsetup [ <country> ]
11.6 +
11.7 +# Configuration:
11.8 +if [ -e userinstall-defaults ]; then
11.9 + source userinstall-defaults
11.10 +elif [ -e /etc/default/userinstall ]; then
11.11 + source /etc/default/userinstall
11.12 +else
11.13 + echo "No defaults found for userinstall."
11.14 + exit 1
11.15 +fi
11.16 +
11.17 +echo "Copying host DNS configuration..."
11.18 +cp /etc/resolv.conf $PACKAGEROOT/etc/
11.19 +
11.20 +echo "Copying filesystems configuration..."
11.21 +cp /etc/fstab $PACKAGEROOT/etc/
11.22 +
11.23 +echo "Copying network configuration..."
11.24 +cp /etc/hosts $PACKAGEROOT/etc/
11.25 +cp /etc/network/interfaces $PACKAGEROOT/etc/network/
11.26 +
11.27 +echo "Copying package repository configuration..."
11.28 +if [[ $USERINSTALL_CODENAME == $DISTRIB_CODENAME ]]; then
11.29 + cp /etc/apt/sources.list $PACKAGEROOT/etc/apt/
11.30 +elif [ -e $USERINSTALL_CODENAME/sources.list ]; then
11.31 + cp $USERINSTALL_CODENAME/sources.list $PACKAGEROOT/etc/apt/
11.32 +else
11.33 + echo "Attempting to generate a repository definition for $USERINSTALL_CODENAME."
11.34 + `dirname $0`/user-makesources $PACKAGEROOT/etc/apt/sources.list $1
11.35 +fi
12.1 --- a/user-setup Sat Jan 16 22:12:19 2010 +0100
12.2 +++ b/user-setup Sun Mar 21 01:28:59 2010 +0100
12.3 @@ -17,12 +17,12 @@
12.4 echo "Examples:"
12.5 echo
12.6 echo "user-setup"
12.7 - echo "user-setup file:///tmp/$DISTRIB_CODENAME/"
12.8 + echo "user-setup file:///tmp/$USERINSTALL_CODENAME/"
12.9 echo "user-setup http://ftp.xx.debian.org/debian/"
12.10 exit 1
12.11 fi
12.12
12.13 -fakeroot fakechroot --use-system-libs debootstrap --variant=fakechroot --include=gnupg,$KEYRING $DISTRIB_CODENAME $PACKAGEROOT $1
12.14 +fakeroot fakechroot --use-system-libs debootstrap --variant=fakechroot --include=gnupg,$KEYRING $USERINSTALL_CODENAME $PACKAGEROOT $1
12.15 echo
12.16 echo "Don't forget to run the following before installing packages:"
12.17 echo
13.1 --- a/userinstall-defaults Sat Jan 16 22:12:19 2010 +0100
13.2 +++ b/userinstall-defaults Sun Mar 21 01:28:59 2010 +0100
13.3 @@ -2,7 +2,13 @@
13.4
13.5 source /etc/lsb-release
13.6
13.7 +# If not using the same distribution inside the userinstall, replace these
13.8 +# definitions:
13.9 +
13.10 +export USERINSTALL_ID=$DISTRIB_ID
13.11 +export USERINSTALL_CODENAME=$DISTRIB_CODENAME
13.12 +
13.13 # Configuration details for building and using a personal package manager.
13.14
13.15 export PACKAGEROOT=$HOME/.userinstall
13.16 -export KEYRING=$(echo $DISTRIB_ID | tr '[:upper:]' '[:lower:]')-keyring
13.17 +export KEYRING=$(echo $USERINSTALL_ID | tr '[:upper:]' '[:lower:]')-keyring
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/userinstall-defaults-uml Sun Mar 21 01:28:59 2010 +0100
14.3 @@ -0,0 +1,15 @@
14.4 +#!/bin/bash
14.5 +
14.6 +# Main configuration:
14.7 +if [ -e userinstall-defaults ]; then
14.8 + source userinstall-defaults
14.9 +elif [ -e /etc/default/userinstall ]; then
14.10 + source /etc/default/userinstall
14.11 +else
14.12 + echo "No defaults found for userinstall."
14.13 + exit 1
14.14 +fi
14.15 +
14.16 +# Configuration details for building a UML instance.
14.17 +
14.18 +export UMLROOT=$HOME/.userinstall-uml