summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrjones <rjones>2009-03-20 11:01:39 +0000
committerrjones <rjones>2009-03-20 11:01:39 +0000
commit1b640fb0bd84f88d378b6c4a74088ac22c8f7d75 (patch)
treeeff1b6ec217a57102ca8a84d9f0f70d6aa44fc40
parentdc60cc1bb950870269252135186e69d2ba4db994 (diff)
downloadfebootstrap-1b640fb0bd84f88d378b6c4a74088ac22c8f7d75.tar.gz
febootstrap-1b640fb0bd84f88d378b6c4a74088ac22c8f7d75.tar.xz
febootstrap-1b640fb0bd84f88d378b6c4a74088ac22c8f7d75.zip
Add first version of the febootstrap-minimize script.
-rw-r--r--.cvsignore2
-rw-r--r--Makefile.am30
-rw-r--r--configure.ac2
-rwxr-xr-xexamples/minimal-filesystem.sh10
-rw-r--r--febootstrap-fix-root.pod41
-rw-r--r--febootstrap-minimize.pod113
-rwxr-xr-xfebootstrap-minimize.sh159
-rw-r--r--febootstrap-to-initramfs.pod1
-rw-r--r--febootstrap.pod14
-rwxr-xr-xfebootstrap.sh12
10 files changed, 326 insertions, 58 deletions
diff --git a/.cvsignore b/.cvsignore
index 9abf25a..4842195 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -11,6 +11,6 @@ config.log
config.status
configure
febootstrap
-febootstrap-fix-root
+febootstrap-minimize
febootstrap-to-initramfs
stamp-h1
diff --git a/Makefile.am b/Makefile.am
index 2c7cfcc..afa11f7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,10 @@
SUBDIRS = examples
-bin_SCRIPTS = febootstrap febootstrap-to-initramfs
+bin_SCRIPTS = \
+ febootstrap \
+ febootstrap-minimize \
+ febootstrap-to-initramfs
febootstrap: febootstrap.sh
rm -f $@
@@ -27,15 +30,25 @@ febootstrap: febootstrap.sh
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 \
@@ -46,32 +59,33 @@ febootstrap.8: febootstrap.pod
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
diff --git a/configure.ac b/configure.ac
index 48bb839..d47d668 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@ dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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])
diff --git a/examples/minimal-filesystem.sh b/examples/minimal-filesystem.sh
index 74a4c2c..1ef6928 100755
--- a/examples/minimal-filesystem.sh
+++ b/examples/minimal-filesystem.sh
@@ -12,7 +12,13 @@
# 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.
@@ -39,6 +45,6 @@ dd if=/dev/zero of=zero bs=2048 count=1
# 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
diff --git a/febootstrap-fix-root.pod b/febootstrap-fix-root.pod
deleted file mode 100644
index 78e5d3d..0000000
--- a/febootstrap-fix-root.pod
+++ /dev/null
@@ -1,41 +0,0 @@
-=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.
diff --git a/febootstrap-minimize.pod b/febootstrap-minimize.pod
new file mode 100644
index 0000000..8d02d5d
--- /dev/null
+++ b/febootstrap-minimize.pod
@@ -0,0 +1,113 @@
+=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.
diff --git a/febootstrap-minimize.sh b/febootstrap-minimize.sh
new file mode 100755
index 0000000..f39beaa
--- /dev/null
+++ b/febootstrap-minimize.sh
@@ -0,0 +1,159 @@
+#!/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
diff --git a/febootstrap-to-initramfs.pod b/febootstrap-to-initramfs.pod
index 4bb418c..be5985c 100644
--- a/febootstrap-to-initramfs.pod
+++ b/febootstrap-to-initramfs.pod
@@ -65,7 +65,6 @@ this in mind when creating very large filesystems.
=head1 SEE ALSO
-L<febootstrap-fix-root(8)>,
L<febootstrap(8)>,
L<cpio(1)>.
diff --git a/febootstrap.pod b/febootstrap.pod
index a610f88..da97766 100644
--- a/febootstrap.pod
+++ b/febootstrap.pod
@@ -55,6 +55,14 @@ If no packages or groups are given, then we install the C<Core> group
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
@@ -89,8 +97,8 @@ permissions using the tool C<febootstrap-to-initramfs>.
=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
@@ -137,7 +145,7 @@ L<http://et.redhat.com/~rjones/febootstrap>
=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)>,
diff --git a/febootstrap.sh b/febootstrap.sh
index e9a197f..41fc84c 100755
--- a/febootstrap.sh
+++ b/febootstrap.sh
@@ -20,7 +20,7 @@
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"
@@ -32,6 +32,8 @@ declare -a packages
packages[0]="@Core"
i=0
+clean=yes
+
usage ()
{
echo "Usage: febootstrap [--options] REPO TARGET [MIRROR]"
@@ -46,6 +48,9 @@ while true; do
--groupinstall|--group-install)
packages[i++]="@$2"
shift 2;;
+ --noclean|--no-clean)
+ clean=no
+ shift;;
--help)
usage
exit 0;;
@@ -164,3 +169,8 @@ if [ $(id -u) -ne 0 ]; then
else
run_yum "${packages[@]}"
fi
+
+# Clean up the yum repository.
+if [ "$clean" = "yes" ]; then
+ rm -rf "$target"/var/cache/yum/febootstrap
+fi