Last active
August 29, 2015 14:11
-
-
Save jlsherrill/321cf092fce13d1c4f3a to your computer and use it in GitHub Desktop.
Script to generate repos syncable by katello/pulp for built puppet modules.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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