summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-09 17:05:58 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-09 22:28:04 +0100
commit566628d8cd674a964d5824391cfd1585a1a22a87 (patch)
tree670366ee1492ff8bb18b9261dfab9d06c06b0a2d
parentd2ef952851d9ef16875fdbbbc6ae6eb6cfc10cc0 (diff)
downloadpoky-566628d8cd674a964d5824391cfd1585a1a22a87.tar.gz
class/lib: Fix up various file access methods
There are various bits of cruft that have built up around our file accesses. This patch cleans some of them up, specifically: * Remove pointless "from __builtin__ import file" * Use open(), not file() * Wrap file usage in a with container to ensure files are closed * Add missing .close() calls in some cases (From OE-Core rev: a43e0a8ecd0441131e929daf998c3cd454d9c8f3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/imagetest-qemu.bbclass1
-rw-r--r--meta/classes/insane.bbclass25
-rw-r--r--meta/classes/libc-package.bbclass6
-rw-r--r--meta/classes/metadata_scm.bbclass21
-rw-r--r--meta/classes/package.bbclass7
-rw-r--r--meta/classes/package_deb.bbclass6
-rw-r--r--meta/classes/package_ipk.bbclass6
-rw-r--r--meta/classes/package_rpm.bbclass9
-rw-r--r--meta/classes/sanity.bbclass63
-rw-r--r--meta/lib/oe/packagedata.py2
-rw-r--r--meta/lib/oe/utils.py6
-rw-r--r--meta/recipes-core/busybox/busybox.inc1
12 files changed, 79 insertions, 74 deletions
diff --git a/meta/classes/imagetest-qemu.bbclass b/meta/classes/imagetest-qemu.bbclass
index 63ba08718e..c30d1cbc85 100644
--- a/meta/classes/imagetest-qemu.bbclass
+++ b/meta/classes/imagetest-qemu.bbclass
@@ -146,6 +146,7 @@ def qemuimagetest_main(d):
146 if not os.path.isfile(fulltestcase): 146 if not os.path.isfile(fulltestcase):
147 raise bb.build.FuncFailed("Testcase %s not found" % fulltestcase) 147 raise bb.build.FuncFailed("Testcase %s not found" % fulltestcase)
148 list.append((item, casefile, fulltestcase)) 148 list.append((item, casefile, fulltestcase))
149 f.close()
149 final_list = check_list(list) 150 final_list = check_list(list)
150 return final_list 151 return final_list
151 152
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 809aa457a1..4d2392e908 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -518,9 +518,10 @@ def package_qa_check_buildpaths(path, name, d, elf, messages):
518 return 518 return
519 519
520 tmpdir = d.getVar('TMPDIR', True) 520 tmpdir = d.getVar('TMPDIR', True)
521 file_content = open(path).read() 521 with open(path) as f:
522 if tmpdir in file_content: 522 file_content = f.read()
523 messages.append("File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d)) 523 if tmpdir in file_content:
524 messages.append("File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d))
524 525
525 526
526QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi" 527QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi"
@@ -634,15 +635,17 @@ def package_qa_check_staged(path,d):
634 for file in files: 635 for file in files:
635 path = os.path.join(root,file) 636 path = os.path.join(root,file)
636 if file.endswith(".la"): 637 if file.endswith(".la"):
637 file_content = open(path).read() 638 with open(path) as f:
638 if workdir in file_content: 639 file_content = f.read()
639 error_msg = "%s failed sanity test (workdir) in path %s" % (file,root) 640 if workdir in file_content:
640 sane = package_qa_handle_error("la", error_msg, d) 641 error_msg = "%s failed sanity test (workdir) in path %s" % (file,root)
642 sane = package_qa_handle_error("la", error_msg, d)
641 elif file.endswith(".pc"): 643 elif file.endswith(".pc"):
642 file_content = open(path).read() 644 with open(path) as f:
643 if pkgconfigcheck in file_content: 645 file_content = f.read()
644 error_msg = "%s failed sanity test (tmpdir) in path %s" % (file,root) 646 if pkgconfigcheck in file_content:
645 sane = package_qa_handle_error("pkgconfig", error_msg, d) 647 error_msg = "%s failed sanity test (tmpdir) in path %s" % (file,root)
648 sane = package_qa_handle_error("pkgconfig", error_msg, d)
646 649
647 return sane 650 return sane
648 651
diff --git a/meta/classes/libc-package.bbclass b/meta/classes/libc-package.bbclass
index 3a131540f3..74e2078544 100644
--- a/meta/classes/libc-package.bbclass
+++ b/meta/classes/libc-package.bbclass
@@ -146,7 +146,7 @@ python package_do_split_gconvs () {
146 146
147 def calc_gconv_deps(fn, pkg, file_regex, output_pattern, group): 147 def calc_gconv_deps(fn, pkg, file_regex, output_pattern, group):
148 deps = [] 148 deps = []
149 f = open(fn, "r") 149 f = open(fn, "rb")
150 c_re = re.compile('^copy "(.*)"') 150 c_re = re.compile('^copy "(.*)"')
151 i_re = re.compile('^include "(\w+)".*') 151 i_re = re.compile('^include "(\w+)".*')
152 for l in f.readlines(): 152 for l in f.readlines():
@@ -167,7 +167,7 @@ python package_do_split_gconvs () {
167 167
168 def calc_charmap_deps(fn, pkg, file_regex, output_pattern, group): 168 def calc_charmap_deps(fn, pkg, file_regex, output_pattern, group):
169 deps = [] 169 deps = []
170 f = open(fn, "r") 170 f = open(fn, "rb")
171 c_re = re.compile('^copy "(.*)"') 171 c_re = re.compile('^copy "(.*)"')
172 i_re = re.compile('^include "(\w+)".*') 172 i_re = re.compile('^include "(\w+)".*')
173 for l in f.readlines(): 173 for l in f.readlines():
@@ -187,7 +187,7 @@ python package_do_split_gconvs () {
187 187
188 def calc_locale_deps(fn, pkg, file_regex, output_pattern, group): 188 def calc_locale_deps(fn, pkg, file_regex, output_pattern, group):
189 deps = [] 189 deps = []
190 f = open(fn, "r") 190 f = open(fn, "rb")
191 c_re = re.compile('^copy "(.*)"') 191 c_re = re.compile('^copy "(.*)"')
192 i_re = re.compile('^include "(\w+)".*') 192 i_re = re.compile('^include "(\w+)".*')
193 for l in f.readlines(): 193 for l in f.readlines():
diff --git a/meta/classes/metadata_scm.bbclass b/meta/classes/metadata_scm.bbclass
index e9b207c24f..8d3988ace8 100644
--- a/meta/classes/metadata_scm.bbclass
+++ b/meta/classes/metadata_scm.bbclass
@@ -32,10 +32,11 @@ def base_get_scmbasepath(d):
32def base_get_metadata_monotone_branch(path, d): 32def base_get_metadata_monotone_branch(path, d):
33 monotone_branch = "<unknown>" 33 monotone_branch = "<unknown>"
34 try: 34 try:
35 monotone_branch = file( "%s/_MTN/options" % path ).read().strip() 35 with open("%s/_MTN/options" % path) as f:
36 if monotone_branch.startswith( "database" ): 36 monotone_branch = f.read().strip()
37 monotone_branch_words = monotone_branch.split() 37 if monotone_branch.startswith( "database" ):
38 monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1] 38 monotone_branch_words = monotone_branch.split()
39 monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
39 except: 40 except:
40 pass 41 pass
41 return monotone_branch 42 return monotone_branch
@@ -43,10 +44,11 @@ def base_get_metadata_monotone_branch(path, d):
43def base_get_metadata_monotone_revision(path, d): 44def base_get_metadata_monotone_revision(path, d):
44 monotone_revision = "<unknown>" 45 monotone_revision = "<unknown>"
45 try: 46 try:
46 monotone_revision = file( "%s/_MTN/revision" % path ).read().strip() 47 with open("%s/_MTN/revision" % path) as f:
47 if monotone_revision.startswith( "format_version" ): 48 monotone_revision = f.read().strip()
48 monotone_revision_words = monotone_revision.split() 49 if monotone_revision.startswith( "format_version" ):
49 monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1] 50 monotone_revision_words = monotone_revision.split()
51 monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1]
50 except IOError: 52 except IOError:
51 pass 53 pass
52 return monotone_revision 54 return monotone_revision
@@ -54,7 +56,8 @@ def base_get_metadata_monotone_revision(path, d):
54def base_get_metadata_svn_revision(path, d): 56def base_get_metadata_svn_revision(path, d):
55 revision = "<unknown>" 57 revision = "<unknown>"
56 try: 58 try:
57 revision = file( "%s/.svn/entries" % path ).readlines()[3].strip() 59 with open("%s/.svn/entries" % path) as f:
60 revision = f.readlines()[3].strip()
58 except IOError: 61 except IOError:
59 pass 62 pass
60 return revision 63 return revision
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 7d0684c95c..36b3ae5109 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1096,7 +1096,8 @@ python emit_pkgdata() {
1096 1096
1097 def get_directory_size(dir): 1097 def get_directory_size(dir):
1098 if os.listdir(dir): 1098 if os.listdir(dir):
1099 size = int(os.popen('du -sk %s' % dir).readlines()[0].split('\t')[0]) 1099 with os.popen('du -sk %s' % dir) as f:
1100 size = int(f.readlines()[0].split('\t')[0])
1100 else: 1101 else:
1101 size = 0 1102 size = 0
1102 return size 1103 return size
@@ -1203,7 +1204,7 @@ python emit_pkgdata() {
1203 g = glob('*') 1204 g = glob('*')
1204 if g or allow_empty == "1": 1205 if g or allow_empty == "1":
1205 packagedfile = pkgdatadir + '/runtime/%s.packaged' % pkg 1206 packagedfile = pkgdatadir + '/runtime/%s.packaged' % pkg
1206 file(packagedfile, 'w').close() 1207 open(packagedfile, 'w').close()
1207 1208
1208 if bb.data.inherits_class('kernel', d) or bb.data.inherits_class('module-base', d): 1209 if bb.data.inherits_class('kernel', d) or bb.data.inherits_class('module-base', d):
1209 write_extra_runtime_pkgs(variants, packages, pkgdatadir) 1210 write_extra_runtime_pkgs(variants, packages, pkgdatadir)
@@ -1633,7 +1634,7 @@ def read_libdep_files(d):
1633 for extension in ".shlibdeps", ".pcdeps", ".clilibdeps": 1634 for extension in ".shlibdeps", ".pcdeps", ".clilibdeps":
1634 depsfile = d.expand("${PKGDEST}/" + pkg + extension) 1635 depsfile = d.expand("${PKGDEST}/" + pkg + extension)
1635 if os.access(depsfile, os.R_OK): 1636 if os.access(depsfile, os.R_OK):
1636 fd = file(depsfile) 1637 fd = open(depsfile)
1637 lines = fd.readlines() 1638 lines = fd.readlines()
1638 fd.close() 1639 fd.close()
1639 for l in lines: 1640 for l in lines:
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 853b5ea8a3..313758f43f 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -227,7 +227,7 @@ python do_package_deb () {
227 bb.mkdirhier(controldir) 227 bb.mkdirhier(controldir)
228 os.chmod(controldir, 0755) 228 os.chmod(controldir, 0755)
229 try: 229 try:
230 ctrlfile = file(os.path.join(controldir, 'control'), 'wb') 230 ctrlfile = open(os.path.join(controldir, 'control'), 'w')
231 # import codecs 231 # import codecs
232 # ctrlfile = codecs.open("someFile", "w", "utf-8") 232 # ctrlfile = codecs.open("someFile", "w", "utf-8")
233 except OSError: 233 except OSError:
@@ -355,7 +355,7 @@ python do_package_deb () {
355 if not scriptvar: 355 if not scriptvar:
356 continue 356 continue
357 try: 357 try:
358 scriptfile = file(os.path.join(controldir, script), 'w') 358 scriptfile = open(os.path.join(controldir, script), 'w')
359 except OSError: 359 except OSError:
360 bb.utils.unlockfile(lf) 360 bb.utils.unlockfile(lf)
361 raise bb.build.FuncFailed("unable to open %s script file for writing." % script) 361 raise bb.build.FuncFailed("unable to open %s script file for writing." % script)
@@ -367,7 +367,7 @@ python do_package_deb () {
367 conffiles_str = localdata.getVar("CONFFILES", True) 367 conffiles_str = localdata.getVar("CONFFILES", True)
368 if conffiles_str: 368 if conffiles_str:
369 try: 369 try:
370 conffiles = file(os.path.join(controldir, 'conffiles'), 'w') 370 conffiles = open(os.path.join(controldir, 'conffiles'), 'w')
371 except OSError: 371 except OSError:
372 bb.utils.unlockfile(lf) 372 bb.utils.unlockfile(lf)
373 raise bb.build.FuncFailed("unable to open conffiles for writing.") 373 raise bb.build.FuncFailed("unable to open conffiles for writing.")
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index 5873f71205..f6797ada9d 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -268,7 +268,7 @@ python do_package_ipk () {
268 controldir = os.path.join(root, 'CONTROL') 268 controldir = os.path.join(root, 'CONTROL')
269 bb.mkdirhier(controldir) 269 bb.mkdirhier(controldir)
270 try: 270 try:
271 ctrlfile = file(os.path.join(controldir, 'control'), 'w') 271 ctrlfile = open(os.path.join(controldir, 'control'), 'w')
272 except OSError: 272 except OSError:
273 bb.utils.unlockfile(lf) 273 bb.utils.unlockfile(lf)
274 raise bb.build.FuncFailed("unable to open control file for writing.") 274 raise bb.build.FuncFailed("unable to open control file for writing.")
@@ -369,7 +369,7 @@ python do_package_ipk () {
369 if not scriptvar: 369 if not scriptvar:
370 continue 370 continue
371 try: 371 try:
372 scriptfile = file(os.path.join(controldir, script), 'w') 372 scriptfile = open(os.path.join(controldir, script), 'w')
373 except OSError: 373 except OSError:
374 bb.utils.unlockfile(lf) 374 bb.utils.unlockfile(lf)
375 raise bb.build.FuncFailed("unable to open %s script file for writing." % script) 375 raise bb.build.FuncFailed("unable to open %s script file for writing." % script)
@@ -380,7 +380,7 @@ python do_package_ipk () {
380 conffiles_str = localdata.getVar("CONFFILES", True) 380 conffiles_str = localdata.getVar("CONFFILES", True)
381 if conffiles_str: 381 if conffiles_str:
382 try: 382 try:
383 conffiles = file(os.path.join(controldir, 'conffiles'), 'w') 383 conffiles = open(os.path.join(controldir, 'conffiles'), 'w')
384 except OSError: 384 except OSError:
385 bb.utils.unlockfile(lf) 385 bb.utils.unlockfile(lf)
386 raise bb.build.FuncFailed("unable to open conffiles for writing.") 386 raise bb.build.FuncFailed("unable to open conffiles for writing.")
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 3a2997637b..25b14dd79d 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -504,8 +504,7 @@ def write_rpm_perfiledata(srcname, d):
504 outdepends = workdir + "/" + srcname + ".requires" 504 outdepends = workdir + "/" + srcname + ".requires"
505 505
506 try: 506 try:
507 from __builtin__ import file 507 dependsfile = open(outdepends, 'w')
508 dependsfile = file(outdepends, 'w')
509 except OSError: 508 except OSError:
510 raise bb.build.FuncFailed("unable to open spec file for writing.") 509 raise bb.build.FuncFailed("unable to open spec file for writing.")
511 510
@@ -518,8 +517,7 @@ def write_rpm_perfiledata(srcname, d):
518 outprovides = workdir + "/" + srcname + ".provides" 517 outprovides = workdir + "/" + srcname + ".provides"
519 518
520 try: 519 try:
521 from __builtin__ import file 520 providesfile = open(outprovides, 'w')
522 providesfile = file(outprovides, 'w')
523 except OSError: 521 except OSError:
524 raise bb.build.FuncFailed("unable to open spec file for writing.") 522 raise bb.build.FuncFailed("unable to open spec file for writing.")
525 523
@@ -1005,8 +1003,7 @@ python write_specfile () {
1005 1003
1006 # Write the SPEC file 1004 # Write the SPEC file
1007 try: 1005 try:
1008 from __builtin__ import file 1006 specfile = open(outspecfile, 'w')
1009 specfile = file(outspecfile, 'w')
1010 except OSError: 1007 except OSError:
1011 raise bb.build.FuncFailed("unable to open spec file for writing.") 1008 raise bb.build.FuncFailed("unable to open spec file for writing.")
1012 1009
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 1fb4a6c629..62fe7e4ef7 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -561,14 +561,14 @@ def check_sanity(sanity_data):
561 last_sstate_dir = "" 561 last_sstate_dir = ""
562 sanityverfile = 'conf/sanity_info' 562 sanityverfile = 'conf/sanity_info'
563 if os.path.exists(sanityverfile): 563 if os.path.exists(sanityverfile):
564 f = open(sanityverfile, 'r') 564 with open(sanityverfile, 'r') as f:
565 for line in f: 565 for line in f:
566 if line.startswith('SANITY_VERSION'): 566 if line.startswith('SANITY_VERSION'):
567 last_sanity_version = int(line.split()[1]) 567 last_sanity_version = int(line.split()[1])
568 if line.startswith('TMPDIR'): 568 if line.startswith('TMPDIR'):
569 last_tmpdir = line.split()[1] 569 last_tmpdir = line.split()[1]
570 if line.startswith('SSTATE_DIR'): 570 if line.startswith('SSTATE_DIR'):
571 last_sstate_dir = line.split()[1] 571 last_sstate_dir = line.split()[1]
572 572
573 sanity_version = int(sanity_data.getVar('SANITY_VERSION', True) or 1) 573 sanity_version = int(sanity_data.getVar('SANITY_VERSION', True) or 1)
574 network_error = False 574 network_error = False
@@ -584,25 +584,24 @@ def check_sanity(sanity_data):
584 if last_sstate_dir != sstate_dir: 584 if last_sstate_dir != sstate_dir:
585 messages = messages + check_sanity_sstate_dir_change(sstate_dir, sanity_data) 585 messages = messages + check_sanity_sstate_dir_change(sstate_dir, sanity_data)
586 if os.path.exists("conf") and not messages: 586 if os.path.exists("conf") and not messages:
587 f = open(sanityverfile, 'w') 587 with open(sanityverfile, 'w') as f:
588 f.write("SANITY_VERSION %s\n" % sanity_version) 588 f.write("SANITY_VERSION %s\n" % sanity_version)
589 f.write("TMPDIR %s\n" % tmpdir) 589 f.write("TMPDIR %s\n" % tmpdir)
590 f.write("SSTATE_DIR %s\n" % sstate_dir) 590 f.write("SSTATE_DIR %s\n" % sstate_dir)
591 591
592 # 592 #
593 # Check that TMPDIR hasn't changed location since the last time we were run 593 # Check that TMPDIR hasn't changed location since the last time we were run
594 # 594 #
595 checkfile = os.path.join(tmpdir, "saved_tmpdir") 595 checkfile = os.path.join(tmpdir, "saved_tmpdir")
596 if os.path.exists(checkfile): 596 if os.path.exists(checkfile):
597 f = open(checkfile, "r") 597 with open(checkfile, "r") as f:
598 saved_tmpdir = f.read().strip() 598 saved_tmpdir = f.read().strip()
599 if (saved_tmpdir != tmpdir): 599 if (saved_tmpdir != tmpdir):
600 messages = messages + "Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % saved_tmpdir 600 messages = messages + "Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % saved_tmpdir
601 else: 601 else:
602 bb.utils.mkdirhier(tmpdir) 602 bb.utils.mkdirhier(tmpdir)
603 f = open(checkfile, "w") 603 with open(checkfile, "w") as f:
604 f.write(tmpdir) 604 f.write(tmpdir)
605 f.close()
606 605
607 # 606 #
608 # Check the 'ABI' of TMPDIR 607 # Check the 'ABI' of TMPDIR
@@ -610,33 +609,32 @@ def check_sanity(sanity_data):
610 current_abi = sanity_data.getVar('OELAYOUT_ABI', True) 609 current_abi = sanity_data.getVar('OELAYOUT_ABI', True)
611 abifile = sanity_data.getVar('SANITY_ABIFILE', True) 610 abifile = sanity_data.getVar('SANITY_ABIFILE', True)
612 if os.path.exists(abifile): 611 if os.path.exists(abifile):
613 f = open(abifile, "r") 612 with open(abifile, "r") as f:
614 abi = f.read().strip() 613 abi = f.read().strip()
615 if not abi.isdigit(): 614 if not abi.isdigit():
616 f = open(abifile, "w") 615 with open(abifile, "w") as f:
617 f.write(current_abi) 616 f.write(current_abi)
618 elif abi == "2" and current_abi == "3": 617 elif abi == "2" and current_abi == "3":
619 bb.note("Converting staging from layout version 2 to layout version 3") 618 bb.note("Converting staging from layout version 2 to layout version 3")
620 subprocess.call(sanity_data.expand("mv ${TMPDIR}/staging ${TMPDIR}/sysroots"), shell=True) 619 subprocess.call(sanity_data.expand("mv ${TMPDIR}/staging ${TMPDIR}/sysroots"), shell=True)
621 subprocess.call(sanity_data.expand("ln -s sysroots ${TMPDIR}/staging"), shell=True) 620 subprocess.call(sanity_data.expand("ln -s sysroots ${TMPDIR}/staging"), shell=True)
622 subprocess.call(sanity_data.expand("cd ${TMPDIR}/stamps; for i in */*do_populate_staging; do new=`echo $i | sed -e 's/do_populate_staging/do_populate_sysroot/'`; mv $i $new; done"), shell=True) 621 subprocess.call(sanity_data.expand("cd ${TMPDIR}/stamps; for i in */*do_populate_staging; do new=`echo $i | sed -e 's/do_populate_staging/do_populate_sysroot/'`; mv $i $new; done"), shell=True)
623 f = open(abifile, "w") 622 with open(abifile, "w") as f:
624 f.write(current_abi) 623 f.write(current_abi)
625 elif abi == "3" and current_abi == "4": 624 elif abi == "3" and current_abi == "4":
626 bb.note("Converting staging layout from version 3 to layout version 4") 625 bb.note("Converting staging layout from version 3 to layout version 4")
627 if os.path.exists(sanity_data.expand("${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS}")): 626 if os.path.exists(sanity_data.expand("${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS}")):
628 subprocess.call(sanity_data.expand("mv ${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS} ${STAGING_BINDIR_CROSS}"), shell=True) 627 subprocess.call(sanity_data.expand("mv ${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS} ${STAGING_BINDIR_CROSS}"), shell=True)
629 subprocess.call(sanity_data.expand("ln -s ${STAGING_BINDIR_CROSS} ${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS}"), shell=True) 628 subprocess.call(sanity_data.expand("ln -s ${STAGING_BINDIR_CROSS} ${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS}"), shell=True)
630 629 with open(abifile, "w") as f:
631 f = open(abifile, "w") 630 f.write(current_abi)
632 f.write(current_abi)
633 elif abi == "4": 631 elif abi == "4":
634 messages = messages + "Staging layout has changed. The cross directory has been deprecated and cross packages are now built under the native sysroot.\nThis requires a rebuild.\n" 632 messages = messages + "Staging layout has changed. The cross directory has been deprecated and cross packages are now built under the native sysroot.\nThis requires a rebuild.\n"
635 elif abi == "5" and current_abi == "6": 633 elif abi == "5" and current_abi == "6":
636 bb.note("Converting staging layout from version 5 to layout version 6") 634 bb.note("Converting staging layout from version 5 to layout version 6")
637 subprocess.call(sanity_data.expand("mv ${TMPDIR}/pstagelogs ${SSTATE_MANIFESTS}"), shell=True) 635 subprocess.call(sanity_data.expand("mv ${TMPDIR}/pstagelogs ${SSTATE_MANIFESTS}"), shell=True)
638 f = open(abifile, "w") 636 with open(abifile, "w") as f:
639 f.write(current_abi) 637 f.write(current_abi)
640 elif abi == "7" and current_abi == "8": 638 elif abi == "7" and current_abi == "8":
641 messages = messages + "Your configuration is using stamp files including the sstate hash but your build directory was built with stamp files that do not include this.\nTo continue, either rebuild or switch back to the OEBasic signature handler with BB_SIGNATURE_HANDLER = 'OEBasic'.\n" 639 messages = messages + "Your configuration is using stamp files including the sstate hash but your build directory was built with stamp files that do not include this.\nTo continue, either rebuild or switch back to the OEBasic signature handler with BB_SIGNATURE_HANDLER = 'OEBasic'.\n"
642 elif (abi != current_abi and current_abi == "9"): 640 elif (abi != current_abi and current_abi == "9"):
@@ -645,9 +643,8 @@ def check_sanity(sanity_data):
645 # Code to convert from one ABI to another could go here if possible. 643 # Code to convert from one ABI to another could go here if possible.
646 messages = messages + "Error, TMPDIR has changed its layout version number (%s to %s) and you need to either rebuild, revert or adjust it at your own risk.\n" % (abi, current_abi) 644 messages = messages + "Error, TMPDIR has changed its layout version number (%s to %s) and you need to either rebuild, revert or adjust it at your own risk.\n" % (abi, current_abi)
647 else: 645 else:
648 f = open(abifile, "w") 646 with open(abifile, "w") as f:
649 f.write(current_abi) 647 f.write(current_abi)
650 f.close()
651 648
652 oeroot = sanity_data.getVar('COREBASE') 649 oeroot = sanity_data.getVar('COREBASE')
653 if oeroot.find ('+') != -1: 650 if oeroot.find ('+') != -1:
diff --git a/meta/lib/oe/packagedata.py b/meta/lib/oe/packagedata.py
index 62fd71898e..14c38bdc0f 100644
--- a/meta/lib/oe/packagedata.py
+++ b/meta/lib/oe/packagedata.py
@@ -12,7 +12,7 @@ def read_pkgdatafile(fn):
12 12
13 if os.access(fn, os.R_OK): 13 if os.access(fn, os.R_OK):
14 import re 14 import re
15 f = file(fn, 'r') 15 f = open(fn, 'r')
16 lines = f.readlines() 16 lines = f.readlines()
17 f.close() 17 f.close()
18 r = re.compile("([^:]+):\s*(.*)") 18 r = re.compile("([^:]+):\s*(.*)")
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index ec8260d9bd..0a2092b24b 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -7,11 +7,13 @@ except ImportError:
7 7
8def read_file(filename): 8def read_file(filename):
9 try: 9 try:
10 f = file( filename, "r" ) 10 f = open( filename, "r" )
11 except IOError as reason: 11 except IOError as reason:
12 return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M: 12 return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M:
13 else: 13 else:
14 return f.read().strip() 14 data = f.read().strip()
15 f.close()
16 return data
15 return None 17 return None
16 18
17def ifelse(condition, iftrue = True, iffalse = False): 19def ifelse(condition, iftrue = True, iffalse = False):
diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
index 59e0141e19..00c88abcba 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -262,6 +262,7 @@ python do_package_prepend () {
262 262
263 d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name) 263 d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name)
264 d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) 264 d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name)
265 f.close()
265} 266}
266 267
267pkg_postinst_${PN} () { 268pkg_postinst_${PN} () {