prt-get: add option to remove log files of successful builds

git-svn-id: https://crux.nu/svn/tools/prt-get/trunk@1139 0b5ae1c7-2405-0410-a7fc-ba219f786e1e
This commit is contained in:
Johannes Winkelmann 2006-04-04 16:22:35 +00:00
parent db9451817d
commit 08fbeb4724
3 changed files with 26 additions and 6 deletions

View File

@ -26,6 +26,7 @@ Configuration::Configuration( const std::string& configFile,
m_parser( parser ),
m_writeLog( false ),
m_appendLog( false ),
m_removeLogOnSuccess( false ),
m_logFilePattern( "" ),
m_cacheFile( "" ),
m_readmeMode( VERBOSE_README ),
@ -76,6 +77,11 @@ bool Configuration::appendLog() const
return m_appendLog;
}
bool Configuration::removeLogOnSuccess() const
{
return m_removeLogOnSuccess;
}
string Configuration::logFilePattern() const
{
return m_logFilePattern;
@ -154,6 +160,11 @@ void Configuration::parseLine(const string& line, bool prepend)
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" ) {

View File

@ -29,6 +29,7 @@ public:
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 @@ private:
std::string m_logFilePattern;
bool m_writeLog;
bool m_appendLog;
bool m_removeLogOnSuccess;
ReadmeMode m_readmeMode;

View File

@ -109,21 +109,21 @@ InstallTransaction::install( const ArgParser* parser,
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 @@ InstallTransaction::installPackage( const Package* package,
#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 @@ InstallTransaction::installPackage( const Package* package,
// Close logfile
close ( fdlog );
if (m_config->removeLogOnSuccess() && !m_config->appendLog() &&
result == SUCCESS) {
unlink(logFile.c_str());
}
}
return result;
}