Author: aschnell Date: Fri Dec 18 14:34:11 2009 New Revision: 60150 URL: http://svn.opensuse.org/viewcvs/yast?rev=60150&view=rev Log: - allow Y2DIR to be a list of paths separated by ":" Modified: trunk/core/VERSION trunk/core/libycp/src/include/ycp/pathsearch.h trunk/core/libycp/src/pathsearch.cc trunk/core/package/yast2-core.changes trunk/core/yast2-core.spec.in Modified: trunk/core/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/VERSION?rev=60150&r1=601... ============================================================================== --- trunk/core/VERSION (original) +++ trunk/core/VERSION Fri Dec 18 14:34:11 2009 @@ -1 +1 @@ -2.18.19 +2.19.0 Modified: trunk/core/libycp/src/include/ycp/pathsearch.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/paths... ============================================================================== --- trunk/core/libycp/src/include/ycp/pathsearch.h (original) +++ trunk/core/libycp/src/include/ycp/pathsearch.h Fri Dec 18 14:34:11 2009 @@ -29,8 +29,10 @@ #include <string> #include <list> +#include <vector> using std::string; +using std::vector; class Y2PathSearch @@ -100,9 +102,13 @@ protected: static bool searchPrefixWarn; + static vector<string> getPaths(); + private: static int defaultComponentLevel (); + static vector<string> paths; + static void initializePaths(); }; /** Modified: trunk/core/libycp/src/pathsearch.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/pathsearch.cc?rev... ============================================================================== --- trunk/core/libycp/src/pathsearch.cc (original) +++ trunk/core/libycp/src/pathsearch.cc Fri Dec 18 14:34:11 2009 @@ -28,105 +28,103 @@ #include <sys/stat.h> #include <sys/time.h> #include <unistd.h> +#include <boost/algorithm/string.hpp> #include <ycp/y2log.h> #include "pathsearch.h" -// watch out, duplicated in YCPPathSearch::initialize -static const char *paths[] = + +bool Y2PathSearch::searchPrefixWarn = true; + + +vector<string> +Y2PathSearch::getPaths() { - "/y2update", // Necessary during installation, but - // can be achieved using -I and -M in - // the yast2 start script - // And more unimplemented stuff for scrconf... - "Y2DIR", // replace with env. var. Y2DIR - "HOME", // replace with users home dir + /.yast2 - YAST2DIR -}; + vector<string> ret; + ret.push_back(string("/y2update")); -static const int NUM_LEVELS = sizeof (paths) / sizeof (paths[0]); + const char* y2dir = getenv("Y2DIR"); + if (y2dir) + { + vector<string> y2dirs; + boost::split(y2dirs, y2dir, boost::is_any_of(":")); + for (vector<string>::const_iterator it = y2dirs.begin(); it != y2dirs.end(); ++it) + { + if (*it != YAST2DIR) // prevent path duplication + ret.push_back(*it); + } + } + + const char* home = getenv("HOME"); + if (home) + { + ret.push_back(string(home) + "/.yast2"); + } + + ret.push_back(string(YAST2DIR)); + + y2debug("getPaths %s", boost::join(ret, " ").c_str()); + + return ret; +} + + +vector<string> Y2PathSearch::paths; + + +void +Y2PathSearch::initializePaths() +{ + if (paths.empty()) + paths = getPaths(); +} -bool Y2PathSearch::searchPrefixWarn = true; int -Y2PathSearch::numberOfComponentLevels () +Y2PathSearch::numberOfComponentLevels() { - return NUM_LEVELS; + initializePaths(); + return paths.size(); } string Y2PathSearch::searchPath (WHAT what, int level) { - static string *my_paths = 0; - - if (!my_paths) - { - // note: never deleted - my_paths = new string [NUM_LEVELS]; + initializePaths(); - const char *home = getenv ("HOME"); - const char *y2dir = getenv ("Y2DIR"); - - for (int i = 0; i < NUM_LEVELS; i++) - { - // #330965, avoid publicly writable dirs in search path - // (we return a nonexistent dir because the API does not - // allow us to say Skip, and a cleanup patch to fix that - // would be too large) - static const char * not_there = YAST2DIR "/not-there"; - if (strcmp (paths[i], "HOME") == 0) - { - if (home) - my_paths[i] = string (home) + "/.yast2"; - else - my_paths[i] = string (not_there); - } - else if (strcmp (paths[i], "Y2DIR") == 0) - { - if (y2dir - && (strcmp (YAST2DIR, y2dir) != 0)) // prevent path duplication - my_paths[i] = string (y2dir); - else - my_paths[i] = string (not_there); - } - else - { - my_paths[i] = string (paths[i]); - } - } - } + int levels = paths.size(); switch (what) { case EXECCOMP: - if (level == NUM_LEVELS - 1) // FIXME + if (level == levels - 1) // FIXME { return EXECCOMPDIR; } else { - return my_paths[level]; + return paths[level]; } break; case PLUGIN: - if (level == NUM_LEVELS - 1) // FIXME + if (level == levels - 1) // FIXME { return PLUGINDIR; } else { - return my_paths[level] + "/plugin"; + return paths[level] + "/plugin"; } break; default: break; } - return my_paths[level]; + return paths[level]; } @@ -166,7 +164,10 @@ string Y2PathSearch::findy2 (string filename, int mode, int level) { - for (int i = 0; i < NUM_LEVELS; i++) + initializePaths(); + + int levels = paths.size(); + for (int i = 0; i < levels; i++) { // for level == -1, all levels are scanned if ((level >= 0) && (i != level)) @@ -180,7 +181,7 @@ if (access (pathname.c_str(), mode) == 0) { // FIXME: this check is different for clients and for modules - see find - if( searchPrefixWarn && i != NUM_LEVELS-1 ) + if( searchPrefixWarn && i != levels - 1 ) { y2warning( "Using special search prefix '%s' for '%s'",searchPath (GENERIC, i).c_str(), pathname.c_str() ); } @@ -247,7 +248,10 @@ int Y2PathSearch::defaultComponentLevel () { - for (int i = 0; i < NUM_LEVELS; i++) + initializePaths(); + + int levels = paths.size(); + for (int i = 0; i < levels; i++) { if (searchPath (GENERIC, i) == YAST2DIR) { @@ -255,7 +259,7 @@ } } /* NOTREACHED */ - return NUM_LEVELS - 1; + return levels - 1; } @@ -264,7 +268,7 @@ { // Determine current component level int current_level = defaultComponentLevel (); - char *levelstring = getenv ("Y2LEVEL"); + const char* levelstring = getenv ("Y2LEVEL"); if (levelstring) { current_level = atoi (levelstring); @@ -277,26 +281,15 @@ bool YCPPathSearch::initialized = false; -// watch out, duplicated in char *paths[] + void YCPPathSearch::initialize (Kind kind, const char *suffix) { - const char *home = getenv ("HOME"); - const char *y2dir = getenv ("Y2DIR"); - searchPrefixWarn = (getenv ("Y2SILENTSEARCH") == NULL); - addPath (kind, string (YAST2DIR) + suffix); - if (home) - { - string homey2 = string (home) + "/.yast2"; - addPath (kind, homey2 + suffix); - } - if (y2dir) - { - addPath (kind, string (y2dir) + suffix); - } - addPath (kind, string ("/y2update") + suffix); + vector<string> paths = getPaths(); + for (vector<string>::const_reverse_iterator it = paths.rbegin(); it != paths.rend(); ++it) + addPath(kind, *it + suffix); } Modified: trunk/core/package/yast2-core.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/package/yast2-core.changes?r... ============================================================================== --- trunk/core/package/yast2-core.changes (original) +++ trunk/core/package/yast2-core.changes Fri Dec 18 14:34:11 2009 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Fri Dec 18 12:43:39 CET 2009 - aschnell@suse.de + +- allow Y2DIR to be a list of paths separated by ":" +- 2.19.0 + +------------------------------------------------------------------- Fri Aug 14 17:03:17 CEST 2009 - lslezak@suse.cz - don't generate autodocs on ARM (doesn't work in qemu-arm) Modified: trunk/core/yast2-core.spec.in URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/yast2-core.spec.in?rev=60150... ============================================================================== --- trunk/core/yast2-core.spec.in (original) +++ trunk/core/yast2-core.spec.in Fri Dec 18 14:34:11 2009 @@ -5,7 +5,7 @@ Group: System/YaST License: GPL v2 or later # obviously -BuildRequires: gcc-c++ +BuildRequires: gcc-c++ boost-devel # we have a parser BuildRequires: flex bison # needed for all yast packages -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org