summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbiao716.wang <biao716.wang@samsung.com>2023-06-27 15:42:18 +0900
committerbiao716.wang <biao716.wang@samsung.com>2023-07-05 20:37:15 +0900
commit2ecd2970217ce53195ad2baf5f979b1f89bac862 (patch)
tree38d2fa3f64ad6b548b190c4e1e32e94618297ec1
parent083bed9db46569c9843665b715adfb50d294a03e (diff)
downloadmic-2ecd2970217ce53195ad2baf5f979b1f89bac862.tar.gz
mic-2ecd2970217ce53195ad2baf5f979b1f89bac862.tar.bz2
mic-2ecd2970217ce53195ad2baf5f979b1f89bac862.zip
fix run error with tpk packagees
Change-Id: I2ac5002e1d7f0dda01fe32a75e779c6db994d41a Signed-off-by: biao716.wang <biao716.wang@samsung.com>
-rw-r--r--mic/3rdparty/pykickstart/base.py3
-rw-r--r--mic/bootstrap.py2
-rw-r--r--mic/imager/baseimager.py16
-rwxr-xr-xmic/kickstart/__init__.py22
-rw-r--r--mic/msger.py2
-rwxr-xr-xmic/utils/misc.py2
-rw-r--r--mic/utils/rpmmisc.py8
-rw-r--r--tests/test_baseimager.py2
8 files changed, 31 insertions, 26 deletions
diff --git a/mic/3rdparty/pykickstart/base.py b/mic/3rdparty/pykickstart/base.py
index b1b7c19..c368702 100644
--- a/mic/3rdparty/pykickstart/base.py
+++ b/mic/3rdparty/pykickstart/base.py
@@ -50,7 +50,7 @@ from pykickstart import __version__
from pykickstart.errors import KickstartParseError, KickstartParseWarning, KickstartDeprecationWarning
from pykickstart.ko import KickstartObject
from pykickstart.version import versionToString
-from pykickstart.parser import Packages
+from pykickstart.parser import Packages, TpkPackages
###
### COMMANDS
@@ -482,6 +482,7 @@ class BaseHandler(KickstartHandler):
# everything else I can think of.
self.scripts = []
self.packages = Packages()
+ self.tpk_packages = TpkPackages()
self.platform = ""
# Any sections that we do not understand but want to prevent causing errors
diff --git a/mic/bootstrap.py b/mic/bootstrap.py
index f1bd137..f5df5f1 100644
--- a/mic/bootstrap.py
+++ b/mic/bootstrap.py
@@ -179,7 +179,7 @@ class MiniBackend(object):
os.makedirs(tmpdir)
tmpfd, tmpfp = tempfile.mkstemp(dir=tmpdir, prefix="%s.pre-" % pkg)
script = script.replace('\r', '')
- os.write(tmpfd, script)
+ os.write(tmpfd, script.encode())
os.close(tmpfd)
os.chmod(tmpfp, 0o700)
diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py
index e3edcbb..2602c60 100644
--- a/mic/imager/baseimager.py
+++ b/mic/imager/baseimager.py
@@ -1263,10 +1263,10 @@ class BaseImageCreator(object):
(fd, path) = tempfile.mkstemp(prefix="ks-runscript-",
dir=self._instroot + "/tmp")
s.script = s.script.replace("\r", "")
- os.write(fd, s.script)
+ os.write(fd, s.script.encode())
if s.interp == '/bin/sh' or s.interp == '/bin/bash':
- os.write(fd, '\n')
- os.write(fd, 'exit 0\n')
+ os.write(fd, '\n'.encode())
+ os.write(fd, 'exit 0\n'.encode())
os.close(fd)
os.chmod(path, 0o700)
@@ -1280,7 +1280,7 @@ class BaseImageCreator(object):
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
while p.poll() == None:
- msger.info(p.stdout.readline().strip())
+ msger.info(p.stdout.readline().strip().decode())
if p.returncode != 0:
raise CreatorError("Failed to execute %%sign script "
"with '%s'" % (s.interp))
@@ -1301,10 +1301,10 @@ class BaseImageCreator(object):
dir=self._instroot + "/tmp")
s.script = s.script.replace("\r", "")
- os.write(fd, s.script)
+ os.write(fd, s.script.encode())
if s.interp == '/bin/sh' or s.interp == '/bin/bash':
- os.write(fd, '\n')
- os.write(fd, 'exit 0\n')
+ os.write(fd, '\n'.encode())
+ os.write(fd, 'exit 0\n'.encode())
os.close(fd)
os.chmod(path, 0o700)
@@ -1327,7 +1327,7 @@ class BaseImageCreator(object):
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
while p.poll() == None:
- msger.info(p.stdout.readline().strip())
+ msger.info(p.stdout.readline().strip().decode())
end_time = time.time()
if (end_time - start_time)/60 > configmgr.create['postscripts_maxruntime']:
raise CreatorError("Your post script is executed more than %d mins, please check it!" % configmgr.create['postscripts_maxruntime'])
diff --git a/mic/kickstart/__init__.py b/mic/kickstart/__init__.py
index a5f46ef..049dbb0 100755
--- a/mic/kickstart/__init__.py
+++ b/mic/kickstart/__init__.py
@@ -321,7 +321,7 @@ class UserConfig(KickstartConfig):
def addUser(self, userconfig):
args = [ "/usr/sbin/useradd" ]
if userconfig.groups:
- args += [ "--groups", string.join(userconfig.groups, ",") ]
+ args += [ "--groups", ",".join(userconfig.groups) ]
if userconfig.name:
args += [ "-m"]
args += [ "-d", "/home/%s" % userconfig.name ]
@@ -357,7 +357,7 @@ class UserConfig(KickstartConfig):
if userconfig.name == "root":
msger.debug("root user, just set root user groups attribution")
if userconfig.groups:
- self.call(["/usr/sbin/usermod", "-a", "-G", "%s" % string.join(userconfig.groups, ","), "root"])
+ self.call(["/usr/sbin/usermod", "-a", "-G", "%s" % ",".join(userconfig.groups), "root"])
continue
self.addUser(userconfig)
@@ -386,7 +386,7 @@ class XConfig(KickstartConfig):
if ksxconfig.defaultdesktop:
self._check_sysconfig()
f = open(self.path("/etc/sysconfig/desktop"), "w")
- f.write("DESKTOP="+ksxconfig.defaultdesktop+"\n")
+ f.write("DESKTOP=" + str(ksxconfig.defaultdesktop) + "\n")
f.close()
class DesktopConfig(KickstartConfig):
@@ -396,28 +396,28 @@ class DesktopConfig(KickstartConfig):
if ksdesktop.defaultdesktop:
self._check_sysconfig()
f = open(self.path("/etc/sysconfig/desktop"), "w")
- f.write("DESKTOP="+ksdesktop.defaultdesktop+"\n")
+ f.write("DESKTOP=" + str(ksdesktop.defaultdesktop) + "\n")
f.close()
if os.path.exists(self.path("/etc/gdm/custom.conf")):
f = open(self.path("/etc/skel/.dmrc"), "w")
f.write("[Desktop]\n")
- f.write("Session="+ksdesktop.defaultdesktop.lower()+"\n")
+ f.write("Session=" + str(ksdesktop.defaultdesktop.lower()) + "\n")
f.close()
if ksdesktop.session:
if os.path.exists(self.path("/etc/sysconfig/uxlaunch")):
f = open(self.path("/etc/sysconfig/uxlaunch"), "a+")
- f.write("session="+ksdesktop.session.lower()+"\n")
+ f.write("session=" + str(ksdesktop.session.lower()) + "\n")
f.close()
if ksdesktop.autologinuser:
self._check_sysconfig()
f = open(self.path("/etc/sysconfig/desktop"), "a+")
- f.write("AUTOLOGIN_USER=" + ksdesktop.autologinuser + "\n")
+ f.write("AUTOLOGIN_USER=" + str(ksdesktop.autologinuser) + "\n")
f.close()
if os.path.exists(self.path("/etc/gdm/custom.conf")):
f = open(self.path("/etc/gdm/custom.conf"), "w")
f.write("[daemon]\n")
f.write("AutomaticLoginEnable=true\n")
- f.write("AutomaticLogin=" + ksdesktop.autologinuser + "\n")
+ f.write("AutomaticLogin=" + str(ksdesktop.autologinuser) + "\n")
f.close()
class MoblinRepoConfig(KickstartConfig):
@@ -873,7 +873,7 @@ def inst_langs(ks):
def get_post_scripts(ks):
scripts = []
for s in ks.handler.scripts:
- if s.type != ksparser.KS_SCRIPT_POST:
+ if s.type != ksparser.constants.KS_SCRIPT_POST:
continue
scripts.append(s)
return scripts
@@ -881,8 +881,8 @@ def get_post_scripts(ks):
def get_sign_scripts(ks):
scripts = []
for s in ks.handler.scripts:
- if (s.type == ksparser.KS_SCRIPT_RUN or \
- s.type == ksparser.KS_SCRIPT_UMOUNT):
+ if (s.type == ksparser.constants.KS_SCRIPT_RUN or \
+ s.type == ksparser.constants.KS_SCRIPT_UMOUNT):
scripts.append(s)
return scripts
diff --git a/mic/msger.py b/mic/msger.py
index 99e4c94..8402f0e 100644
--- a/mic/msger.py
+++ b/mic/msger.py
@@ -170,6 +170,8 @@ class MicFileHandler(logging.FileHandler):
# we don't use FileHandler to initialize,
# because filename might be expected to None
logging.Handler.__init__(self)
+ self._builtin_open = open
+ self.errors = None
self.stream = None
if filename:
self.baseFilename = os.path.abspath(filename)
diff --git a/mic/utils/misc.py b/mic/utils/misc.py
index e50f8f3..fd7a080 100755
--- a/mic/utils/misc.py
+++ b/mic/utils/misc.py
@@ -180,7 +180,7 @@ def extract_rpm(rpmfile, targetdir):
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p1.stdout.close()
(sout, serr) = p2.communicate()
- msger.verbose(sout or serr)
+ msger.verbose(sout.decode() or serr.decode())
os.chdir(olddir)
diff --git a/mic/utils/rpmmisc.py b/mic/utils/rpmmisc.py
index 9d36586..a4c4962 100644
--- a/mic/utils/rpmmisc.py
+++ b/mic/utils/rpmmisc.py
@@ -51,12 +51,14 @@ class RPMInstallCallback:
tmpepoch = hdr['epoch']
if tmpepoch is None: epoch = '0'
else: epoch = str(tmpepoch)
-
+ #name, version, release must have value according to spec rule.
return (hdr['name'], hdr['arch'], epoch, hdr['version'], hdr['release'])
def _makeHandle(self, hdr):
- handle = '%s:%s.%s-%s-%s' % (hdr['epoch'], hdr['name'], hdr['version'],
- hdr['release'], hdr['arch'])
+ tmpepoch = hdr['epoch']
+ if tmpepoch is None: epoch = '0'
+ else: epoch = str(tmpepoch) #epoch is 'int' object
+ handle = '%s:%s.%s-%s-%s' % (tmpepoch, hdr['name'], hdr['version'], hdr['release'], hdr['arch'])
return handle
diff --git a/tests/test_baseimager.py b/tests/test_baseimager.py
index a4f66e8..4049daf 100644
--- a/tests/test_baseimager.py
+++ b/tests/test_baseimager.py
@@ -55,7 +55,7 @@ class BaseImgrTest(unittest.TestCase):
dev_null = os.open("/dev/null", os.O_WRONLY)
p = subprocess.Popen('mount', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- for entry in p.communicate()[0].split('\n'):
+ for entry in p.communicate()[0].decode().split('\n'):
if entry.find(pattern) > 0:
real_mount_list.append(entry.split(' ')[2])
real_mount_list.sort()