CentOS 8: Fix swtpm build error

Change python to python3

Story: 2006729
Task: 37892

Change-Id: Iab66fe528750bd2d97946057c33a0711238048e2
Signed-off-by: Long Li <lilong-neu@neusoft.com>
This commit is contained in:
Long Li 2019-12-25 18:10:39 +08:00 committed by Lin Shuicheng
parent a7fd513689
commit 8d37c4351c
3 changed files with 64 additions and 2 deletions

View File

@ -1,2 +1,2 @@
COPY_LIST="$PKG_BASE/files/* $CGCS_BASE/downloads/swtpm-0.1.0-253eac5.tar.gz"
COPY_LIST="$PKG_BASE/files/* $PKG_BASE/patches/* $CGCS_BASE/downloads/swtpm-0.1.0-253eac5.tar.gz"
TIS_PATCH_VER=1

View File

@ -26,6 +26,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
#STX
Source1: setup_vtpm
Patch1: 0001-change-python-to-python3.patch
# due to gnutls backlevel API:
%if 0%{?rhel} >= 7 || 0%{?fedora} >= 19
@ -36,7 +37,7 @@ Source1: setup_vtpm
BuildRequires: automake autoconf bash coreutils libtool sed
BuildRequires: libtpms-devel >= 0.6.0 fuse-devel glib2-devel gmp-devel
BuildRequires: expect bash net-tools nss-devel socat python-twisted
BuildRequires: expect bash net-tools nss-devel socat python3-twisted
%if %{with_gnutls}
BuildRequires: gnutls >= 3.1.0 gnutls-devel gnutls-utils
BuildRequires: libtasn1-devel libtasn1
@ -154,6 +155,8 @@ Tools for the TPM emulator from the swtpm package
%prep
%setup -q
%patch1 -p1
%build
#STX

View File

@ -0,0 +1,59 @@
From 96dce63b7f7d70bb3e8734ee0bcd0f967390a7d3 Mon Sep 17 00:00:00 2001
From: chendongqi <chen.dq@neusoft.com>
Date: Thu, 19 Dec 2019 17:15:21 +0800
Subject: [PATCH] change-python-to-python3
Signed-off-by: Long Li <lilong-neu@neusoft.com>
---
tests/test_clientfds.py | 10 +++++++---
tests/test_ctrlchannel3 | 2 +-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tests/test_clientfds.py b/tests/test_clientfds.py
index 7dbbfce..6f301db 100755
--- a/tests/test_clientfds.py
+++ b/tests/test_clientfds.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
import os
import sys
@@ -42,7 +42,11 @@ def spawn_swtpm():
cmd += " --pid file=" + pidfile + " --tpmstate dir=" + tpmpath
print("Running child cmd: %s" % cmd)
try:
- child = subprocess.Popen(cmd.split())
+ if sys.version_info[0] >= 3:
+ child = subprocess.Popen(cmd.split(),
+ pass_fds=[_fd.fileno(), _ctrlfd.fileno()])
+ else:
+ child = subprocess.Popen(cmd.split())
except OSError as err:
print("OS error: %d" % err.errno)
return False
@@ -94,7 +98,7 @@ if __name__ == "__main__":
else:
res = 0
except:
- print "__Exception: ", sys.exc_info()
+ print("__Exception: ", sys.exc_info())
res = -1
if child:
diff --git a/tests/test_ctrlchannel3 b/tests/test_ctrlchannel3
index 4fe7363..588a5a7 100755
--- a/tests/test_ctrlchannel3
+++ b/tests/test_ctrlchannel3
@@ -44,7 +44,7 @@ if wait_for_file $PID_FILE 3; then
exit 1
fi
-LOG=$(SOCK_PATH=$SWTPM_CTRL_UNIX_PATH exec python $DIR/test_setdatafd.py)
+LOG=$(SOCK_PATH=$SWTPM_CTRL_UNIX_PATH exec python3 $DIR/test_setdatafd.py)
res=$?
if [ $res -ne 0 ]; then
--
2.7.4