config.status
configure
febootstrap
-febootstrap-fix-root
+febootstrap-minimize
febootstrap-to-initramfs
stamp-h1
SUBDIRS = examples
-bin_SCRIPTS = febootstrap febootstrap-to-initramfs
+bin_SCRIPTS = \
+ febootstrap \
+ febootstrap-minimize \
+ febootstrap-to-initramfs
febootstrap: febootstrap.sh
rm -f $@
chmod 0555 $@-t
mv $@-t $@
+febootstrap-minimize: febootstrap-minimize.sh
+ rm -f $@
+ cp $< $@-t
+ chmod 0555 $@-t
+ mv $@-t $@
+
febootstrap-to-initramfs: febootstrap-to-initramfs.sh
rm -f $@
cp $< $@-t
chmod 0555 $@-t
mv $@-t $@
-man_MANS = febootstrap.8 febootstrap-to-initramfs.8 febootstrap-fix-root.8
+man_MANS = \
+ febootstrap.8 \
+ febootstrap-minimize.8 \
+ febootstrap-to-initramfs.8
if HAVE_PERLDOC
+
febootstrap.8: febootstrap.pod
pod2man \
--section 8 \
febootstrap.txt: febootstrap.pod
pod2text $< > $@
-febootstrap-to-initramfs.8: febootstrap-to-initramfs.pod
+febootstrap-minimize.8: febootstrap-minimize.pod
pod2man \
--section 8 \
-c "Virtualization Support" \
--release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
$< > $@
-febootstrap-to-initramfs.txt: febootstrap-to-initramfs.pod
+febootstrap-minimize.txt: febootstrap-minimize.pod
pod2text $< > $@
-febootstrap-fix-root.8: febootstrap-fix-root.pod
+febootstrap-to-initramfs.8: febootstrap-to-initramfs.pod
pod2man \
--section 8 \
-c "Virtualization Support" \
--release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
$< > $@
-febootstrap-fix-root.txt: febootstrap-fix-root.pod
+febootstrap-to-initramfs.txt: febootstrap-to-initramfs.pod
pod2text $< > $@
+
endif
EXTRA_DIST = \
fakechroot-2.8-relchroot.patch \
febootstrap.8 febootstrap.txt febootstrap.pod \
+ febootstrap-minimize.8 febootstrap-minimize.txt \
+ febootstrap-minimize.pod \
febootstrap-to-initramfs.8 febootstrap-to-initramfs.txt \
febootstrap-to-initramfs.pod \
- febootstrap-fix-root.8 febootstrap-fix-root.txt \
- febootstrap-fix-root.pod \
febootstrap.sh febootstrap-to-initramfs.sh
dnl
dnl Written by Richard W.M. Jones <rjones@redhat.com>
-AC_INIT(febootstrap,0.8)
+AC_INIT(febootstrap,0.9)
AM_INIT_AUTOMAKE
AC_CHECK_PROG(PERLDOC,[perldoc],[perldoc],[no])
# few command line utilities. One of the joys of Fedora is that even
# this minimal install is still 200 MB ...
-../febootstrap -i bash -i coreutils fedora-10 ./minimal
+../febootstrap -i bash -i coreutils fedora-10 ./minimal $1
+
+# ... but let's minimize it aggressively.
+
+echo -n "Before minimization: "; du -sh minimal
+../febootstrap-minimize --all ./minimal
+echo -n "After minimization: "; du -sh minimal
# Create the /init which is just a simple script to give users an
# interactive shell.
# Now run qemu to boot this minimal system.
qemu-system-$(arch) \
- -m 1024 \
+ -m 128 \
-kernel vmlinuz -initrd minimal-initrd.img \
-hda zero -boot c
+++ /dev/null
-=head1 NAME
-
-febootstrap-fix-root - Fix ownership and permissions inside febootstrap root
-
-=head1 SYNOPSIS
-
- febootstrap-fix-root DIR
-
-=head1 DESCRIPTION
-
-
-
-
-=head1 SEE ALSO
-
-L<febootstrap-to-initramfs(8)>,
-L<febootstrap(8)>,
-L<fakeroot(1)>.
-
-=head1 AUTHORS
-
-Richard W.M. Jones <rjones @ redhat . com>
-
-=head1 COPYRIGHT
-
-(C) Copyright 2009 Red Hat Inc.,
-L<http://et.redhat.com/~rjones/febootstrap>.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
--- /dev/null
+=head1 NAME
+
+febootstrap-minimize - Minimize an febootstrap image
+
+=head1 SYNOPSIS
+
+ febootstrap-minimize [--options] DIR
+
+=head1 DESCRIPTION
+
+I<febootstrap-minimize> minimizes an L<febootstrap(8)>-created
+filesystem. This means that unneeded files and cruft are removed from
+the image.
+
+If no options are given, the default is to minimize the image as much
+as possible. This means, for example, that locales are removed so the
+image will only be usable in US-English, there will be no
+documentation or manual pages, and the image will only work in a UTC
+timezone.
+
+Note that image minimization involves deleting files that have been
+installed by RPM. Thus after minimization, it is no longer guaranteed
+that RPM will function correctly on the image. You should only do
+this as a final step for "throwaway" appliances that do not need to be
+modified or upgraded in future.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<--all>
+
+Perform all minimization operations, to produce the smallest possible
+image. Note in particular that locales are discarded.
+
+You can perform all minimization operations I<except> X, Y and Z by
+doing:
+
+ febootstrap-minimize --all --keep-X --keep-Y --keep-Z ...
+
+(C<--all> can be omitted since it is the default).
+
+=item B<--none>
+
+Start with no minimization operations. You can specify I<only>
+minimization operations X, Y and Z like this:
+
+ febootstrap-minimize --none --drop-X --drop-Y --drop-Z ...
+
+=item B<--keep-locales>
+
+=item B<--drop-locales>
+
+Keep or drop locale support.
+
+=item B<--keep-docs>
+
+=item B<--drop-docs>
+
+Keep or drop documentation and man pages.
+
+=item B<--keep-yum-cache>
+
+=item B<--drop-yum-cache>
+
+Keep or drop the yum cache.
+
+=item B<--keep-cracklib>
+
+=item B<--drop-cracklib>
+
+Keep or drop cracklib libraries.
+
+=item B<--keep-i18n>
+
+=item B<--drop-i18n>
+
+Keep or drop C</usr/share/i18n>.
+
+=item B<--keep-zoneinfo>
+
+=item B<--drop-zoneinfo>
+
+Keep or drop all timezones (except UTC which is never deleted).
+
+=back
+
+=head1 SEE ALSO
+
+L<febootstrap(8)>.
+
+=head1 AUTHORS
+
+Richard W.M. Jones <rjones @ redhat . com>
+
+=head1 COPYRIGHT
+
+(C) Copyright 2009 Red Hat Inc.,
+L<http://et.redhat.com/~rjones/febootstrap>.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
--- /dev/null
+#!/bin/bash -
+# febootstrap minimize
+# (C) Copyright 2009 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# Written by Richard W.M. Jones <rjones@redhat.com>
+
+TEMP=`getopt \
+ -o '' \
+ --long help,all,none,keep-locales,drop-locales,keep-docs,drop-docs,keep-yum-cache,drop-yum-cache,keep-cracklib,drop-cracklib,keep-i18n,drop-i18n,keep-zoneinfo,drop-zoneinfo \
+ -n febootstrap-minimize -- "$@"`
+if [ $? != 0 ]; then
+ echo "febootstrap-minimize: problem parsing the command line arguments"
+ exit 1
+fi
+eval set -- "$TEMP"
+
+set_all ()
+{
+ keep_locales=no
+ keep_docs=no
+keep_yum_cache=no
+ keep_cracklib=no
+ keep_i18n=no
+ keep_zoneinfo=no
+}
+
+set_none ()
+{
+ keep_locales=yes
+ keep_docs=yes
+keep_yum_cache=yes
+ keep_cracklib=yes
+ keep_i18n=yes
+ keep_zoneinfo=yes
+}
+
+set_all
+
+usage ()
+{
+ echo "Usage: febootstrap-minimize [--options] DIR"
+ echo "Please read febootstrap-minimize(8) man page for more information."
+}
+
+while true; do
+ case "$1" in
+ --all)
+ set_all
+ shift;;
+ --none)
+ set_none
+ shift;;
+ --keep-locales)
+ keep_locales=yes
+ shift;;
+ --drop-locales)
+ keep_locales=no
+ shift;;
+ --keep-docs)
+ keep_docs=yes
+ shift;;
+ --drop-docs)
+ keep_docs=no
+ shift;;
+ --keep-yum-cache)
+ keep_yum_cache=yes
+ shift;;
+ --drop-yum-cache)
+ keep_yum_cache=no
+ shift;;
+ --keep-cracklib)
+ keep_cracklib=yes
+ shift;;
+ --drop-cracklib)
+ keep_cracklib=no
+ shift;;
+ --keep-i18n)
+ keep_i18n=yes
+ shift;;
+ --drop-i18n)
+ keep_i18n=no
+ shift;;
+ --keep-zoneinfo)
+ keep_zoneinfo=yes
+ shift;;
+ --drop-zoneinfo)
+ keep_zoneinfo=no
+ shift;;
+ --help)
+ usage
+ exit 0;;
+ --)
+ shift
+ break;;
+ *)
+ echo "Internal error!"
+ exit 1;;
+ esac
+done
+
+if [ $# -lt 1 ]; then
+ usage
+ exit 1
+fi
+
+target="$1"
+
+#----------------------------------------------------------------------
+
+if [ ! -d "$target" ]; then
+ echo "febootstrap-minimize: $target: target directory not found"
+ exit 1
+fi
+
+#du -sh "$target"
+
+if [ "$keep_locales" != "yes" ]; then
+ rm -f "$target"/usr/lib/locale/*
+ rm -rf "$target"/usr/share/locale
+fi
+
+if [ "$keep_docs" != "yes" ]; then
+ rm -rf "$target"/usr/share/man
+ rm -rf "$target"/usr/share/doc
+fi
+
+if [ "$keep_yum_cache" != "yes" ]; then
+ rm -rf "$target"/var/cache/yum/*
+fi
+
+if [ "$keep_cracklib" != "yes" ]; then
+ rm -rf "$target"/usr/share/cracklib
+fi
+
+if [ "$keep_i18n" != "yes" ]; then
+ rm -rf "$target"/usr/share/i18n
+fi
+
+if [ "$keep_zoneinfo" != "yes" ]; then
+ mv "$target"/usr/share/zoneinfo/{UCT,UTC,Universal,Zulu,GMT*,*.tab} \
+ "$target"
+ rm -rf "$target"/usr/share/zoneinfo/*
+ mv "$target"/{UCT,UTC,Universal,Zulu,GMT*,*.tab} \
+ "$target"/usr/share/zoneinfo/
+fi
=head1 SEE ALSO
-L<febootstrap-fix-root(8)>,
L<febootstrap(8)>,
L<cpio(1)>.
which is the smallest working Fedora installation. Use C<yum
groupinfo Core> to list the packages currently in the C<Core> group.
+=item B<--no-clean>
+
+Normally febootstrap will clean up the yum repository
+(C</var/cache/yum> inside the image). This contains the downloaded
+RPMs and metadata. However if you give the C<--no-clean> option, then
+the yum repository is left. This is useful if you want to run further
+yum commands inside the filesystem by hand.
+
=back
=head1 REPOSITORIES
=item *
-Apply the permissions to the target directory using the tool
-C<febootstrap-fix-root> (requires root).
+Apply the permissions to the target directory using the forthcoming
+tool C<febootstrap-fix-root> (requires root).
=back
=head1 SEE ALSO
L<febootstrap-to-initramfs(8)>,
-L<febootstrap-fix-root(8)>,
+L<febootstrap-minimize(8)>,
L<fakeroot(1)>,
L<fakechroot(1)>,
L<yum(8)>,
TEMP=`getopt \
-o g:i: \
- --long groupinstall:,group-install:,help,install: \
+ --long groupinstall:,group-install:,help,install:,noclean,no-clean \
-n febootstrap -- "$@"`
if [ $? != 0 ]; then
echo "febootstrap: problem parsing the command line arguments"
packages[0]="@Core"
i=0
+clean=yes
+
usage ()
{
echo "Usage: febootstrap [--options] REPO TARGET [MIRROR]"
--groupinstall|--group-install)
packages[i++]="@$2"
shift 2;;
+ --noclean|--no-clean)
+ clean=no
+ shift;;
--help)
usage
exit 0;;
else
run_yum "${packages[@]}"
fi
+
+# Clean up the yum repository.
+if [ "$clean" = "yes" ]; then
+ rm -rf "$target"/var/cache/yum/febootstrap
+fi