From 98159abd6965d32805e17a859b2d08c6fa42ec8a Mon Sep 17 00:00:00 2001
From: Zbynek Moravec <zmoravec@redhat.com>
Date: Wed, 8 Jul 2015 15:10:18 +0200
Subject: [PATCH] trac#469 Add Python3 support. Fix --srpm-destination
---
utils/scap-as-rpm | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/utils/scap-as-rpm b/utils/scap-as-rpm
index fee1f5b..4dae7d9 100755
--- a/utils/scap-as-rpm
+++ b/utils/scap-as-rpm
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/python
# Copyright 2013 Red Hat Inc., Durham, North Carolina.
# All Rights Reserved.
#
@@ -70,7 +70,7 @@ except ImportError:
opts, args = optparse.OptionParser.parse_args(self, args, values)
if self._args_spec:
if not args:
- print "Missing arguments: %s" % self._args_spec
+ print("Missing arguments: %s" % self._args_spec)
self.print_help()
setattr(opts, self._args_name, args)
@@ -87,7 +87,7 @@ except ImportError:
if fobj:
fobj.write("%s\n" % self._args_description)
else:
- print self._args_description
+ print(self._args_description)
ParserClass = ArgOptParserShim
@@ -136,7 +136,7 @@ if subprocess.call(["rpmbuild", "--version"], stdout = sys.stdout, stderr = sys.
sys.exit(1)
def get_rpmbuild_paths():
- sources = subprocess_check_output(["rpm", "--eval", "%{_sourcedir}"]).strip()
+ sources = subprocess_check_output(["rpm", "--eval", "%{_sourcedir}"]).strip().decode('utf-8')
if not os.path.exists(sources):
if subprocess.call(["rpmdev-setuptree"], stdout = sys.stdout, stderr = sys.stderr) != 0:
@@ -145,8 +145,8 @@ def get_rpmbuild_paths():
"'%s'\n" % (sources))
raise CannotContinueError()
- rpm = subprocess_check_output(["rpm", "--eval", "%{_rpmdir}"]).strip()
- srpm = subprocess_check_output(["rpm", "--eval", "%{_srcrpmdir}"]).strip()
+ rpm = subprocess_check_output(["rpm", "--eval", "%{_rpmdir}"]).strip().decode('utf-8')
+ srpm = subprocess_check_output(["rpm", "--eval", "%{_srcrpmdir}"]).strip().decode('utf-8')
if not os.path.exists(rpm) or not os.path.exists(srpm):
sys.stderr.write("The SOURCES rpmbuild directory exists but RPM or SRPM do not. Please make "
@@ -201,7 +201,7 @@ BuildArch: noarch
#Requires: openscap-utils >= ${__package_openscap_version}
%description
-asdf
+This package was generated by scap-as-rpm.
%prep
${__package_prepper}
@@ -272,7 +272,7 @@ def main():
help = "The folder (absolute or relative to CWD) where the result RPM shall be saved.")
parser.add_argument("--srpm-destination", dest = "srpm_destination", default = None,
help = "The folder (absolute or relative to CWD) where the result SRPM shall be saved.")
- parser.add_argument("files", metavar="FILE", nargs="+",
+ parser.add_argument("files", metavar = "FILE", nargs = "+",
help = "List of files that should be put into the result package. "
"These should be SCAP XML files but such requirement is not enforced.")
@@ -332,7 +332,7 @@ def main():
shutil.copy(os.path.join(rpmbuild_rpm_path, "noarch", rpm_basename), os.path.join(args.rpm_destination, rpm_basename))
if args.srpm_destination is not None:
- shutil.copy(os.path.join(rpmbuild_srpm_path, srpm_basename), os.path.join(args.srpm_destination, rpm_basename))
+ shutil.copy(os.path.join(rpmbuild_srpm_path, srpm_basename), os.path.join(args.srpm_destination, srpm_basename))
print("")
print("Resulting RPM:\t'%s'" % (os.path.join(args.rpm_destination, rpm_basename)))