Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to generate repos syncable by katello/pulp for built puppet modules.
#!/usr/bin/env python
import sys
import os
from hashlib import sha256
ARCHIVE_SUFFIX = '.tar.gz'
def digest(path):
h = sha256()
with open(path) as fp:
h.update(fp.read())
return h.hexdigest()
def chdir(path):
if path:
print 'cd %s' % path
os.chdir(path)
def build_manifest(path):
_dir = os.getcwd()
chdir(path)
with open('PULP_MANIFEST', 'w+') as fp:
for path in os.listdir('.'):
if not path.endswith(ARCHIVE_SUFFIX):
continue
fp.write(path)
fp.write(',%s' % digest(path))
fp.write(',%s\n' % os.path.getsize(path))
chdir(_dir)
if len(sys.argv) == 2:
build_manifest(sys.argv[1])
else:
print "require path to modules"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment