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. # Process this file with autoconf to produce a configure script.
AC_INIT AC_INIT
AC_CONFIG_SRCDIR([src/prtget.cpp]) 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 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 in their "Depends on:" line. Use the --softdeps flag to also search the
"Optional:" lines for \fB<package>\fP. "Optional:" lines for \fB<package>\fP.
By default, output is restricted to ports that are installed. To see all hard By default, output is restricted to ports that are installed. To see all
dependencies, add the --all switch; use --recursive to get a recursive list the dependencies, add the --all switch; use --recursive to get a recursive
(without duplication), and --tree to get a nicely indented one. list (without duplication), and --tree to get a nicely indented one.
.TP .TP
.B dup [-v] [format] .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 this option is not required; it's primarily interesting if you're developing
an independent installation. 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 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 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 archives get unpacked, but the relevant prt\-get.conf and ports tree are those

View File

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

View File

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

View File

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

View File

@ -327,20 +327,9 @@ Repository::WriteResult Repository::writeCache( const string& cacheFile )
const Package* p = it->second; const Package* p = it->second;
// TODO: encode // TODO: encode
hasReadme = noStr; hasReadme = ( p->hasReadme() ) ? yesStr : noStr;
if ( p->hasReadme() ) { hasPreInstall = ( p->hasPreInstall() ) ? yesStr : noStr;
hasReadme = yesStr; hasPostInstall = ( p->hasPostInstall() ) ? yesStr : noStr;
}
hasPreInstall = noStr;
if ( p->hasPreInstall() ) {
hasPreInstall = yesStr;
}
hasPostInstall = noStr;
if ( p->hasPostInstall() ) {
hasPostInstall = yesStr;
}
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", 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(), p->name().c_str(),