Skip to content

Instantly share code, notes, and snippets.

@jlsherrill
Last active August 29, 2015 14:11
Show Gist options
  • Save jlsherrill/321cf092fce13d1c4f3a to your computer and use it in GitHub Desktop.
Save jlsherrill/321cf092fce13d1c4f3a to your computer and use it in GitHub Desktop.
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