summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oe/package_manager/rpm/__init__.py33
1 files changed, 21 insertions, 12 deletions
diff --git a/meta/lib/oe/package_manager/rpm/__init__.py b/meta/lib/oe/package_manager/rpm/__init__.py
index b392581069..97ef387f3b 100644
--- a/meta/lib/oe/package_manager/rpm/__init__.py
+++ b/meta/lib/oe/package_manager/rpm/__init__.py
@@ -96,11 +96,15 @@ class RpmPM(PackageManager):
96 archs = ["sdk_provides_dummy_target"] + archs 96 archs = ["sdk_provides_dummy_target"] + archs
97 confdir = "%s/%s" %(self.target_rootfs, "etc/dnf/vars/") 97 confdir = "%s/%s" %(self.target_rootfs, "etc/dnf/vars/")
98 bb.utils.mkdirhier(confdir) 98 bb.utils.mkdirhier(confdir)
99 open(confdir + "arch", 'w').write(":".join(archs)) 99 with open(confdir + "arch", 'w') as f:
100 f.write(":".join(archs))
101
100 distro_codename = self.d.getVar('DISTRO_CODENAME') 102 distro_codename = self.d.getVar('DISTRO_CODENAME')
101 open(confdir + "releasever", 'w').write(distro_codename if distro_codename is not None else '') 103 with open(confdir + "releasever", 'w') as f:
104 f.write(distro_codename if distro_codename is not None else '')
102 105
103 open(oe.path.join(self.target_rootfs, "etc/dnf/dnf.conf"), 'w').write("") 106 with open(oe.path.join(self.target_rootfs, "etc/dnf/dnf.conf"), 'w') as f:
107 f.write("")
104 108
105 109
106 def _configure_rpm(self): 110 def _configure_rpm(self):
@@ -110,14 +114,17 @@ class RpmPM(PackageManager):
110 platformconfdir = "%s/%s" %(self.target_rootfs, "etc/rpm/") 114 platformconfdir = "%s/%s" %(self.target_rootfs, "etc/rpm/")
111 rpmrcconfdir = "%s/%s" %(self.target_rootfs, "etc/") 115 rpmrcconfdir = "%s/%s" %(self.target_rootfs, "etc/")
112 bb.utils.mkdirhier(platformconfdir) 116 bb.utils.mkdirhier(platformconfdir)
113 open(platformconfdir + "platform", 'w').write("%s-pc-linux" % self.primary_arch) 117 with open(platformconfdir + "platform", 'w') as f:
118 f.write("%s-pc-linux" % self.primary_arch)
114 with open(rpmrcconfdir + "rpmrc", 'w') as f: 119 with open(rpmrcconfdir + "rpmrc", 'w') as f:
115 f.write("arch_compat: %s: %s\n" % (self.primary_arch, self.archs if len(self.archs) > 0 else self.primary_arch)) 120 f.write("arch_compat: %s: %s\n" % (self.primary_arch, self.archs if len(self.archs) > 0 else self.primary_arch))
116 f.write("buildarch_compat: %s: noarch\n" % self.primary_arch) 121 f.write("buildarch_compat: %s: noarch\n" % self.primary_arch)
117 122
118 open(platformconfdir + "macros", 'w').write("%_transaction_color 7\n") 123 with open(platformconfdir + "macros", 'w') as f:
124 f.write("%_transaction_color 7\n")
119 if self.d.getVar('RPM_PREFER_ELF_ARCH'): 125 if self.d.getVar('RPM_PREFER_ELF_ARCH'):
120 open(platformconfdir + "macros", 'a').write("%%_prefer_color %s" % (self.d.getVar('RPM_PREFER_ELF_ARCH'))) 126 with open(platformconfdir + "macros", 'a') as f:
127 f.write("%%_prefer_color %s" % (self.d.getVar('RPM_PREFER_ELF_ARCH')))
121 128
122 if self.d.getVar('RPM_SIGN_PACKAGES') == '1': 129 if self.d.getVar('RPM_SIGN_PACKAGES') == '1':
123 signer = get_signer(self.d, self.d.getVar('RPM_GPG_BACKEND')) 130 signer = get_signer(self.d, self.d.getVar('RPM_GPG_BACKEND'))
@@ -164,13 +171,13 @@ class RpmPM(PackageManager):
164 repo_uri = uri + "/" + arch 171 repo_uri = uri + "/" + arch
165 repo_id = "oe-remote-repo" + "-".join(urlparse(repo_uri).path.split("/")) 172 repo_id = "oe-remote-repo" + "-".join(urlparse(repo_uri).path.split("/"))
166 repo_name = "OE Remote Repo:" + " ".join(urlparse(repo_uri).path.split("/")) 173 repo_name = "OE Remote Repo:" + " ".join(urlparse(repo_uri).path.split("/"))
167 open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'a').write( 174 with open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'a') as f:
168 "[%s]\nname=%s\nbaseurl=%s\n%s\n" % (repo_id, repo_name, repo_uri, gpg_opts)) 175 f.write("[%s]\nname=%s\nbaseurl=%s\n%s\n" % (repo_id, repo_name, repo_uri, gpg_opts))
169 else: 176 else:
170 repo_name = "OE Remote Repo:" + " ".join(urlparse(uri).path.split("/")) 177 repo_name = "OE Remote Repo:" + " ".join(urlparse(uri).path.split("/"))
171 repo_uri = uri 178 repo_uri = uri
172 open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'w').write( 179 with open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'w') as f:
173 "[%s]\nname=%s\nbaseurl=%s\n%s" % (repo_base, repo_name, repo_uri, gpg_opts)) 180 f.write("[%s]\nname=%s\nbaseurl=%s\n%s" % (repo_base, repo_name, repo_uri, gpg_opts))
174 181
175 def _prepare_pkg_transaction(self): 182 def _prepare_pkg_transaction(self):
176 os.environ['D'] = self.target_rootfs 183 os.environ['D'] = self.target_rootfs
@@ -329,7 +336,8 @@ class RpmPM(PackageManager):
329 return e.output.decode("utf-8") 336 return e.output.decode("utf-8")
330 337
331 def dump_install_solution(self, pkgs): 338 def dump_install_solution(self, pkgs):
332 open(self.solution_manifest, 'w').write(" ".join(pkgs)) 339 with open(self.solution_manifest, 'w') as f:
340 f.write(" ".join(pkgs))
333 return pkgs 341 return pkgs
334 342
335 def load_old_install_solution(self): 343 def load_old_install_solution(self):
@@ -363,7 +371,8 @@ class RpmPM(PackageManager):
363 bb.utils.mkdirhier(target_path) 371 bb.utils.mkdirhier(target_path)
364 num = self._script_num_prefix(target_path) 372 num = self._script_num_prefix(target_path)
365 saved_script_name = oe.path.join(target_path, "%d-%s" % (num, pkg)) 373 saved_script_name = oe.path.join(target_path, "%d-%s" % (num, pkg))
366 open(saved_script_name, 'w').write(output) 374 with open(saved_script_name, 'w') as f:
375 f.write(output)
367 os.chmod(saved_script_name, 0o755) 376 os.chmod(saved_script_name, 0o755)
368 377
369 def _handle_intercept_failure(self, registered_pkgs): 378 def _handle_intercept_failure(self, registered_pkgs):