使用BitBake SRC_URI file://获取器去除解压源码树的基础路径
Let me break down what's going wrong here and how to fix it:
The Problem with Your Current Configuration
When you use file:///src/someproject in SRC_URI, Yocto creates a temporary tarball of the entire someproject directory (not just its contents). The paths inside this tarball look like someproject/file1, someproject/subdir/, etc.
Your original basepath=/src/someproject is trying to match an absolute filesystem path, but basepath works against the paths inside the source archive—not your local system's absolute paths. Since the archive doesn't have a /src/someproject prefix, the basepath rule does nothing, and Yocto extracts the full someproject directory into your source subdir, resulting in the nested structure you're seeing.
Solution 1: Correct the basepath Value
Use the directory name (not the full absolute path) as your basepath. This tells Yocto to strip that prefix from the archive paths:
SRC_URI="file:///src/someproject;subdir=source;basepath=someproject"
Now when Yocto extracts the archive, it will remove the someproject prefix and drop all files/subdirs directly into build/tmp/work/target/someproject/1.0-r1/source/.
Solution 2: Target Directory Contents Directly
Alternatively, you can skip basepath entirely by pointing SRC_URI to all contents inside your local directory using a wildcard:
SRC_URI="file:///src/someproject/*;subdir=source"
This tells Yocto to grab every file and subdirectory under /src/someproject and copy them directly into your source subdir, no extra nested directories included.
Either approach will give you the flat source structure you're expecting.
内容的提问来源于stack exchange,提问作者Alexander Amelkin

