=over 4
-=item B<--install="list of packages separated by commas">
+=item B<-i package>
-=item B<--groupinstall="list of groups separated by commas">
+=item B<--install=package>
-Specify the list of packages or groups to install. These are passed
-directly to C<yum install> or C<yum groupinstall> commands, and thus
-any dependencies are also resolved by yum. You can also use shell
-globs and filenames here, as with ordinary yum.
+=item B<-g "group">
+
+=item B<--groupinstall="group">
+
+Specify the package or group to install. To list multiple packages or
+groups, you must give multiple C<-i> or C<-g> options. Group names
+can contain spaces, so use quotes where necessary.
+
+These are passed directly to C<yum install> or C<yum groupinstall>
+commands, and thus any dependencies are also resolved by yum. You can
+also use shell globs and filenames here, as with ordinary yum.
If no packages or groups are given, then we install the C<Core> group
which is the smallest working Fedora installation. Use C<yum
=back
+=head1 REPOSITORIES
+
+You can list available repositories by visiting this URL:
+
+L<http://mirrors.fedoraproject.org/mirrorlist?repo=help&arch=i386>
+
+(If necessary replace C<i386> with your architecture, but it seems
+unlikely that this list will change based on architecture).
+
=head1 FAKEROOT LOGFILE
When febootstrap is run as non-root (the normal case) we use fakeroot
necessary for installs. If it makes you happier, you can run it the
first time you boot the new system.
+febootstrap recreates the repository anew each time, and this causes
+yum to download all the RPMs every time. This is very wasteful, and
+we should provide a way to cache the repository.
+
=head1 HOME PAGE
L<http://et.redhat.com/~rjones/febootstrap>
-#!/bin/sh -
+#!/bin/bash -
# febootstrap
# (C) Copyright 2009 Red Hat Inc.
#
#
# Written by Richard W.M. Jones <rjones@redhat.com>
+TEMP=`getopt \
+ -o g:i: \
+ --long groupinstall:,group-install:,help,install: \
+ -n febootstrap -- "$@"`
+if [ $? != 0 ]; then
+ echo "febootstrap: problem parsing the command line arguments"
+ exit 1
+fi
+eval set -- "$TEMP"
+
+declare -a packages
+packages[0]="@Core"
+i=0
+
+usage ()
+{
+ echo "Usage: febootstrap [--options] REPO TARGET [MIRROR]"
+ echo "Please read febootstrap(8) man page for more information."
+}
+
+while true; do
+ case "$1" in
+ -i|--install)
+ packages[i++]="$2"
+ shift 2;;
+ --groupinstall|--group-install)
+ packages[i++]="@$2"
+ shift 2;;
+ --help)
+ usage
+ exit 0;;
+ --)
+ shift
+ break;;
+ *)
+ echo "Internal error!"
+ exit 1;;
+ esac
+done
+
+if [ $# -lt 2 -o $# -gt 3 ]; then
+ usage
+ exit 1
+fi
+
+repo="$1"
+target="$2"
+mirror="$3"
+
+# Architecture is currently always the same as the current arch. We
+# cannot do --foreign builds. See discussion in the manpage.
+arch=$(arch)
+
+# Create a temporary directory, make sure it gets cleaned up at the end.
+tmpdir=$(mktemp -d)
+remove_tmpdir ()
+{
+ status=$?
+ rm -rf "$tmpdir" && exit $status
+}
+trap remove_tmpdir EXIT
+
+# Create the temporary repository configuration. The name of the
+# repository is always 'febootstrap'.
+cat > $tmpdir/febootstrap.repo <<__EOF__
+[febootstrap]
+name=febootstrap $repo $arch
+failovermethod=priority
+enabled=1
+gpgcheck=0
+__EOF__
+
+# "Mirror" parameter is a bit misnamed, but it means a local mirror,
+# instead of the public Fedora mirrors.
+if [ -n "$mirror" ]; then
+ echo "baseurl=$mirror" >> "$tmpdir"/febootstrap.repo
+else
+ echo "mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=$repo&arch=$arch" >> "$tmpdir"/febootstrap.repo
+fi
+
+# Create the target filesystem.
+rm -rf "$target"
+mkdir "$target"
+
+# This is necessary to keep yum happy. It's not clear why yum can't
+# just create this file itself.
+mkdir -p "$target"/var/cache/yum/febootstrap/packages
+
+yumargs="-y --disablerepo=* --enablerepo=febootstrap --noplugins --nogpgcheck"
+
+# If we are root, then we don't need to run fakeroot and fakechroot.
+if [ $(id -u) -eq 0 ]; then
+ yum \
+ -c "$tmpdir"/febootstrap.repo \
+ $yumargs \
+ --installroot="$target" \
+ install "${packages[@]}"
+else
+ fakeroot -s "$target"/fakeroot.log \
+ fakechroot -s \
+ yum \
+ -c "$tmpdir"/febootstrap.repo \
+ $yumargs \
+ --installroot="$target" \
+ install "${packages[@]}"
+fi