Target map-packages deprecation message

Currently every run of install-packages puts out a warning that
map-packages is obsolete.  This happens even if map-package does no
mapping.  The caller can't prevent the call (it's part of
install-packages) and it gives no actionable help if there is
something wrong.

Keep track of any mappings we are doing in the obsolete map-packages
run and only output a warning if we actually translate anything.  If
we do output, tell the caller what packages were translated so they
can make appropriate pkg-map entries.

Change-Id: Ibfe69dc84246662ed8caa0d4c3e2edf68314c87e
This commit is contained in:
Ian Wienand 2017-01-18 07:05:17 +11:00
parent e3b67a3d45
commit 5bd8158862
2 changed files with 50 additions and 9 deletions

View File

@ -22,6 +22,13 @@ import sys
# Manually maintained for brevity; consider making this compiled from
# distromatch or other rich data sources.
# Debian name on the left, Fedora/RHEL on the right.
#
# !!! DO NOT ADD ANY ENTRIES TO THIS FILE !!!
#
# This global list has been deprecated by the pkg-map element. New
# package mappings should go in pkg-map files inside each element.
#
package_map = {
'apache2': 'httpd',
'arping': 'iputils',
@ -81,13 +88,30 @@ package_map = {
'openstack-neutron-dhcp-agent': 'openstack-neutron',
}
print("WARNING: map-packages is deprecated. Please use the pkg-map element.",
file=sys.stderr)
deprecated = []
for arg in sys.argv[1:]:
if arg not in package_map and arg.endswith('-dev'):
# convert -dev into devel
print('%s%s' % (arg, 'el'))
converted = '%s%s' % (arg, 'el')
deprecated.append((arg, converted))
print(converted)
else:
print(package_map.get(arg, arg))
converted = package_map.get(arg, arg)
if converted != arg:
deprecated.append((arg, converted))
print(converted)
if deprecated:
print("WARNING: The following packages were re-mapped by "
"redhat-common map-packages\n"
"They should be converted to pkg-map:", file=sys.stderr)
for arg, converted in deprecated:
print(" %s -> %s" % (arg, converted), file=sys.stderr)
sys.exit(0)
# Tell emacs to use python-mode
# Local variables:
# mode: python
# End:

View File

@ -18,6 +18,14 @@ import sys
# Manually maintained for brevity; consider making this compiled from
# distromatch or other rich data sources.
# Debian name on the left, RHEL on the right.
#
# !!! DO NOT ADD ANY ENTRIES TO THIS FILE !!!
#
# This global list has been deprecated by the pkg-map element. New
# package mappings should go in pkg-map files inside each element.
#
package_map = {
'augeas-tools': 'augeas',
'build-essential': 'make automake gcc gcc-c++ kernel-devel',
@ -40,9 +48,18 @@ package_map = {
'vlan': 'vconfig',
}
print("WARNING: map-packages is deprecated. Please use the pkg-map element.",
file=sys.stderr)
deprecated = []
for arg in sys.argv[1:]:
print(package_map.get(arg, arg))
mapped = package_map.get(arg, arg)
if mapped != arg:
deprecated.append((arg, mapped))
print(mapped)
if deprecated:
print("WARNING: The following packages were re-mapped by "
"rhel map-packages.\n"
"They should be converted to pkg-map:\n", file=sys.stderr)
for arg, converted in deprecated:
print(" %s -> %s" % (arg, converted), file=sys.stderr)
sys.exit(0)