document the interaction between --install-root and 'runscripts yes';

allow command line to override more settings in prt-get.conf;
tune installTransaction to avoid lookup during evaluateResult
This commit is contained in:
John McQuah 2023-05-31 08:59:55 -04:00
parent b3404ff38e
commit 21f2e52314
6 changed files with 41 additions and 33 deletions

View File

@ -1,7 +1,7 @@
# Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_SRCDIR([src/prtget.cpp])
AM_INIT_AUTOMAKE(prt-get,5.19.5)
AM_INIT_AUTOMAKE(prt-get,5.19.7)
dnl Determine default prefix

View File

@ -258,9 +258,9 @@ print a list of ports which have
in their "Depends on:" line. Use the --softdeps flag to also search the
"Optional:" lines for \fB<package>\fP.
By default, output is restricted to ports that are installed. To see all hard
dependencies, add the --all switch; use --recursive to get a recursive list
(without duplication), and --tree to get a nicely indented one.
By default, output is restricted to ports that are installed. To see all
the dependencies, add the --all switch; use --recursive to get a recursive
list (without duplication), and --tree to get a nicely indented one.
.TP
.B dup [-v] [format]
@ -549,6 +549,16 @@ the requested packages onto a different directory than '/'. In daily usage,
this option is not required; it's primarily interesting if you're developing
an independent installation.
Some pre- or post-install scripts might not have the intended effect if
invoked as
.B chroot <dir> /bin/sh <path/to/script>
(the naive way to respect --install-root).
So if you're maintaining an installation on a volume mounted somewhere
other than '/', it might be safer to ensure that your \fBprt\-get.conf(5)\fP
has the line
.B runscripts no
and then run any pre- or post-install scripts by hand.
The setting for --install-root determines which package database is used for
reading/writing (so <dir>/var/lib/pkg/db must exist), and where the pkg.tar.?z
archives get unpacked, but the relevant prt\-get.conf and ports tree are those

View File

@ -153,7 +153,9 @@ void Configuration::parseLine(const string& line, bool prepend)
// it's already set to false, so we can just enable it.
// like this, the command line switch works as well
m_writeLog = true;
}
} else if ( s == "disabled" ) {
m_writeLog = false;
}
} else if ( startsWithNoCase( s, "logfile" ) ) {
s = stripWhiteSpace( s.replace( 0, 7, "" ) );
m_logFilePattern = s;
@ -166,7 +168,9 @@ void Configuration::parseLine(const string& line, bool prepend)
s = stripWhiteSpace( s.replace( 0, 16, "" ) );
if ( s == "yes" ) {
m_removeLogOnSuccess = true;
}
} else if ( s == "no" ) {
m_removeLogOnSuccess = false;
}
} else if ( startsWithNoCase( s, "readme" ) ) {
s = stripWhiteSpace( s.replace( 0, 6, "" ) );
if ( s == "compact" ) {
@ -178,12 +182,16 @@ void Configuration::parseLine(const string& line, bool prepend)
s = stripWhiteSpace( s.replace( 0, 10, "" ) );
if ( s == "yes" ) {
m_runScripts = true;
}
} else if ( s == "no" ) {
m_runScripts = false;
}
} else if ( startsWithNoCase( s, "preferhigher" ) ) {
s = stripWhiteSpace( s.replace( 0, 12, "" ) );
if ( s == "yes" ) {
m_preferHigher = true;
}
} else if ( s == "no" ) {
m_preferHigher = false;
}
} else if ( startsWithNoCase( s, "useregex" ) ) {
s = stripWhiteSpace( s.replace( 0, 8, "" ) );
if ( s == "yes" ) {
@ -193,8 +201,7 @@ void Configuration::parseLine(const string& line, bool prepend)
s = stripWhiteSpace( s.replace( 0, 8, "" ) );
if ( s == "yes" ) {
m_followSoftdeps = true;
}
if ( s == "no" ) {
} else if ( s == "no" ) {
m_followSoftdeps = false;
}
} else if ( startsWithNoCase( s, "makecommand" ) ) {

View File

@ -187,7 +187,8 @@ InstallTransaction::install( const ArgParser* parser,
if ( parser->isTest() ||
(result = installPackage( package, parser, update, info )) == SUCCESS) {
m_installedPackages.push_back( make_pair( package->name(), info));
m_installedPackages.push_back( make_pair( package->path()
+ "/" + package->name(), info));
} else {
// log failures are critical
@ -305,6 +306,9 @@ InstallTransaction::installPackage( const Package* package,
if (m_config->runscriptCommand() != "") {
runscriptCommand = m_config->runscriptCommand();
}
if (parser->installRoot() != "") {
runscriptCommand = "chroot " + parser->installRoot() + runscriptCommand;
}
// -- pre-install
struct stat statData;

View File

@ -1126,15 +1126,13 @@ void PrtGet::evaluateResult( InstallTransaction& transaction,
bool atLeastOnePackageHasReadme = false;
for ( ; iit != inst.end(); ++iit ) {
if (m_parser->printPath()) {
// TODO: avoid lookup by tuning
// InstallTransaction::installedPackages()
const Package* p = m_repo->getPackage(iit->first);
if (p) {
cout << p->path() << "/";
}
size_t pos = (iit->first).find_last_of('/');
if ( m_parser->printPath() || (pos == string::npos)
|| (pos+2 > (iit->first).length()) ) {
cout << iit->first;
} else {
cout << (iit->first).substr(pos+1);
}
cout << iit->first;
if ( iit->second.hasReadme ) {
if ( m_config->readmeMode() ==
Configuration::COMPACT_README ) {

View File

@ -327,20 +327,9 @@ Repository::WriteResult Repository::writeCache( const string& cacheFile )
const Package* p = it->second;
// TODO: encode
hasReadme = noStr;
if ( p->hasReadme() ) {
hasReadme = yesStr;
}
hasPreInstall = noStr;
if ( p->hasPreInstall() ) {
hasPreInstall = yesStr;
}
hasPostInstall = noStr;
if ( p->hasPostInstall() ) {
hasPostInstall = yesStr;
}
hasReadme = ( p->hasReadme() ) ? yesStr : noStr;
hasPreInstall = ( p->hasPreInstall() ) ? yesStr : noStr;
hasPostInstall = ( p->hasPostInstall() ) ? yesStr : noStr;
fprintf( fp, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n",
p->name().c_str(),