Correctly determine if a package has bundled dependencies
I have a package that's as follows:
# tree /usr/lib/node_modules/history
/usr/lib/node_modules/history
|-- DOMUtils.js
|-- LocationUtils.js
|-- PathUtils.js
|-- createBrowserHistory.js
|-- createHashHistory.js
|-- createMemoryHistory.js
|-- createTransitionManager.js
|-- es
| |-- DOMUtils.js
| |-- LocationUtils.js
| |-- PathUtils.js
| |-- createBrowserHistory.js
| |-- createHashHistory.js
| |-- createMemoryHistory.js
| |-- createTransitionManager.js
| `-- index.js
|-- index.js
|-- node_modules
| |-- invariant -> /usr/lib/node_modules/invariant
| |-- loose-envify -> /usr/lib/node_modules/loose-envify
| |-- resolve-pathname -> /usr/lib/node_modules/resolve-pathname
| |-- value-equal -> /usr/lib/node_modules/value-equal
| `-- warning -> /usr/lib/node_modules/warning
|-- package.json
`-- umd
|-- history.js
`-- history.min.js
The node_modules directory was created by the %nodejs_symlink_deps
macro. Then when using nodejs.req I don't get any dependencies:
# echo /usr/lib/node_modules/history/package.json | /usr/lib/rpm/nodejs.req
It looks like has_only_bundled_dependencies returns true, while it
shouldn't. Critically, it runs this code:
bundled_dependency_iter = (
os.path.realpath(path)
for path in dependency_path_iter
if not os.path.islink(path) or path.startswith(module_root_path)
)
Here dependency_path_iter is:
[
'/usr/lib/node_modules/history/node_modules/invariant',
'/usr/lib/node_modules/history/node_modules/loose-envify',
'/usr/lib/node_modules/history/node_modules/resolve-pathname',
'/usr/lib/node_modules/history/node_modules/value-equal',
'/usr/lib/node_modules/history/node_modules/warning'
]
And module_root_path is /usr/lib/node_modules/history.
We can conclude that path.startswith(module_root_path) will always be
true, because we started with iterating over files under
module_root_path. The code suggests it should have looked up the real
path instead. If we make that change, it correctly generates the
dependencies.
This commit is contained in:
parent
c15d4d3782
commit
af87d90a8d
@ -633,9 +633,9 @@ def has_only_bundled_dependencies(module_dir_path):
|
||||
for basename in os.listdir(dependency_root_path)
|
||||
)
|
||||
bundled_dependency_iter = (
|
||||
os.path.realpath(path)
|
||||
path
|
||||
for path in dependency_path_iter
|
||||
if not os.path.islink(path) or path.startswith(module_root_path)
|
||||
if not os.path.islink(path) or os.path.realpath(path).startswith(module_root_path)
|
||||
)
|
||||
|
||||
return any(bundled_dependency_iter)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user