//--------------------------------------------------------------------------- // setCompare //--------------------------------------------------------------------------- const char* CDaliDeploymentEngine::setCompare(const char *filename) { //BUG: 9254 - Deploy Wizard's "compare" for Dali looks in wrong folder //If filename is in deploy folder then compare file in folder above it. // StringBuffer installPath; getInstallPath(filename, installPath); return CDeploymentEngine::setCompare(installPath.str()); }
//--------------------------------------------------------------------------- // compareFiles //--------------------------------------------------------------------------- void CDaliDeploymentEngine::compareFiles(const char *newFile, const char *oldFile) { //BUG: 9254 - Deploy Wizard's "compare" for Dali looks in wrong folder //If filename is in deploy folder then compare file in folder above it. // StringBuffer installPath; getInstallPath(oldFile, installPath); Owned<IDeployTask> task = createDeployTask(*m_pCallback, "Compare File", m_process.queryName(), m_name.get(), m_curInstance, newFile, installPath.str(), m_curSSHUser.str(), m_curSSHKeyFile.str(), m_curSSHKeyPassphrase.str(), m_useSSHIfDefined); m_pCallback->printStatus(task); task->compareFile(DTC_CRC | DTC_SIZE); m_pCallback->printStatus(task); checkAbort(task); }
namespace core { //===========================================================================// const std::string APPLICATION_PATH = getApplicationPath(); const std::string INSTALL_PATH = getInstallPath(APPLICATION_PATH); const std::string DATA_PATH = path::join(INSTALL_PATH, "data"); const std::string BINARY_PATH = path::join(INSTALL_PATH, "bin"); namespace path { //===========================================================================// std::vector<std::string> split(const std::string& input) { std::vector<std::string> elements; for (const auto& curr : boost::filesystem::path(input)) { elements.push_back(curr.filename().string()); } return elements; } //===========================================================================// std::string join(const std::string& start, const std::string& end) { boost::filesystem::path path(start); path /= end; path.normalize(); return path.string(); } //===========================================================================// bool exists(const std::string& pathname) { return boost::filesystem::exists(pathname); } //===========================================================================// std::vector<std::string> listDirectory(const std::string& pathname) { boost::filesystem::path path(pathname); std::vector<std::string> ret; for (auto iter = boost::filesystem::directory_iterator(path); iter != boost::filesystem::directory_iterator(); ++iter) { if (!boost::filesystem::is_directory(iter->path())) { ret.push_back(iter->path().filename().string()); } } return ret; } //===========================================================================// std::string getExtension(const std::string& pathname, size_t iterations) { std::string extension; std::string fullExtension; boost::filesystem::path base = pathname; size_t iter = 0; do { extension = boost::filesystem::extension(base); fullExtension = extension + fullExtension; base = base.stem(); ++iter; } while (!extension.empty() && (iter < iterations || !iterations)); return fullExtension; } //===========================================================================// std::string getBase(const std::string& pathname) { return boost::filesystem::path(pathname).filename().stem().string(); } //===========================================================================// std::string getDirectory(const std::string& pathname) { boost::filesystem::path boostPath(pathname); if (boost::filesystem::is_directory(boostPath)) { return pathname; } const std::string path = boostPath.parent_path().string(); return path.empty() ? "." : path + "/"; } //===========================================================================// std::string getFilename(const std::string& pathname) { boost::filesystem::path boostPath(pathname); if (boost::filesystem::is_directory(boostPath)) { return ""; } return boostPath.filename().string(); } //===========================================================================// void makeDirectory(const std::string& path) { boost::filesystem::create_directories(path); } //===========================================================================// void removeAll(const std::string& path) { boost::filesystem::remove_all(path); } } }
void MarketSrcPackage::process() { if (!m_Initialized) throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION, "package "+m_PackageFilename+" not initialized"); if (!m_Downloaded) throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION, "package "+m_PackageFilename+" cannot be processed before download"); if (!m_CMakeProgram.isFound()) throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,"CMake command not defined"); std::string BuildConfigOptions = composeFullBuildOptions(getPackageType(), m_BuildConfigOptions); std::string BuildDir = m_TempBuildsDir + "/" + m_ID; std::string SrcInstallDir = getInstallPath() + "/" + m_ID; // creating installation dir if (openfluid::tools::Filesystem::isDirectory(SrcInstallDir)) openfluid::tools::Filesystem::removeDirectory(SrcInstallDir); if (!openfluid::tools::Filesystem::makeDirectory(SrcInstallDir)) throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION, "unable to create source directory for "+m_ID+" package"); // creating build dir if (openfluid::tools::Filesystem::isDirectory(BuildDir)) openfluid::tools::Filesystem::removeDirectory(BuildDir); if (!openfluid::tools::Filesystem::makeDirectory(BuildDir)) throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION, "unable to create build directory for "+m_ID+" package"); // == Building commands == QString UntarCommand = QString("\"%1\" -E chdir \"%2\" \"%1\" -E tar xfz \"%3\"") .arg(m_CMakeProgram.getFullProgramPath(), QString::fromStdString(SrcInstallDir), QString::fromStdString(m_PackageDest)); QString BuildConfigCommand = QString("\"%1\" -E chdir \"%2\" \"%1\" \"%3\" %4") .arg(m_CMakeProgram.getFullProgramPath(), QString::fromStdString(BuildDir), QString::fromStdString(SrcInstallDir), QString::fromStdString(BuildConfigOptions)); QString BuildCommand = QString("\"%1\" -E chdir \"%2\" \"%1\" --build .") .arg(m_CMakeProgram.getFullProgramPath(), QString::fromStdString(BuildDir)); // uncompressing package { QProcess Untar; Untar.start(UntarCommand); Untar.waitForFinished(-1); Untar.waitForReadyRead(-1); appendToLogFile(QString(Untar.readAllStandardOutput()).toStdString()); int RetValue = Untar.exitCode(); if (RetValue != 0) { appendToLogFile(QString(Untar.readAllStandardError()).toStdString()); throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION, "Error uncompressing sources package using CMake"); } } // configuring the build { QProcess Config; Config.start(BuildConfigCommand); Config.waitForFinished(-1); Config.waitForReadyRead(-1); appendToLogFile(QString(Config.readAllStandardOutput()).toStdString()); int RetValue = Config.exitCode(); if (RetValue != 0) { appendToLogFile(QString(Config.readAllStandardError()).toStdString()); throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION, "Error configuring package build using CMake"); } } // building { QProcess Build; Build.start(BuildCommand); Build.waitForFinished(-1); Build.waitForReadyRead(-1); appendToLogFile(QString(Build.readAllStandardOutput()).toStdString()); int RetValue = Build.exitCode(); if (RetValue != 0) { appendToLogFile(QString(Build.readAllStandardError()).toStdString()); throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,"Error building package using CMake"); } } // TODO add management of plugins suffixes for builder-extensions std::string PackagesPluginsSuffixes= ""; if (getPackageType() == PackageInfo::SIM) PackagesPluginsSuffixes = openfluid::config::SIMULATORS_PLUGINS_SUFFIX; else if (getPackageType() == PackageInfo::OBS) PackagesPluginsSuffixes = openfluid::config::OBSERVERS_PLUGINS_SUFFIX; if (!openfluid::tools::Filesystem::isFile(BuildDir+"/"+m_ID+PackagesPluginsSuffixes+openfluid::config::PLUGINS_EXT)) throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,"Error finding built package"); std::string BinInstallDir = getInstallPath() + "/../" + m_MarketBagBinSubDir; if (openfluid::tools::Filesystem::isFile(BinInstallDir+"/"+m_ID+ PackagesPluginsSuffixes +openfluid::config::PLUGINS_EXT)) openfluid::tools::Filesystem::removeFile(BinInstallDir+"/"+m_ID+ PackagesPluginsSuffixes+openfluid::config::PLUGINS_EXT); openfluid::tools::Filesystem::copyFile(BuildDir+"/"+m_ID+PackagesPluginsSuffixes+openfluid::config::PLUGINS_EXT, BinInstallDir+"/"+m_ID+PackagesPluginsSuffixes+openfluid::config::PLUGINS_EXT); if (!m_KeepSources) openfluid::tools::Filesystem::removeDirectory(SrcInstallDir); }