diff options
author | Adam Williamson <awilliam@redhat.com> | 2016-11-21 19:36:49 -0800 |
---|---|---|
committer | Adam Williamson <awilliam@redhat.com> | 2016-11-23 09:21:45 -0800 |
commit | 2e09ca2d007153e02526075bc414e05079e913d3 (patch) | |
tree | 8c9222c47559fb71ee5a8c7aa96ec1923fca21f9 /files/scripts/create-filelist | |
parent | 49dd063d22ffa273f077753023625a3fafdd554a (diff) | |
download | ansible-2e09ca2d007153e02526075bc414e05079e913d3.tar.gz ansible-2e09ca2d007153e02526075bc414e05079e913d3.tar.xz ansible-2e09ca2d007153e02526075bc414e05079e913d3.zip |
turn 'filterlist' into 'imagelist', using productmd
This adopts https://pagure.io/quick-fedora-mirror/pull-request/27
and adapts to it, so we get `imagelist` files rather than
`filterlist` files (see recent commits for this). The rationale
is more fully explained in that PR (and in PR #26 also) - on
further inspection it turns out that we have to filter out an
awful lot of extensions to create small filterlists for all
three modules, and I'm worried that other file extensions may
appear in the future and cause the filterlists to suddenly get
bigger again. Instead, we have create-filelist use the productmd
constant that defines valid image formats, and only include files
that match those formats in the list. The downside of this
approach is we have to ensure productmd on all the systems that
run `create-filelist` is kept up to date if the list of valid
image formats changes.
Diffstat (limited to 'files/scripts/create-filelist')
-rwxr-xr-x | files/scripts/create-filelist | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/files/scripts/create-filelist b/files/scripts/create-filelist index e485efb80..fcbdea468 100755 --- a/files/scripts/create-filelist +++ b/files/scripts/create-filelist @@ -14,6 +14,12 @@ import os import sys from scandir import scandir +# productmd is optional, needed only for the imagelist feature +try: + from productmd.images import SUPPORTED_IMAGE_FORMATS +except ImportError: + SUPPORTED_IMAGE_FORMATS = [] + def get_ftype(entry): """Return a simple indicator of the file type.""" @@ -58,8 +64,8 @@ def parseopts(): null = open(os.devnull, 'w') p = argparse.ArgumentParser( description='Generate a list of files and times, suitable for consumption by quick-fedora-mirror, ' - 'and a much smaller list with packages, Device Tree boot files, HTML files, pictures ' - 'and directories filtered out, for consumption by fedfind.') + 'and (optionally) a much smaller list of only files that match one of the productmd ' + ' supported image types, for use by fedfind.') p.add_argument('-c', '--checksum', action='store_true', help='Include checksums of all repomd.xml files in the file list.') p.add_argument('-C', '--checksum-file', action='append', dest='checksum_files', @@ -75,8 +81,9 @@ def parseopts(): help='Filename of the file list with times (default: stdout).') p.add_argument('-f', '--filelist', type=argparse.FileType('w'), default=null, help='Filename of the file list without times (default: no plain file list is generated).') - p.add_argument('-F', '--filterlist', type=argparse.FileType('w'), default=null, - help='Filename of the filtered file list for fedfind (default: not generated).') + p.add_argument('-i', '--imagelist', type=argparse.FileType('w'), default=null, + help='Filename of the image file list for fedfind (default: not generated). Requires ' + 'the productmd library.') opts = p.parse_args() @@ -99,6 +106,8 @@ def parseopts(): def main(): opts = parseopts() + if opts.imagelist.name != os.devnull and not SUPPORTED_IMAGE_FORMATS: + sys.exit("--imagelist requires the productmd library!") checksums = {} os.chdir(opts.dir) @@ -112,9 +121,9 @@ def main(): # opts.filelist.write(entry.path + '\n') print(entry.path, file=opts.filelist) # write to filtered list if appropriate - skips = ('.rpm', '.drpm', '.dtb', '.html', '.png', '.jpg') - if not any(entry.path.endswith(skip) for skip in skips) and not (entry.is_dir()): - print(entry.path, file=opts.filterlist) + imgs = ['.{0}'.format(form) for form in SUPPORTED_IMAGE_FORMATS] + if any(entry.path.endswith(img) for img in imgs): + print(entry.path, file=opts.imagelist) if entry.name in opts.checksum_files: checksums[entry.path[2:]] = True info = entry.stat(follow_symlinks=False) |