report pre- and post-install scripts in test mode

This commit is contained in:
John McQuah 2023-06-23 14:08:28 -04:00
parent 68239f077b
commit 507afd9766
4 changed files with 27 additions and 15 deletions

View File

@ -20,7 +20,7 @@ It might look like this:
# prt-get.conf
# root directories
prtdir /usr/ports/base
prtdir /usr/ports/core
prtdir /usr/ports/opt
prtdir /usr/ports/contrib
@ -130,8 +130,8 @@ and %n would be
This allows you to have separate log files per port.
.B readme
which can be set to 'disabled', to suppress the notification after
installing a port with a README file; 'compact', to collect all the READMEs
can be set to 'disabled', to suppress the notification after installing
a port with a README file; 'compact', to collect all the READMEs
into one post-transaction output; or 'verbose', to print separate
information about each port with a README file. See
.B prt-get(8)
@ -149,13 +149,13 @@ append a comma separated list of ports to be used after the path,
using a colon (':') character to separate the two components
.B path:package1, package2,...
Note that this slows down prt-get a lot if you list a lot of packages.
If you become aware of speed problems due to this, create a separate
ports directory instead and use symlinks for the ports you want to use.
If you become aware of speed problems due to this feature, create a separate
ports directory instead and fill it with symlinks to the ports you want.
.LP
You can write comments after a '#' character. If you have '#'
characters in your paths, there's no way to escape them (as there is no
way to escape ':' characters). Complain to the author if this is a
characters in your paths, there's no way to escape them (likewise there is
no way to escape ':' characters). Complain to the author if this is a
problem :-)

View File

@ -169,8 +169,17 @@ InstallTransaction::install( const ArgParser* parser )
InstallTransaction::InstallResult result;
InstallInfo info( package->hasReadme() );
if ( parser->isTest() ||
(result = installPackage( package, parser, update, info )) == SUCCESS) {
if ( parser->isTest() ) {
info.preState = ( package->hasPreInstall() &&
(parser->execPreInstall() || m_config->runScripts())
) ? DEFERRED : NONEXISTENT;
info.postState = ( package->hasPostInstall() &&
(parser->execPostInstall() || m_config->runScripts())
) ? DEFERRED : NONEXISTENT;
m_installedPackages.push_back( make_pair( package->path() + "/" + package->name(), info));
continue;
}
if ((result = installPackage( package, parser, update, info )) == SUCCESS) {
m_installedPackages.push_back( make_pair( package->path() + "/" + package->name(), info));
} else {

View File

@ -67,6 +67,7 @@ public:
enum State {
EXEC_SUCCESS,
FAILED,
DEFERRED,
NONEXISTENT
};
struct InstallInfo {

View File

@ -1053,16 +1053,18 @@ void PrtGet::evaluateResult( InstallTransaction& transaction,
void PrtGet::reportPrePost(const InstallTransaction::InstallInfo& info) {
if (info.preState != InstallTransaction::NONEXISTENT) {
string preString = "failed";
if (info.preState == InstallTransaction::EXEC_SUCCESS) {
preString = "ok";
string preString = (info.preState == InstallTransaction::FAILED) ?
"failed" : "ok";
if (info.preState == InstallTransaction::DEFERRED) {
preString = "deferred";
}
cout << " [pre: " << preString << "]";
}
if ( info.postState != InstallTransaction::NONEXISTENT) {
string postString = "failed";
if (info.postState == InstallTransaction::EXEC_SUCCESS){
postString = "ok";
string postString = (info.postState == InstallTransaction::FAILED) ?
"failed" : "ok";
if (info.postState == InstallTransaction::DEFERRED) {
postString = "deferred";
}
cout << " [post: " << postString << "]";
}