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:
parent
db9451817d
commit
08fbeb4724
@ -26,6 +26,7 @@ Configuration::Configuration( const std::string& configFile,
|
|||||||
m_parser( parser ),
|
m_parser( parser ),
|
||||||
m_writeLog( false ),
|
m_writeLog( false ),
|
||||||
m_appendLog( false ),
|
m_appendLog( false ),
|
||||||
|
m_removeLogOnSuccess( false ),
|
||||||
m_logFilePattern( "" ),
|
m_logFilePattern( "" ),
|
||||||
m_cacheFile( "" ),
|
m_cacheFile( "" ),
|
||||||
m_readmeMode( VERBOSE_README ),
|
m_readmeMode( VERBOSE_README ),
|
||||||
@ -76,6 +77,11 @@ bool Configuration::appendLog() const
|
|||||||
return m_appendLog;
|
return m_appendLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Configuration::removeLogOnSuccess() const
|
||||||
|
{
|
||||||
|
return m_removeLogOnSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
string Configuration::logFilePattern() const
|
string Configuration::logFilePattern() const
|
||||||
{
|
{
|
||||||
return m_logFilePattern;
|
return m_logFilePattern;
|
||||||
@ -154,6 +160,11 @@ void Configuration::parseLine(const string& line, bool prepend)
|
|||||||
if ( s == "append" ) {
|
if ( s == "append" ) {
|
||||||
m_appendLog = true;
|
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" ) ) {
|
} else if ( startwith_nocase( s, "readme" ) ) {
|
||||||
s = stripWhiteSpace( s.replace( 0, 6, "" ) );
|
s = stripWhiteSpace( s.replace( 0, 6, "" ) );
|
||||||
if ( s == "compact" ) {
|
if ( s == "compact" ) {
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
|
|
||||||
bool writeLog() const;
|
bool writeLog() const;
|
||||||
bool appendLog() const;
|
bool appendLog() const;
|
||||||
|
bool removeLogOnSuccess() const;
|
||||||
std::string logFilePattern() const;
|
std::string logFilePattern() const;
|
||||||
|
|
||||||
const std::list< std::pair<std::string, std::string> >& rootList() const;
|
const std::list< std::pair<std::string, std::string> >& rootList() const;
|
||||||
@ -64,6 +65,7 @@ private:
|
|||||||
std::string m_logFilePattern;
|
std::string m_logFilePattern;
|
||||||
bool m_writeLog;
|
bool m_writeLog;
|
||||||
bool m_appendLog;
|
bool m_appendLog;
|
||||||
|
bool m_removeLogOnSuccess;
|
||||||
|
|
||||||
ReadmeMode m_readmeMode;
|
ReadmeMode m_readmeMode;
|
||||||
|
|
||||||
|
@ -190,8 +190,10 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int fdlog = -1;
|
int fdlog = -1;
|
||||||
|
string logFile = "";
|
||||||
|
|
||||||
if ( m_config->writeLog() ) {
|
if ( m_config->writeLog() ) {
|
||||||
string logFile = m_config->logFilePattern();
|
logFile = m_config->logFilePattern();
|
||||||
if ( logFile == "" ) {
|
if ( logFile == "" ) {
|
||||||
return NO_LOG_FILE;
|
return NO_LOG_FILE;
|
||||||
}
|
}
|
||||||
@ -344,6 +346,11 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
|
|
||||||
// Close logfile
|
// Close logfile
|
||||||
close ( fdlog );
|
close ( fdlog );
|
||||||
|
|
||||||
|
if (m_config->removeLogOnSuccess() && !m_config->appendLog() &&
|
||||||
|
result == SUCCESS) {
|
||||||
|
unlink(logFile.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user