mirror of
https://git.yoctoproject.org/poky
synced 2026-03-11 17:59:39 +01:00
oe/packagemanager/rpm: don't leak file objects
(From OE-Core rev: 406abef218a7e743f7892eff4c13fa0f889aa7f2) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 28706c27680745c9f8df27713ce63ef5d611138c) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
8c13777e74
commit
36bc011714
@@ -96,11 +96,15 @@ class RpmPM(PackageManager):
|
||||
archs = ["sdk_provides_dummy_target"] + archs
|
||||
confdir = "%s/%s" %(self.target_rootfs, "etc/dnf/vars/")
|
||||
bb.utils.mkdirhier(confdir)
|
||||
open(confdir + "arch", 'w').write(":".join(archs))
|
||||
distro_codename = self.d.getVar('DISTRO_CODENAME')
|
||||
open(confdir + "releasever", 'w').write(distro_codename if distro_codename is not None else '')
|
||||
with open(confdir + "arch", 'w') as f:
|
||||
f.write(":".join(archs))
|
||||
|
||||
open(oe.path.join(self.target_rootfs, "etc/dnf/dnf.conf"), 'w').write("")
|
||||
distro_codename = self.d.getVar('DISTRO_CODENAME')
|
||||
with open(confdir + "releasever", 'w') as f:
|
||||
f.write(distro_codename if distro_codename is not None else '')
|
||||
|
||||
with open(oe.path.join(self.target_rootfs, "etc/dnf/dnf.conf"), 'w') as f:
|
||||
f.write("")
|
||||
|
||||
|
||||
def _configure_rpm(self):
|
||||
@@ -110,14 +114,17 @@ class RpmPM(PackageManager):
|
||||
platformconfdir = "%s/%s" %(self.target_rootfs, "etc/rpm/")
|
||||
rpmrcconfdir = "%s/%s" %(self.target_rootfs, "etc/")
|
||||
bb.utils.mkdirhier(platformconfdir)
|
||||
open(platformconfdir + "platform", 'w').write("%s-pc-linux" % self.primary_arch)
|
||||
with open(platformconfdir + "platform", 'w') as f:
|
||||
f.write("%s-pc-linux" % self.primary_arch)
|
||||
with open(rpmrcconfdir + "rpmrc", 'w') as f:
|
||||
f.write("arch_compat: %s: %s\n" % (self.primary_arch, self.archs if len(self.archs) > 0 else self.primary_arch))
|
||||
f.write("buildarch_compat: %s: noarch\n" % self.primary_arch)
|
||||
|
||||
open(platformconfdir + "macros", 'w').write("%_transaction_color 7\n")
|
||||
with open(platformconfdir + "macros", 'w') as f:
|
||||
f.write("%_transaction_color 7\n")
|
||||
if self.d.getVar('RPM_PREFER_ELF_ARCH'):
|
||||
open(platformconfdir + "macros", 'a').write("%%_prefer_color %s" % (self.d.getVar('RPM_PREFER_ELF_ARCH')))
|
||||
with open(platformconfdir + "macros", 'a') as f:
|
||||
f.write("%%_prefer_color %s" % (self.d.getVar('RPM_PREFER_ELF_ARCH')))
|
||||
|
||||
if self.d.getVar('RPM_SIGN_PACKAGES') == '1':
|
||||
signer = get_signer(self.d, self.d.getVar('RPM_GPG_BACKEND'))
|
||||
@@ -164,13 +171,13 @@ class RpmPM(PackageManager):
|
||||
repo_uri = uri + "/" + arch
|
||||
repo_id = "oe-remote-repo" + "-".join(urlparse(repo_uri).path.split("/"))
|
||||
repo_name = "OE Remote Repo:" + " ".join(urlparse(repo_uri).path.split("/"))
|
||||
open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'a').write(
|
||||
"[%s]\nname=%s\nbaseurl=%s\n%s\n" % (repo_id, repo_name, repo_uri, gpg_opts))
|
||||
with open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'a') as f:
|
||||
f.write("[%s]\nname=%s\nbaseurl=%s\n%s\n" % (repo_id, repo_name, repo_uri, gpg_opts))
|
||||
else:
|
||||
repo_name = "OE Remote Repo:" + " ".join(urlparse(uri).path.split("/"))
|
||||
repo_uri = uri
|
||||
open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'w').write(
|
||||
"[%s]\nname=%s\nbaseurl=%s\n%s" % (repo_base, repo_name, repo_uri, gpg_opts))
|
||||
with open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'w') as f:
|
||||
f.write("[%s]\nname=%s\nbaseurl=%s\n%s" % (repo_base, repo_name, repo_uri, gpg_opts))
|
||||
|
||||
def _prepare_pkg_transaction(self):
|
||||
os.environ['D'] = self.target_rootfs
|
||||
@@ -329,7 +336,8 @@ class RpmPM(PackageManager):
|
||||
return e.output.decode("utf-8")
|
||||
|
||||
def dump_install_solution(self, pkgs):
|
||||
open(self.solution_manifest, 'w').write(" ".join(pkgs))
|
||||
with open(self.solution_manifest, 'w') as f:
|
||||
f.write(" ".join(pkgs))
|
||||
return pkgs
|
||||
|
||||
def load_old_install_solution(self):
|
||||
@@ -363,7 +371,8 @@ class RpmPM(PackageManager):
|
||||
bb.utils.mkdirhier(target_path)
|
||||
num = self._script_num_prefix(target_path)
|
||||
saved_script_name = oe.path.join(target_path, "%d-%s" % (num, pkg))
|
||||
open(saved_script_name, 'w').write(output)
|
||||
with open(saved_script_name, 'w') as f:
|
||||
f.write(output)
|
||||
os.chmod(saved_script_name, 0o755)
|
||||
|
||||
def _handle_intercept_failure(self, registered_pkgs):
|
||||
|
||||
Reference in New Issue
Block a user