image-minimizer: Fix utf8 error and add docs
rpm returns a header that is a string, no need to call decode() on it. Also added documentation and a manpage for image-minimizer
This commit is contained in:
parent
d692ce3662
commit
f8af828a80
@ -266,6 +266,7 @@ man_pages = [
|
|||||||
('lorax', 'lorax', u'Lorax Documentation', [u'Weldr Team'], 1),
|
('lorax', 'lorax', u'Lorax Documentation', [u'Weldr Team'], 1),
|
||||||
('livemedia-creator', 'livemedia-creator', u'Live Media Creator 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),
|
('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.
|
# If true, show URL addresses after external links.
|
||||||
|
99
docs/image-minimizer.rst
Normal file
99
docs/image-minimizer.rst
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
image-minimizer
|
||||||
|
===============
|
||||||
|
|
||||||
|
:Authors:
|
||||||
|
Brian C. Lane <bcl@redhat.com>
|
||||||
|
|
||||||
|
`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 <PATTERN>
|
||||||
|
This will remove files from the installation.
|
||||||
|
|
||||||
|
* keep <PATTERN>
|
||||||
|
This will keep files, and should follow any `drop` commands including globs.
|
||||||
|
|
||||||
|
* droprpm <PATTERN>
|
||||||
|
Remove matching rpm packages. Dependencies are not remove, just individual
|
||||||
|
packages matching the glob.
|
||||||
|
|
||||||
|
* keeprpm <PATTERN>
|
||||||
|
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
|
@ -16,6 +16,7 @@ Contents:
|
|||||||
livemedia-creator
|
livemedia-creator
|
||||||
mkksiso
|
mkksiso
|
||||||
product-images
|
product-images
|
||||||
|
image-minimizer
|
||||||
modules
|
modules
|
||||||
|
|
||||||
Documentation for other Lorax Branches
|
Documentation for other Lorax Branches
|
||||||
|
@ -70,7 +70,7 @@ class ImageMinimizer:
|
|||||||
not_found = True
|
not_found = True
|
||||||
for hdr in mi:
|
for hdr in mi:
|
||||||
not_found = False
|
not_found = False
|
||||||
rpms.add(hdr['name'].decode("utf8"))
|
rpms.add(hdr['name'])
|
||||||
if self.verbose and not_found:
|
if self.verbose and not_found:
|
||||||
print("%s package not found" % pattern)
|
print("%s package not found" % pattern)
|
||||||
|
|
||||||
@ -145,7 +145,8 @@ class ImageMinimizer:
|
|||||||
self.ts.run(runCallback, "erase")
|
self.ts.run(runCallback, "erase")
|
||||||
|
|
||||||
def filter(self):
|
def filter(self):
|
||||||
for line in (open(self.filename).readlines()):
|
with open(self.filename) as f:
|
||||||
|
for line in f:
|
||||||
self.parse_line(line.strip())
|
self.parse_line(line.strip())
|
||||||
self.remove()
|
self.remove()
|
||||||
self.remove_rpm()
|
self.remove_rpm()
|
||||||
|
Loading…
Reference in New Issue
Block a user