From 2d2b1d669337dd8843f785c2f3d9c6048f730252 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Sat, 28 May 2022 08:20:18 -0400 Subject: [PATCH] welding in a virtual unix root for windoze since windows is too dumb to have a top-level root folder, we need to rely on the virtualization environment that is getting us the features we rely on, which usually come from unix (or linux). the toolsets used in the past for this include MSYS, Cygwin, and possibly others. this release is starting to support Cygwin and others will be added as time permits. --- .../application_configuration.cpp | 28 +++++++++++++++++ .../configuration/application_configuration.h | 31 ++++++++++++++++--- nucleus/library/filesystem/filename.cpp | 14 +++++++++ production/paths.ini | 5 +++ scripts/cgi/paths.ini | 2 ++ scripts/generator/produce_feisty_meow.sh | 21 ++++++++++++- 6 files changed, 95 insertions(+), 6 deletions(-) diff --git a/nucleus/library/configuration/application_configuration.cpp b/nucleus/library/configuration/application_configuration.cpp index d5ca0802..51df2a82 100644 --- a/nucleus/library/configuration/application_configuration.cpp +++ b/nucleus/library/configuration/application_configuration.cpp @@ -290,6 +290,34 @@ const astring &application_configuration::GLOBAL_SECTION_NAME() { STATIC_STRING( const astring &application_configuration::LOGGING_FOLDER_NAME() { STATIC_STRING("LogPath"); } +const astring &application_configuration::WINDOZE_VIRTUAL_ROOT_NAME() +{ STATIC_STRING("VirtualUnixRoot"); } + +const astring &application_configuration::DEFAULT_VIRTUAL_UNIX_ROOT() +{ STATIC_STRING("c:/cygwin"); } + +////////////// + +astring application_configuration::get_virtual_unix_root() +{ +#ifdef __UNIX__ + // simple implementation for unix/linux; just tell the truth about the real root. + return "/"; +#endif +#ifdef __WIN32__ + /* + read the path out of the config file, which should have been set during the + build process if this is really windows. + */ + astring virtual_root = read_item(WINDOZE_VIRTUAL_ROOT_NAME()); + if (!virtual_root) { + // if it has no length, we didn't get our setting! we'll limp along with a guess. + return DEFAULT_VIRTUAL_UNIX_ROOT; + } + +#endif +} + ////////////// ////const int MAX_LOG_PATH = 512; diff --git a/nucleus/library/configuration/application_configuration.h b/nucleus/library/configuration/application_configuration.h index bb829304..34d57751 100644 --- a/nucleus/library/configuration/application_configuration.h +++ b/nucleus/library/configuration/application_configuration.h @@ -74,9 +74,20 @@ public: //!< retrieves the core binary directory location from paths.ini. static basis::astring get_logging_directory(); - //!< returns the directory where log files will be stored. + //!< returns the folder where the log files for the feisty meow system are stored. + /*!< any log files should be written to this folder by the rest of the codebase, + unless there are special purposes for those log files. but logs from general + operation of feisty meow should be written in this directory. */ + + static basis::astring get_virtual_unix_root(); + //!< returns the path to the unix root, which may be simulated. + /*!< on unix, this will just return '/'. on win32 with cygwin installed, + this will return the cygwin path for '/' that was detected at build time. + this is often "c:/cygwin", which we use as a default if the path isn't + detected properly. */ // the following are key names within the main configuration file. + // not generally for external use. static const basis::astring &GLOBAL_SECTION_NAME(); //!< the root section name for our configuration items in the main ini file. @@ -91,10 +102,20 @@ public: /*!< this is where all files for this product are stored on "this" machine. */ static const basis::astring &LOGGING_FOLDER_NAME(); - //!< the location where the log files for the system are stored. - /*!< this is always considered to be a directory under the local folder. - the make_logfile_name() function (see below) can be used to create a - properly formed filename for logging. */ + //!< the tag used for finding our logging path in the paths config file. + + static const basis::astring &WINDOZE_VIRTUAL_ROOT_NAME(); + //!< the tag used for looking up the virtual windows path in the paths config file. + + static const basis::astring &DEFAULT_VIRTUAL_UNIX_ROOT(); + //!< default value if we don't find our setting for virtual root. + /*!< this is bound to fail on many occasions if it's actually used on + windoze for the default, but if we don't have good information ready, + we can't just intuit the virtual unix root; we are not kreskin. the + virtual unix environment could be MSYS, Cygwin, or others. Currently, + if Cygwin is used during the build process, then the default should + never be needed. support for other systems will be added as time + permits and users clamor for them. */ // helper methods. diff --git a/nucleus/library/filesystem/filename.cpp b/nucleus/library/filesystem/filename.cpp index ed7b914a..ba72084e 100644 --- a/nucleus/library/filesystem/filename.cpp +++ b/nucleus/library/filesystem/filename.cpp @@ -227,6 +227,20 @@ void filename::canonicalize() //LOG(astring("turned msys string into: ") + *this); } } + + // if no specialized path specifications were seen, and we have a unix style path + // here, then there will be trouble when we pass that to windows. +//if first character is a slash, and second char is alphanumeric, then we check... +//can we find a cygwin root dir stored in our config stuff? +// maybe in the build version file? ugh, yuck. +// what about in generated files, created at build time? --> yes, nice option. +// +//hmmm: we need the capability to re-create the config file that tells us +// where cyg root is, but how can we, aside from guessing at where to find +// cygwin (c:/cygwin c:/cygwin64 etc). +// +//hmmm: + #endif // we don't crop the last separator if the name's too small. for msdos diff --git a/production/paths.ini b/production/paths.ini index 0f274370..df2d0646 100644 --- a/production/paths.ini +++ b/production/paths.ini @@ -1,3 +1,8 @@ [Common] +# default logging path that users can alter if needed. LogPath=$FEISTY_MEOW_GENERATED_STORE/logs +# default location of virtual root directory for Unix. +# replaced at runtime on windoze if cygwin is available. +#hmmm: support msys too at some point? very worthy as well. +VirtualUnixRoot=c:/cygwin diff --git a/scripts/cgi/paths.ini b/scripts/cgi/paths.ini index fe57bba9..1faa81a7 100755 --- a/scripts/cgi/paths.ini +++ b/scripts/cgi/paths.ini @@ -1,3 +1,5 @@ [Common] +# simple cgi paths.ini to point at different logging when really running. +#hmmm: not sure this is still useful or necessary; is it being honored on running systems with feisty? LogPath=/tmp/cgi-bin-logs diff --git a/scripts/generator/produce_feisty_meow.sh b/scripts/generator/produce_feisty_meow.sh index dbecd263..efdb78ac 100644 --- a/scripts/generator/produce_feisty_meow.sh +++ b/scripts/generator/produce_feisty_meow.sh @@ -33,6 +33,7 @@ export INCLUDED_FROM_BOOTSTRAP=true export BUILD_SCRIPTS_PATH="$( \cd "$(\dirname "$0")" && /bin/pwd )" #echo build scripts dir initial value: $BUILD_SCRIPTS_PATH BUILD_SCRIPTS_PATH="$(echo $BUILD_SCRIPTS_PATH | tr '\\\\' '/' )" +#hmmm: why four backslashes above? trying two in our unix virtual root code below. #echo build scripts dir after chewing: $BUILD_SCRIPTS_PATH # load in feisty meow basic scripts, if not already loaded. @@ -61,8 +62,26 @@ function prepare_binaries_dir() mkdir -p "$CLAM_BINARIES" fi if [ ! -f "$CLAM_BINARIES/paths.ini" ]; then - echo "copied paths.ini to binary dir." cp "$PRODUCTION_STORE/paths.ini" "$CLAM_BINARIES" + echo "copied paths.ini to binary dir." + fi + # set the cygwin root path if we're on cygwin. + whichable cygpath + if [ $? -eq 0 ]; then + # found cygpath, so run it now to get the dossy path of the root ('/' folder). + found_root=$(cygpath -w -m /) + if [ $? -ne 0 ]; then + echo "Failure to find virtual Unix root folder with cygpath." + exit 1322 + fi +echo "found root as '$found_root'" + # translate any backslashes to forward thinking slashes. + found_root=$(echo $found_root | tr '\\' '/') +echo "processed root is now: '$found_root'" + # edit the entry in place to correct the default path. + sed -i -e "s/VirtualUnixRoot=.*/VirtualUnixRoot=$found_root/" "$CLAM_BINARIES/paths.ini" +echo "paths file now has:" +cat "$CLAM_BINARIES/paths.ini" fi } -- 2.34.1