diff options
author | Ben Brown <ben.brown@codethink.co.uk> | 2017-05-17 12:30:48 +0100 |
---|---|---|
committer | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2017-05-17 14:16:56 +0100 |
commit | 8ecf7503e3aabb470499a67130b81fa1546bed19 (patch) | |
tree | 0fe21c8e1574f6424d8f74028f93c239435644c8 /kbas | |
parent | 41dbfc6ac45111bbcbcb78cf767ecc2d2e063829 (diff) | |
download | ybd-8ecf7503e3aabb470499a67130b81fa1546bed19.tar.gz |
Allow rpm uploads without having to tar
Diffstat (limited to 'kbas')
-rwxr-xr-x | kbas/__main__.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kbas/__main__.py b/kbas/__main__.py index 7629710..80de7ef 100755 --- a/kbas/__main__.py +++ b/kbas/__main__.py @@ -23,7 +23,7 @@ from time import strftime, gmtime from datetime import datetime import tempfile from bottle import Bottle, request, response, template, static_file -from subprocess import call +from subprocess import call, check_output from ybd import app, cache @@ -152,7 +152,13 @@ class KeyedBinaryArtifactServer(object): with open(artifact, "w") as f: f.write(upload.value) - if call(['tar', 'tf', artifact]): + if artifact.endswith('.rpm'): + ftype = check_output( + ['file', '--brief', '--mime-type', artifact]).strip() + if ftype != "application/x-rpm": + app.log('UPLOAD', 'ERROR: not a valid rpm:', artifact) + raise TypeError("Not a valid rpm") + elif call(['tar', 'tf', artifact]): app.log('UPLOAD', 'ERROR: not a valid tarfile:', artifact) raise checksum = cache.md5(artifact) |