Skip to content

Commit 9ba6d0c

Browse files
authored
pkg-config.py: fix IndexError when --variable=prefix is empty (#33288)
sometimes (e.g. with openssl-3.3.0) the pkg-config returns just new-line and prefix[-4] then fails with IndexError. Fixes: Command: python3 build/config/linux/pkg-config.py -s recipe-sysroot --system_libdir lib openssl Returned 1. stderr: Traceback (most recent call last): File "build/config/linux/pkg-config.py", line 259, in <module> sys.exit(main()) ^^^^^^ File "build/config/linux/pkg-config.py", line 156, in main prefix = GetPkgConfigPrefixToStrip(options, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "build/config/linux/pkg-config.py", line 102, in GetPkgConfigPrefixToStrip if prefix[-4] == '/usr': ~~~~~~^^^^ IndexError: string index out of range This part was originally introduced in pkg-config.py in chromium: https://chromium.googlesource.com/chromium/src/build/config/+/3df971b0a5e23e51c1c739fc1908caa1d95b8ac8%5E%21/#F1 The -4 typo was fixed in chromium with: https://chromium.googlesource.com/chromium/src/build/config/+/be2d385088cfb3a9f9f92c1dcb5c39b40fa28271%5E%21/#F0 And prefix isn't set in openssl pkg-config since: openssl/openssl@2ac569a Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
1 parent a8e4344 commit 9ba6d0c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

build/config/linux/pkg-config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def GetPkgConfigPrefixToStrip(options, args):
9999
# from pkg-config's |prefix| variable.
100100
prefix = subprocess.check_output([options.pkg_config,
101101
"--variable=prefix"] + args, env=os.environ).decode('utf-8')
102-
if prefix[-4] == '/usr':
102+
if prefix[:4] == '/usr':
103103
return prefix[4:]
104104
return prefix
105105

0 commit comments

Comments
 (0)