diff options
| author | Robert Yang <liezhi.yang@windriver.com> | 2012-05-29 22:53:06 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-30 12:04:45 +0100 |
| commit | e40995e569289598a1d9d71e19734402f2b54718 (patch) | |
| tree | 108328e272a149da0e27dec0e0f0bebe602b80b8 /meta/classes/package.bbclass | |
| parent | e4c35790d6dc23a0933f188f52fa4434784e1d98 (diff) | |
| download | poky-e40995e569289598a1d9d71e19734402f2b54718.tar.gz | |
meta: replace os.system with subprocess.call
Replace os.system with subprocess.call since the older function would
fail (more or less) silently if the executed program cannot be found
More info:
http://docs.python.org/library/subprocess.html#subprocess-replacements
[YOCTO #2454]
(From OE-Core rev: a07d03cc6f67c88feb9813ae7deb6e4a93552dfe)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package.bbclass')
| -rw-r--r-- | meta/classes/package.bbclass | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 58320dd7ef..41139ef921 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
| @@ -183,7 +183,7 @@ def splitfile(file, debugfile, debugsrcdir, d): | |||
| 183 | # The debug information is then processed for src references. These | 183 | # The debug information is then processed for src references. These |
| 184 | # references are copied to debugsrcdir, if defined. | 184 | # references are copied to debugsrcdir, if defined. |
| 185 | 185 | ||
| 186 | import commands, stat | 186 | import commands, stat, subprocess |
| 187 | 187 | ||
| 188 | dvar = d.getVar('PKGD', True) | 188 | dvar = d.getVar('PKGD', True) |
| 189 | pathprefix = "export PATH=%s; " % d.getVar('PATH', True) | 189 | pathprefix = "export PATH=%s; " % d.getVar('PATH', True) |
| @@ -205,14 +205,14 @@ def splitfile(file, debugfile, debugsrcdir, d): | |||
| 205 | 205 | ||
| 206 | # We need to extract the debug src information here... | 206 | # We need to extract the debug src information here... |
| 207 | if debugsrcdir: | 207 | if debugsrcdir: |
| 208 | os.system("%s'%s' -b '%s' -d '%s' -i -l '%s' '%s'" % (pathprefix, debugedit, workparentdir, debugsrcdir, sourcefile, file)) | 208 | subprocess.call("%s'%s' -b '%s' -d '%s' -i -l '%s' '%s'" % (pathprefix, debugedit, workparentdir, debugsrcdir, sourcefile, file), shell=True) |
| 209 | 209 | ||
| 210 | bb.mkdirhier(os.path.dirname(debugfile)) | 210 | bb.mkdirhier(os.path.dirname(debugfile)) |
| 211 | 211 | ||
| 212 | os.system("%s'%s' --only-keep-debug '%s' '%s'" % (pathprefix, objcopy, file, debugfile)) | 212 | subprocess.call("%s'%s' --only-keep-debug '%s' '%s'" % (pathprefix, objcopy, file, debugfile), shell=True) |
| 213 | 213 | ||
| 214 | # Set the debuglink to have the view of the file path on the target | 214 | # Set the debuglink to have the view of the file path on the target |
| 215 | os.system("%s'%s' --add-gnu-debuglink='%s' '%s'" % (pathprefix, objcopy, debugfile, file)) | 215 | subprocess.call("%s'%s' --add-gnu-debuglink='%s' '%s'" % (pathprefix, objcopy, debugfile, file), shell=True) |
| 216 | 216 | ||
| 217 | if newmode: | 217 | if newmode: |
| 218 | os.chmod(file, origmode) | 218 | os.chmod(file, origmode) |
| @@ -225,7 +225,7 @@ def splitfile2(debugsrcdir, d): | |||
| 225 | # The debug src information processed in the splitfile2 is further procecessed | 225 | # The debug src information processed in the splitfile2 is further procecessed |
| 226 | # and copied to the destination here. | 226 | # and copied to the destination here. |
| 227 | 227 | ||
| 228 | import commands, stat | 228 | import commands, stat, subprocess |
| 229 | 229 | ||
| 230 | sourcefile = d.expand("${WORKDIR}/debugsources.list") | 230 | sourcefile = d.expand("${WORKDIR}/debugsources.list") |
| 231 | if debugsrcdir and os.path.isfile(sourcefile): | 231 | if debugsrcdir and os.path.isfile(sourcefile): |
| @@ -252,14 +252,14 @@ def splitfile2(debugsrcdir, d): | |||
| 252 | processdebugsrc += "fgrep -z '%s' | " | 252 | processdebugsrc += "fgrep -z '%s' | " |
| 253 | processdebugsrc += "(cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s' 2>/dev/null)" | 253 | processdebugsrc += "(cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s' 2>/dev/null)" |
| 254 | 254 | ||
| 255 | os.system(processdebugsrc % (sourcefile, workbasedir, workparentdir, dvar, debugsrcdir)) | 255 | subprocess.call(processdebugsrc % (sourcefile, workbasedir, workparentdir, dvar, debugsrcdir), shell=True) |
| 256 | 256 | ||
| 257 | # The copy by cpio may have resulted in some empty directories! Remove these | 257 | # The copy by cpio may have resulted in some empty directories! Remove these |
| 258 | for root, dirs, files in os.walk("%s%s" % (dvar, debugsrcdir)): | 258 | for root, dirs, files in os.walk("%s%s" % (dvar, debugsrcdir)): |
| 259 | for d in dirs: | 259 | for d in dirs: |
| 260 | dir = os.path.join(root, d) | 260 | dir = os.path.join(root, d) |
| 261 | #bb.note("rmdir -p %s" % dir) | 261 | #bb.note("rmdir -p %s" % dir) |
| 262 | os.system("rmdir -p %s 2>/dev/null" % dir) | 262 | subprocess.call("rmdir -p %s 2>/dev/null" % dir, shell=True) |
| 263 | 263 | ||
| 264 | # Also remove debugsrcdir if its empty | 264 | # Also remove debugsrcdir if its empty |
| 265 | for p in nosuchdir[::-1]: | 265 | for p in nosuchdir[::-1]: |
| @@ -275,14 +275,14 @@ def runstrip(file, elftype, d): | |||
| 275 | # 4 - executable | 275 | # 4 - executable |
| 276 | # 8 - shared library | 276 | # 8 - shared library |
| 277 | 277 | ||
| 278 | import commands, stat | 278 | import commands, stat, subprocess |
| 279 | 279 | ||
| 280 | pathprefix = "export PATH=%s; " % d.getVar('PATH', True) | 280 | pathprefix = "export PATH=%s; " % d.getVar('PATH', True) |
| 281 | strip = d.getVar("STRIP", True) | 281 | strip = d.getVar("STRIP", True) |
| 282 | 282 | ||
| 283 | # Handle kernel modules specifically - .debug directories here are pointless | 283 | # Handle kernel modules specifically - .debug directories here are pointless |
| 284 | if file.find("/lib/modules/") != -1 and file.endswith(".ko"): | 284 | if file.find("/lib/modules/") != -1 and file.endswith(".ko"): |
| 285 | return os.system("%s'%s' --strip-debug --remove-section=.comment --remove-section=.note --preserve-dates '%s'" % (pathprefix, strip, file)) | 285 | return subprocess.call("%s'%s' --strip-debug --remove-section=.comment --remove-section=.note --preserve-dates '%s'" % (pathprefix, strip, file), shell=True) |
| 286 | 286 | ||
| 287 | newmode = None | 287 | newmode = None |
| 288 | if not os.access(file, os.W_OK) or os.access(file, os.R_OK): | 288 | if not os.access(file, os.W_OK) or os.access(file, os.R_OK): |
| @@ -301,7 +301,7 @@ def runstrip(file, elftype, d): | |||
| 301 | stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) | 301 | stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) |
| 302 | bb.debug(1, "runstrip: %s" % stripcmd) | 302 | bb.debug(1, "runstrip: %s" % stripcmd) |
| 303 | 303 | ||
| 304 | ret = os.system("%s%s" % (pathprefix, stripcmd)) | 304 | ret = subprocess.call("%s%s" % (pathprefix, stripcmd), shell=True) |
| 305 | 305 | ||
| 306 | if newmode: | 306 | if newmode: |
| 307 | os.chmod(file, origmode) | 307 | os.chmod(file, origmode) |
| @@ -427,6 +427,7 @@ python package_do_split_locales() { | |||
| 427 | } | 427 | } |
| 428 | 428 | ||
| 429 | python perform_packagecopy () { | 429 | python perform_packagecopy () { |
| 430 | import subprocess | ||
| 430 | dest = d.getVar('D', True) | 431 | dest = d.getVar('D', True) |
| 431 | dvar = d.getVar('PKGD', True) | 432 | dvar = d.getVar('PKGD', True) |
| 432 | 433 | ||
| @@ -434,9 +435,9 @@ python perform_packagecopy () { | |||
| 434 | 435 | ||
| 435 | # Start by package population by taking a copy of the installed | 436 | # Start by package population by taking a copy of the installed |
| 436 | # files to operate on | 437 | # files to operate on |
| 437 | os.system('rm -rf %s/*' % (dvar)) | 438 | subprocess.call('rm -rf %s/*' % (dvar), shell=True) |
| 438 | # Preserve sparse files and hard links | 439 | # Preserve sparse files and hard links |
| 439 | os.system('tar -cf - -C %s -ps . | tar -xf - -C %s' % (dest, dvar)) | 440 | subprocess.call('tar -cf - -C %s -ps . | tar -xf - -C %s' % (dest, dvar), shell=True) |
| 440 | } | 441 | } |
| 441 | 442 | ||
| 442 | # We generate a master list of directories to process, we start by | 443 | # We generate a master list of directories to process, we start by |
| @@ -668,7 +669,7 @@ python fixup_perms () { | |||
| 668 | } | 669 | } |
| 669 | 670 | ||
| 670 | python split_and_strip_files () { | 671 | python split_and_strip_files () { |
| 671 | import commands, stat, errno | 672 | import commands, stat, errno, subprocess |
| 672 | 673 | ||
| 673 | dvar = d.getVar('PKGD', True) | 674 | dvar = d.getVar('PKGD', True) |
| 674 | pn = d.getVar('PN', True) | 675 | pn = d.getVar('PN', True) |
| @@ -838,7 +839,7 @@ python split_and_strip_files () { | |||
| 838 | os.unlink(fpath) | 839 | os.unlink(fpath) |
| 839 | # This could leave an empty debug directory laying around | 840 | # This could leave an empty debug directory laying around |
| 840 | # take care of the obvious case... | 841 | # take care of the obvious case... |
| 841 | os.system("rmdir %s 2>/dev/null" % os.path.dirname(fpath)) | 842 | subprocess.call("rmdir %s 2>/dev/null" % os.path.dirname(fpath), shell=True) |
| 842 | 843 | ||
| 843 | # Process the debugsrcdir if requested... | 844 | # Process the debugsrcdir if requested... |
| 844 | # This copies and places the referenced sources for later debugging... | 845 | # This copies and places the referenced sources for later debugging... |
| @@ -870,7 +871,7 @@ python split_and_strip_files () { | |||
| 870 | } | 871 | } |
| 871 | 872 | ||
| 872 | python populate_packages () { | 873 | python populate_packages () { |
| 873 | import glob, stat, errno, re | 874 | import glob, stat, errno, re, subprocess |
| 874 | 875 | ||
| 875 | workdir = d.getVar('WORKDIR', True) | 876 | workdir = d.getVar('WORKDIR', True) |
| 876 | outdir = d.getVar('DEPLOY_DIR', True) | 877 | outdir = d.getVar('DEPLOY_DIR', True) |
| @@ -896,7 +897,7 @@ python populate_packages () { | |||
| 896 | package_list.append(pkg) | 897 | package_list.append(pkg) |
| 897 | d.setVar('PACKAGES', ' '.join(package_list)) | 898 | d.setVar('PACKAGES', ' '.join(package_list)) |
| 898 | pkgdest = d.getVar('PKGDEST', True) | 899 | pkgdest = d.getVar('PKGDEST', True) |
| 899 | os.system('rm -rf %s' % pkgdest) | 900 | subprocess.call('rm -rf %s' % pkgdest, shell=True) |
| 900 | 901 | ||
| 901 | seen = [] | 902 | seen = [] |
| 902 | 903 | ||
