anvil/tools/explode_envra
Joshua Harlow 95c0b10ab0 Extract the correct rpm name using a new envra exploding helper
Change-Id: I602eba8d388f530716643a6ce8cae9dde4c80a86
2014-08-26 22:10:43 -07:00

49 lines
1.4 KiB
Python
Executable File

#!/usr/bin/python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Copyright 2005 Duke University
# Parts Copyright 2007 Red Hat, Inc
from rpmUtils import miscutils
import os
import sys
try:
import simplejson as json
except ImportError:
import json
def main():
if len(sys.argv) <= 1:
print("%s filename ..." % os.path.basename(sys.argv[0]))
return 1
for filename in sys.argv[1:]:
(name, ver, rel, epoch, arch) = miscutils.splitFilename(filename)
holder = {
'name': name,
'version': ver,
'release': rel,
'epoch': epoch,
'arch': arch,
}
print(json.dumps(holder))
return 0
if __name__ == '__main__':
sys.exit(main())