Author: jw Date: 2006-04-04 18:22:35 +0200 (Tue, 04 Apr 2006) New Revision: 1139 Modified: tools/prt-get/trunk/src/configuration.cpp tools/prt-get/trunk/src/configuration.h tools/prt-get/trunk/src/installtransaction.cpp Log: prt-get: add option to remove log files of successful builds Modified: tools/prt-get/trunk/src/configuration.cpp =================================================================== --- tools/prt-get/trunk/src/configuration.cpp 2006-04-04 16:00:31 UTC (rev 1138) +++ tools/prt-get/trunk/src/configuration.cpp 2006-04-04 16:22:35 UTC (rev 1139) @@ -26,6 +26,7 @@ m_parser( parser ), m_writeLog( false ), m_appendLog( false ), + m_removeLogOnSuccess( false ), m_logFilePattern( "" ), m_cacheFile( "" ), m_readmeMode( VERBOSE_README ), @@ -76,6 +77,11 @@ return m_appendLog; } +bool Configuration::removeLogOnSuccess() const +{ + return m_removeLogOnSuccess; +} + string Configuration::logFilePattern() const { return m_logFilePattern; @@ -154,6 +160,11 @@ if ( s == "append" ) { m_appendLog = true; } + } else if ( startwith_nocase( s, "rmlog_on_success" ) ) { + s = stripWhiteSpace( s.replace( 0, 16, "" ) ); + if ( s == "yes" ) { + m_removeLogOnSuccess = true; + } } else if ( startwith_nocase( s, "readme" ) ) { s = stripWhiteSpace( s.replace( 0, 6, "" ) ); if ( s == "compact" ) { Modified: tools/prt-get/trunk/src/configuration.h =================================================================== --- tools/prt-get/trunk/src/configuration.h 2006-04-04 16:00:31 UTC (rev 1138) +++ tools/prt-get/trunk/src/configuration.h 2006-04-04 16:22:35 UTC (rev 1139) @@ -29,6 +29,7 @@ bool writeLog() const; bool appendLog() const; + bool removeLogOnSuccess() const; std::string logFilePattern() const; const std::list< std::pair<std::string, std::string> >& rootList() const; @@ -64,6 +65,7 @@ std::string m_logFilePattern; bool m_writeLog; bool m_appendLog; + bool m_removeLogOnSuccess; ReadmeMode m_readmeMode; Modified: tools/prt-get/trunk/src/installtransaction.cpp =================================================================== --- tools/prt-get/trunk/src/installtransaction.cpp 2006-04-04 16:00:31 UTC (rev 1138) +++ tools/prt-get/trunk/src/installtransaction.cpp 2006-04-04 16:22:35 UTC (rev 1139) @@ -109,21 +109,21 @@ if ( m_packages.empty() ) { return NO_PACKAGE_GIVEN; } - + list<string> ignoredPackages; StringHelper::split(parser->ignore(), ',', ignoredPackages); list< pair<string, const Package*> >::iterator it = m_packages.begin(); for ( ; it != m_packages.end(); ++it ) { const Package* package = it->second; - - if (find(ignoredPackages.begin(), - ignoredPackages.end(), + + if (find(ignoredPackages.begin(), + ignoredPackages.end(), it->first) != ignoredPackages.end() ) { m_ignoredPackages.push_back(it->first); continue; } - + if ( package == NULL ) { m_missingPackages.push_back( make_pair( it->first, string("") ) ); if ( group ) { @@ -190,8 +190,10 @@ #endif int fdlog = -1; + string logFile = ""; + if ( m_config->writeLog() ) { - string logFile = m_config->logFilePattern(); + logFile = m_config->logFilePattern(); if ( logFile == "" ) { return NO_LOG_FILE; } @@ -344,6 +346,11 @@ // Close logfile close ( fdlog ); + + if (m_config->removeLogOnSuccess() && !m_config->appendLog() && + result == SUCCESS) { + unlink(logFile.c_str()); + } } return result; }