summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMingli Yu <mingli.yu@windriver.com>2021-11-17 10:16:23 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-01-22 17:56:53 +0000
commite1f86e7761573accbf722c4fe10e5cd1770d6638 (patch)
tree095df4eb212b2a36d20fe4dbc407c57d746300a4 /scripts
parent2be5df91820a0d712f1b4adb7dbae7d2e7451281 (diff)
downloadpoky-e1f86e7761573accbf722c4fe10e5cd1770d6638.tar.gz
wic: use shutil.which
Use shutil.which to find the executable instead to silence the below warning: $ cat tmp/work/intel_x86_64-poky-linux/core-image-base/1.0-r5/temp/log.do_image_wic [snip] DEBUG: Executing shell function do_image_wic /path/layers/oe-core/scripts/wic:27: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives from distutils import spawn INFO: Creating image(s)... [snip] [RP: Added conversion for missed function reference] (From OE-Core rev: 488815681466d5e4c7640df5281fa6e1f9b4c75e) Signed-off-by: Mingli Yu <mingli.yu@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 3966cbf5c8a2dbc3a4f0f3eefdbeeb83f522bf87) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/wic/engine.py6
-rw-r--r--scripts/lib/wic/misc.py4
-rwxr-xr-xscripts/wic4
3 files changed, 7 insertions, 7 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 9ff4394757..7dbde85696 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -19,10 +19,10 @@ import os
19import tempfile 19import tempfile
20import json 20import json
21import subprocess 21import subprocess
22import shutil
22import re 23import re
23 24
24from collections import namedtuple, OrderedDict 25from collections import namedtuple, OrderedDict
25from distutils.spawn import find_executable
26 26
27from wic import WicError 27from wic import WicError
28from wic.filemap import sparse_copy 28from wic.filemap import sparse_copy
@@ -245,7 +245,7 @@ class Disk:
245 for path in pathlist.split(':'): 245 for path in pathlist.split(':'):
246 self.paths = "%s%s:%s" % (native_sysroot, path, self.paths) 246 self.paths = "%s%s:%s" % (native_sysroot, path, self.paths)
247 247
248 self.parted = find_executable("parted", self.paths) 248 self.parted = shutil.which("parted", path=self.paths)
249 if not self.parted: 249 if not self.parted:
250 raise WicError("Can't find executable parted") 250 raise WicError("Can't find executable parted")
251 251
@@ -283,7 +283,7 @@ class Disk:
283 "resize2fs", "mkswap", "mkdosfs", "debugfs"): 283 "resize2fs", "mkswap", "mkdosfs", "debugfs"):
284 aname = "_%s" % name 284 aname = "_%s" % name
285 if aname not in self.__dict__: 285 if aname not in self.__dict__:
286 setattr(self, aname, find_executable(name, self.paths)) 286 setattr(self, aname, shutil.which(name, path=self.paths))
287 if aname not in self.__dict__ or self.__dict__[aname] is None: 287 if aname not in self.__dict__ or self.__dict__[aname] is None:
288 raise WicError("Can't find executable '{}'".format(name)) 288 raise WicError("Can't find executable '{}'".format(name))
289 return self.__dict__[aname] 289 return self.__dict__[aname]
diff --git a/scripts/lib/wic/misc.py b/scripts/lib/wic/misc.py
index 57c042c503..3e11822996 100644
--- a/scripts/lib/wic/misc.py
+++ b/scripts/lib/wic/misc.py
@@ -16,9 +16,9 @@ import logging
16import os 16import os
17import re 17import re
18import subprocess 18import subprocess
19import shutil
19 20
20from collections import defaultdict 21from collections import defaultdict
21from distutils import spawn
22 22
23from wic import WicError 23from wic import WicError
24 24
@@ -122,7 +122,7 @@ def find_executable(cmd, paths):
122 if provided and "%s-native" % recipe in provided: 122 if provided and "%s-native" % recipe in provided:
123 return True 123 return True
124 124
125 return spawn.find_executable(cmd, paths) 125 return shutil.which(cmd, path=paths)
126 126
127def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""): 127def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""):
128 """ 128 """
diff --git a/scripts/wic b/scripts/wic
index a741aed364..6547abe0e9 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -22,9 +22,9 @@ import sys
22import argparse 22import argparse
23import logging 23import logging
24import subprocess 24import subprocess
25import shutil
25 26
26from collections import namedtuple 27from collections import namedtuple
27from distutils import spawn
28 28
29# External modules 29# External modules
30scripts_path = os.path.dirname(os.path.realpath(__file__)) 30scripts_path = os.path.dirname(os.path.realpath(__file__))
@@ -47,7 +47,7 @@ if os.environ.get('SDKTARGETSYSROOT'):
47 break 47 break
48 sdkroot = os.path.dirname(sdkroot) 48 sdkroot = os.path.dirname(sdkroot)
49 49
50bitbake_exe = spawn.find_executable('bitbake') 50bitbake_exe = shutil.which('bitbake')
51if bitbake_exe: 51if bitbake_exe:
52 bitbake_path = scriptpath.add_bitbake_lib_path() 52 bitbake_path = scriptpath.add_bitbake_lib_path()
53 import bb 53 import bb