Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 832726 Details for
Bug 1038211
RFE: include rpmdev-splitfilename
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
rpmdev-splitfilename
rpmdev-splitfilename (text/plain), 4.83 KB, created by
tal
on 2013-12-04 15:49:33 UTC
(
hide
)
Description:
rpmdev-splitfilename
Filename:
MIME Type:
Creator:
tal
Created:
2013-12-04 15:49:33 UTC
Size:
4.83 KB
patch
obsolete
>#!/usr/bin/python ># ># rpmdev-splitfilename -- parse the parts of a package name ># ># Copyright (c) Thomas A. Limoncelli ># ># 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > >import os >import re >import sys >import rpmUtils.miscutils > >def usage(): > print """ >rpmdev-splitfilename filename.rpm [filename2.rpm] # On the command line >rpmdev-splitfilename <list.txt # Stdin > >Outputs a TAB separated list of the name components: >Field Description Example: > 1 The directory path leading up to the package name. May be null. > 2 Package Name > 3 Package Version 1.2 > 4 The full release 3.el6 > 5 Epoch. Usually null. > 6 Architecture x86_64 > 7 Version plus release 1.2.3 > 8 Integer portion of release 3 > 9 Platform el6.x86_64 > >The input can be just the package name or a path to the file name. The >RPM file does not have to exist; it is never actually accessed. > >If there is a parse error, the exit status will be non-zero. > >Examples: > $ rpmdev-splitfilename path/to/example-1.2-3.el6.x86_64.rpm > path/to example 1.2 3.el6 x86_64 1.2-3 3 el6.x86_64 > $ rpmdev-splitfilename example-1.2-3.el6.x86_64.rpm > example 1.2 3.el6 x86_64 1.2-3 3 el6.x86_64 > $ echo /path/example-1.2-3.el6.x86_64.rpm | rpmdev-splitfilename > /path/to example 1.2 3.el6 x86_64 1.2-3 3 el6.x86_64 > $ rpmdev-splitfilename example-1.2-3.el6.x86_64.rpm | awk -F'\t' '{ print $7 }' > 1.2-3 >""".strip() > ># Discarded. It works but it does not handle epoch. >#def nameparse_regex(fullname): ># m = re.search(r'(.*/)*(.*)-(.*)-(.*?)\.(.*)(\.rpm)', fullname) ># if m: ># (path, name, version, release, arch, _) = m.groups() ># path = path or '' ># verrel = version + '-' + release ># if path != '/' and path[-1:] == '/': ># path = path[:-1] ># return (path, name, verrel, version, release, arch) ># else: ># return False > ># Discarded. It works but it does not handle epoch. >#def nameparse_split(fullname): ># # According to http://www.rpm.org/max-rpm/ch-rpm-file-format.html ># # the full name is segmented by '-' with the first part being the only ># # one that can contain '-' itself. ># # Therefore we split it on '-', then work with the parts from there. ># parts = fullname.strip().split('-') ># if len(parts) < 3: ># return False ># # Merge the initial parts to form the path and name. ># longpath = '-'.join(parts[:-2]) ># (path, name) = os.path.split(longpath) ># # The version is the 2nd to last part. ># version = parts[-2] ># # The last part is segmented on '.': release.arch.rpm ># endparts = parts[-1].split('.') ># # Remove the .rpm ># if endparts[-1] == 'rpm': # Allow for input without a .rpm suffix. ># endparts.pop() ># # The remainder is the release followed by arch. ># release = endparts[0] ># arch = '.'.join(endparts[1:]) ># # Generate version-release as output as a convenience. ># verrel = version + '-' + release ># # Done. ># return (path, name, verrel, version, release, arch) > >def nameparse_splitFilename(fullname): > if len(fullname.split('-')) < 3: > return False > (longpath, version, release_plus, epoch, arch) = rpmUtils.miscutils.splitFilename(fullname.strip()) > (path, name) = os.path.split(longpath) > endparts = release_plus.split('.') > pure_release = endparts[0] > platform = '.'.join(endparts[1:] + [arch]) > verrel = version + '-' + pure_release > return (path, name, version, release_plus, epoch, arch, verrel, pure_release, platform) > >#nameparse = nameparse_regex >#nameparse = nameparse_split >nameparse = nameparse_splitFilename > >def parse_and_print(fullname): > result = nameparse(fullname) > if result: > print "\t".join(result) > else: > sys.stderr.write('ERROR: Invalid name: %s\n' % fullname) > sys.exit(1) > >def main(): > if len(sys.argv) > 1 and sys.argv[1] in ['-h', '--help', '-help', '--usage']: > usage() > sys.exit(0) > if len(sys.argv) > 1: > for fullname in sys.argv[1:]: > parse_and_print(fullname) > else: > import fileinput > for fullname in fileinput.input(): > parse_and_print(fullname) > sys.exit(0) > >if __name__ == "__main__": > main()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1038211
: 832726