]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
namespace: fix namespace.pl script to support relative paths
authorJacob Keller <jacob.e.keller@intel.com>
Fri, 27 Sep 2019 23:30:27 +0000 (16:30 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 12 Nov 2019 18:04:42 +0000 (19:04 +0100)
commita2e5cbb5634057ae473d8fe5846fd23f0b4a8098
treef14323e1ebe58e6a509ef71a511509cbdefb6949
parent1699a02f5dd3bc38f5959bfe50e674d7bc4b619f
namespace: fix namespace.pl script to support relative paths

BugLink: https://bugs.launchpad.net/bugs/1851876
[ Upstream commit 82fdd12b95727640c9a8233c09d602e4518e71f7 ]

The namespace.pl script does not work properly if objtree is not set to
an absolute path. The do_nm function is run from within the find
function, which changes directories.

Because of this, appending objtree, $File::Find::dir, and $source, will
return a path which is not valid from the current directory.

This used to work when objtree was set to an absolute path when using
"make namespacecheck". It appears to have not worked when calling
./scripts/namespace.pl directly.

This behavior was changed in 7e1c04779efd ("kbuild: Use relative path
for $(objtree)", 2014-05-14)

Rather than fixing the Makefile to set objtree to an absolute path, just
fix namespace.pl to work when srctree and objtree are relative. Also fix
the script to use an absolute path for these by default.

Use the File::Spec module for this purpose. It's been part of perl
5 since 5.005.

The curdir() function is used to get the current directory when the
objtree and srctree aren't set in the environment.

rel2abs() is used to convert possibly relative objtree and srctree
environment variables to absolute paths.

Finally, the catfile() function is used instead of string appending
paths together, since this is more robust when joining paths together.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
scripts/namespace.pl