diff options
author | 2010-08-19 19:02:43 +0100 | |
---|---|---|
committer | 2010-08-19 19:03:14 +0100 | |
commit | 2fc6bfb4f4647a3c513b199c2ee44026665e4f37 (patch) | |
tree | e195135d3fb401afd79abd71b5b23f1061e12596 | |
parent | 351364671047b4989ea4bbb6327876818bad2681 (diff) | |
download | paludis-2fc6bfb4f4647a3c513b199c2ee44026665e4f37.tar.gz paludis-2fc6bfb4f4647a3c513b199c2ee44026665e4f37.tar.xz |
Update ld.so.conf parsing, in particular support "include"
-rw-r--r-- | paludis/broken_linkage_configuration.cc | 81 | ||||
-rw-r--r-- | paludis/broken_linkage_configuration_TEST.cc | 4 | ||||
-rwxr-xr-x | paludis/broken_linkage_configuration_TEST_setup.sh | 20 |
3 files changed, 87 insertions, 18 deletions
diff --git a/paludis/broken_linkage_configuration.cc b/paludis/broken_linkage_configuration.cc index 1de7582fe..0796b9482 100644 --- a/paludis/broken_linkage_configuration.cc +++ b/paludis/broken_linkage_configuration.cc @@ -34,6 +34,7 @@ #include <functional> #include <iterator> #include <vector> +#include <cctype> using namespace paludis; @@ -133,6 +134,59 @@ namespace ll_debug, lc_context) << "Final " << varname << "=\"" << join(vec.begin(), vec.end(), " ") << "\""; } + + bool + char_equals_ci(char a, char b) + { + return std::tolower(a) == std::tolower(b); + } + + bool + equals_ci(const std::string & a, const std::string & b) + { + return a.length() == b.length() && std::equal(a.begin(), a.end(), b.begin(), char_equals_ci); + } + + void + parse_ld_so_conf(const FSEntry & root, const FSEntry & file, const LineConfigFileOptions & opts, std::vector<std::string> & res) + { + if (file.is_regular_file_or_symlink_to_regular_file()) + { + LineConfigFile lines(file, opts); + for (auto it(lines.begin()), it_end(lines.end()); it_end != it; ++it) + { + std::vector<std::string> tokens; + tokenise_whitespace(*it, std::back_inserter(tokens)); + + if ("include" == tokens.at(0)) + { + for (auto it2(next(tokens.begin())), it2_end(tokens.end()); it2_end != it2; ++it2) + { + FSEntry rel('/' == it2->at(0) ? root : file.dirname()); + for (WildcardExpander it3(*it2, rel), it3_end; it3_end != it3; ++it3) + { + Context ctx("When reading included file '" + stringify(rel / *it3) + "':"); + parse_ld_so_conf(root, rel / *it3, opts, res); + } + } + } + + else if (equals_ci("hwdep", tokens.at(0))) // XXX + Log::get_instance()->message("reconcilio.broken_linkage_finder.etc_ld_so_conf.hwdep", ll_warning, lc_context) + << "'hwdep' line in '" << file << "' is not supported"; + else if (std::string::npos != it->find('=')) + Log::get_instance()->message("reconcilio.broken_linkage_finder.etc_ld_so_conf.equals", ll_warning, lc_context) + << "'=' line in '" << file << "' is not supported"; + + else + res.push_back(*it); + } + } + + else if (file.exists()) + Log::get_instance()->message("reconcilio.broken_linkage_finder.etc_ld_so_conf.not_a_file", ll_warning, lc_context) + << "'" << file << "' exists but is not a regular file"; + } } BrokenLinkageConfiguration::BrokenLinkageConfiguration(const FSEntry & root) : @@ -261,23 +315,20 @@ Imp<BrokenLinkageConfiguration>::load_from_etc_ld_so_conf(const FSEntry & root) FSEntry etc_ld_so_conf(root / "etc" / "ld.so.conf"); Context ctx("When reading '" + stringify(etc_ld_so_conf) + "':"); - if (etc_ld_so_conf.is_regular_file_or_symlink_to_regular_file()) - { - LineConfigFileOptions opts; - opts += lcfo_disallow_continuations; + LineConfigFileOptions opts; + opts += lcfo_disallow_continuations; + opts += lcfo_allow_inline_comments; - LineConfigFile lines(etc_ld_so_conf, opts); - if (lines.begin() != lines.end()) - { - Log::get_instance()->message("reconcilio.broken_linkage_finder.got", ll_debug, lc_context) - << "Got " << join(lines.begin(), lines.end(), " "); - std::copy(lines.begin(), lines.end(), std::back_inserter(search_dirs)); - std::copy(lines.begin(), lines.end(), std::back_inserter(ld_so_conf)); - } + std::vector<std::string> res; + parse_ld_so_conf(root, etc_ld_so_conf, opts, res); + + if (res.begin() != res.end()) + { + Log::get_instance()->message("reconcilio.broken_linkage_finder.got", ll_debug, lc_context) + << "Got " << join(res.begin(), res.end(), " "); + std::copy(res.begin(), res.end(), std::back_inserter(search_dirs)); + std::copy(res.begin(), res.end(), std::back_inserter(ld_so_conf)); } - else if (etc_ld_so_conf.exists()) - Log::get_instance()->message("reconcilio.broken_linkage_finder.etc_ld_so_conf.not_a_file", ll_warning, lc_context) - << "'" << etc_ld_so_conf << "' exists but is not a regular file"; } void diff --git a/paludis/broken_linkage_configuration_TEST.cc b/paludis/broken_linkage_configuration_TEST.cc index 29373cb57..d05077252 100644 --- a/paludis/broken_linkage_configuration_TEST.cc +++ b/paludis/broken_linkage_configuration_TEST.cc @@ -46,9 +46,9 @@ namespace test_cases BrokenLinkageConfiguration config(FSEntry::cwd() / "broken_linkage_configuration_TEST_dir"); TEST_CHECK_EQUAL(join(config.begin_search_dirs(), config.end_search_dirs(), " "), - "/alib /barbin /barlib/foo /bazbin /bin /blib /foobin /foolib/bar /lib32 /lib64 /quuxlib /sbin /usr/bin /usr/lib* /usr/sbin"); + "/42 /alib /barbin /barlib/foo /bazbin /bin /blib /fhqwhgads1 /fhqwhgads2 /foobin /foolib/bar /hwdp foobar /lib32 /lib64 /quuxlib /qwerty1 /qwerty2 /sbin /uiop1 /uiop2 /usr/bin /usr/lib* /usr/sbin"); TEST_CHECK_EQUAL(join(config.begin_ld_so_conf(), config.end_ld_so_conf(), " "), - "/barlib/foo /foolib/bar /lib /usr/lib"); + "/42 /barlib/foo /fhqwhgads1 /fhqwhgads2 /foolib/bar /lib /qwerty1 /qwerty2 /uiop1 /uiop2 /usr/lib hwdp foobar"); TEST_CHECK(config.dir_is_masked(FSEntry("/meh"))); TEST_CHECK(config.dir_is_masked(FSEntry("/quuxlib/quux"))); diff --git a/paludis/broken_linkage_configuration_TEST_setup.sh b/paludis/broken_linkage_configuration_TEST_setup.sh index 96559116c..55c0e46c7 100755 --- a/paludis/broken_linkage_configuration_TEST_setup.sh +++ b/paludis/broken_linkage_configuration_TEST_setup.sh @@ -4,7 +4,7 @@ mkdir broken_linkage_configuration_TEST_dir || exit 1 cd broken_linkage_configuration_TEST_dir || exit 1 -mkdir -p etc/revdep-rebuild +mkdir -p etc/revdep-rebuild etc/ld.so.conf.d ld.so.conf.d echo 'export PATH="/foobin:/barbin"' >>etc/profile.env echo 'export ROOTPATH="/bazbin"' >>etc/profile.env @@ -13,6 +13,24 @@ echo 'export WRATH="/goo"' >>etc/profile.env echo '/foolib/bar' >>etc/ld.so.conf echo '/barlib/foo' >>etc/ld.so.conf echo '#/shoe' >>etc/ld.so.conf +echo '/meh=hahaha' >>etc/ld.so.conf +echo 'include ld.so.conf.d/*' >>etc/ld.so.conf +echo 'include /ld.so.conf.d/*' >>etc/ld.so.conf +echo 'include ld.so.conf.2' >>etc/ld.so.conf + +echo '/qwerty1' >>etc/ld.so.conf.d/qwerty +echo '/qwerty2' >>etc/ld.so.conf.d/qwerty +echo '/uiop1' >>etc/ld.so.conf.d/uiop +echo '/uiop2' >>etc/ld.so.conf.d/uiop + +echo '/fhqwhgads1' >>ld.so.conf.d/fhqwhgads +echo 'hwdep lalala' >>ld.so.conf.d/fhqwhgads +echo 'HWDEP lalalala' >>ld.so.conf.d/fhqwhgads +echo 'HwDep lalalalala' >>ld.so.conf.d/fhqwhgads +echo 'hwdp foobar' >>ld.so.conf.d/fhqwhgads +echo '/fhqwhgads2' >>ld.so.conf.d/fhqwhgads + +echo '/42' >>etc/ld.so.conf.2 echo 'SEARCH_DIRS="/alib /blib"' >>etc/revdep-rebuild/10-test echo 'SEARCH_DIRS_MASK="/meh -*"' >>etc/revdep-rebuild/10-test |