mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 09:49:33 +02:00
oe/packagemanager/rpm: don't leak file objects
(From OE-Core rev: 28706c27680745c9f8df27713ce63ef5d611138c) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
5f60768030
commit
79af23dc5e
@@ -98,11 +98,15 @@ class RpmPM(PackageManager):
|
|||||||
archs = ["sdk_provides_dummy_target"] + archs
|
archs = ["sdk_provides_dummy_target"] + archs
|
||||||
confdir = "%s/%s" %(self.target_rootfs, "etc/dnf/vars/")
|
confdir = "%s/%s" %(self.target_rootfs, "etc/dnf/vars/")
|
||||||
bb.utils.mkdirhier(confdir)
|
bb.utils.mkdirhier(confdir)
|
||||||
open(confdir + "arch", 'w').write(":".join(archs))
|
with open(confdir + "arch", 'w') as f:
|
||||||
distro_codename = self.d.getVar('DISTRO_CODENAME')
|
f.write(":".join(archs))
|
||||||
open(confdir + "releasever", 'w').write(distro_codename if distro_codename is not None else '')
|
|
||||||
|
|
||||||
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):
|
def _configure_rpm(self):
|
||||||
@@ -112,14 +116,17 @@ class RpmPM(PackageManager):
|
|||||||
platformconfdir = "%s/%s" %(self.target_rootfs, "etc/rpm/")
|
platformconfdir = "%s/%s" %(self.target_rootfs, "etc/rpm/")
|
||||||
rpmrcconfdir = "%s/%s" %(self.target_rootfs, "etc/")
|
rpmrcconfdir = "%s/%s" %(self.target_rootfs, "etc/")
|
||||||
bb.utils.mkdirhier(platformconfdir)
|
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:
|
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("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)
|
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'):
|
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':
|
if self.d.getVar('RPM_SIGN_PACKAGES') == '1':
|
||||||
signer = get_signer(self.d, self.d.getVar('RPM_GPG_BACKEND'))
|
signer = get_signer(self.d, self.d.getVar('RPM_GPG_BACKEND'))
|
||||||
@@ -166,13 +173,13 @@ class RpmPM(PackageManager):
|
|||||||
repo_uri = uri + "/" + arch
|
repo_uri = uri + "/" + arch
|
||||||
repo_id = "oe-remote-repo" + "-".join(urlparse(repo_uri).path.split("/"))
|
repo_id = "oe-remote-repo" + "-".join(urlparse(repo_uri).path.split("/"))
|
||||||
repo_name = "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(
|
with open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'a') as f:
|
||||||
"[%s]\nname=%s\nbaseurl=%s\n%s\n" % (repo_id, repo_name, repo_uri, gpg_opts))
|
f.write("[%s]\nname=%s\nbaseurl=%s\n%s\n" % (repo_id, repo_name, repo_uri, gpg_opts))
|
||||||
else:
|
else:
|
||||||
repo_name = "OE Remote Repo:" + " ".join(urlparse(uri).path.split("/"))
|
repo_name = "OE Remote Repo:" + " ".join(urlparse(uri).path.split("/"))
|
||||||
repo_uri = uri
|
repo_uri = uri
|
||||||
open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'w').write(
|
with open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_base + ".repo"), 'w') as f:
|
||||||
"[%s]\nname=%s\nbaseurl=%s\n%s" % (repo_base, repo_name, repo_uri, gpg_opts))
|
f.write("[%s]\nname=%s\nbaseurl=%s\n%s" % (repo_base, repo_name, repo_uri, gpg_opts))
|
||||||
|
|
||||||
def _prepare_pkg_transaction(self):
|
def _prepare_pkg_transaction(self):
|
||||||
os.environ['D'] = self.target_rootfs
|
os.environ['D'] = self.target_rootfs
|
||||||
@@ -331,7 +338,8 @@ class RpmPM(PackageManager):
|
|||||||
return e.output.decode("utf-8")
|
return e.output.decode("utf-8")
|
||||||
|
|
||||||
def dump_install_solution(self, pkgs):
|
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
|
return pkgs
|
||||||
|
|
||||||
def load_old_install_solution(self):
|
def load_old_install_solution(self):
|
||||||
@@ -365,7 +373,8 @@ class RpmPM(PackageManager):
|
|||||||
bb.utils.mkdirhier(target_path)
|
bb.utils.mkdirhier(target_path)
|
||||||
num = self._script_num_prefix(target_path)
|
num = self._script_num_prefix(target_path)
|
||||||
saved_script_name = oe.path.join(target_path, "%d-%s" % (num, pkg))
|
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)
|
os.chmod(saved_script_name, 0o755)
|
||||||
|
|
||||||
def _handle_intercept_failure(self, registered_pkgs):
|
def _handle_intercept_failure(self, registered_pkgs):
|
||||||
|
|||||||
Reference in New Issue
Block a user