diff --git a/docs/conf.py b/docs/conf.py index a608bdcc..9b64b26d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -266,6 +266,7 @@ man_pages = [ ('lorax', 'lorax', u'Lorax Documentation', [u'Weldr Team'], 1), ('livemedia-creator', 'livemedia-creator', u'Live Media Creator Documentation', [u'Weldr Team'], 1), ('mkksiso', 'mkksiso', u'Make Kickstart ISO Utility Documentation', [u'Weldr Team'], 1), + ('image-minimizer', 'image-minimizer', u'Utility script to remove files and packages', [u'Weldr Team'], 1), ] # If true, show URL addresses after external links. diff --git a/docs/image-minimizer.rst b/docs/image-minimizer.rst new file mode 100644 index 00000000..9e694432 --- /dev/null +++ b/docs/image-minimizer.rst @@ -0,0 +1,99 @@ +image-minimizer +=============== + +:Authors: + Brian C. Lane + +`image-minimizer` is a script used as an interpreter for kickstart `%post` +sections. It is used to remove rpm packages and individual files from the +system that Anaconda has just installed. + +It processes a list of commands that tell it which files or rpms to remove, and +which to keep. + + +image-minimizer cmdline arguments +--------------------------------- + + `usage: image-minimizer [-h] [-i STRING] [--dryrun] [-v] STRING` + +Optional arguments +^^^^^^^^^^^^^^^^^^ + + -h, --help show this help message and exit + -i STRING, --installroot STRING + Root path to prepend to all file patterns and + installation root for RPM operations. Defaults to + INSTALL_ROOT or /mnt/sysimage/ + --dryrun If set, no filesystem changes are made. + -v, --verbose Display every action as it is performed. + +Positional arguments +^^^^^^^^^^^^^^^^^^^^ + + :STRING: Filename to process + + +NOTES +----- + +You cannot pass any arguments to `image-minimizer` when using it from the +kickstart `%post`. + +When using this from a kickstart the image-minimizer package needs to be available. +It is not included on the standard boot.iso, so you will need to include `lorax` in +the `%package` section. You can use `image-minimizer` to remove lorax from the install. + +If you are using this with `livemedia-creator` it can be installed on the host +system so that `lorax` isn't needed in the `%package` list, and it doesn't need +to be removed. + + +commands +-------- + +Commands are listed one per line, followed by a space, and then by the +package, file, or glob. The globs used are Unix style pathname patterns using +`*`, `?`, and `[]` character ranges. globbing is implemented using the python +glob module. + + +* drop + This will remove files from the installation. + +* keep + This will keep files, and should follow any `drop` commands including globs. + +* droprpm + Remove matching rpm packages. Dependencies are not remove, just individual + packages matching the glob. + +* keeprpm + Do not remove matching rpm packages, it should follow any `droprpm` commands + that include globs. + + +example +------- + +Example Anaconda `%post` usage:: + + %post --interpreter=image-minimizer --nochroot + + drop /lib/modules/*/kernel/fs + keep /lib/modules/*/kernel/fs/ext* + keep /lib/modules/*/kernel/fs/mbcache* + keep /lib/modules/*/kernel/fs/squashfs + + droprpm make + droprpm mtools + droprpm mysql-libs + droprpm perl + droprpm perl-Pod-* + droprpm syslinux + keeprpm perl-Pod-Simple + + # Not needed after image-minimizer is done + droprpm lorax + + %end diff --git a/docs/index.rst b/docs/index.rst index c51d24e4..e102f330 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -16,6 +16,7 @@ Contents: livemedia-creator mkksiso product-images + image-minimizer modules Documentation for other Lorax Branches diff --git a/src/bin/image-minimizer b/src/bin/image-minimizer index 29387eb1..75eae83c 100755 --- a/src/bin/image-minimizer +++ b/src/bin/image-minimizer @@ -70,7 +70,7 @@ class ImageMinimizer: not_found = True for hdr in mi: not_found = False - rpms.add(hdr['name'].decode("utf8")) + rpms.add(hdr['name']) if self.verbose and not_found: print("%s package not found" % pattern) @@ -145,8 +145,9 @@ class ImageMinimizer: self.ts.run(runCallback, "erase") def filter(self): - for line in (open(self.filename).readlines()): - self.parse_line(line.strip()) + with open(self.filename) as f: + for line in f: + self.parse_line(line.strip()) self.remove() self.remove_rpm()