support more format codes in the argument to 'dup'

expand man-page to explain some asymmetries

report pre- and post-install scripts in test mode
This commit is contained in:
John McQuah 2023-06-23 14:48:05 -04:00
parent 934e044f86
commit e7d2481dcb
7 changed files with 113 additions and 62 deletions

View File

@ -188,19 +188,18 @@ Search the ports tree (both name and description) for the pattern
.B expr .B expr
(which can be a shell-like wildcard pattern or a regexp). The search in (which can be a shell-like wildcard pattern or a regexp). The search in
the description is not case sensitive. Note that this requires prt\-get the description is not case sensitive. Note that this requires prt\-get
to read every Pkgfile, which makes it rather slow; if you like this, to read every Pkgfile, which makes it rather slow. If you like searching by
consider using the cache functionality, so you only have to spend this description, consider using the cache functionality, so you only have to
time once after updating the ports tree has been updated. read all the Pkgfiles after each update of the ports tree.
.TP .TP
.B fsearch [\-\-full] [\-\-regex] <pattern> .B fsearch [\-\-full] [\-\-regex] <pattern>
Search the ports tree for Search the ports tree for
.B pattern .B pattern
as file name in their footprint. When called without '--full', strips as file name in their footprint. When called without '--full', strips
the directories from the file names before matching; this behaviour the directories from the file names before matching.
will change in prt-get 0.6, where full path search will be the Pattern can be a shell-like wildcard pattern (e.g. prt-get fsearch "*.h")
default. Pattern can be a shell-like wildcard pattern (e.g. prt-get or a regular expression (e.g. prt-get fsearch --regex 'liblz(o2|ma).*')
fsearch "*.h") or a regular expression (e.g. prt-get fsearch --regex 'liblz(o2|ma).*')
.TP .TP
@ -217,18 +216,19 @@ Print the port's README file if it exists; if set, uses $PAGER
.TP .TP
.B depends [\-\-softdeps] <package1> [<package2> ...] .B depends [\-\-softdeps] <package1> [<package2> ...]
print a recursive list of dependencies needed to install the packages passed print a recursive list of dependencies needed to install the packages
as argument. It shows a list of the dependencies that were found in the ports tree, passed as argument. It shows a list of the dependencies that were found in
plus a list of the dependencies that could not be found. Pass the --softdeps flag the ports tree, plus a list of the dependencies that could not be found.
if you want the sorting algorithm to consider optional dependencies too. Pass the --softdeps flag if you want the sorting algorithm to consider
optional dependencies too.
.TP .TP
.B quickdep [\-\-softdeps] <package1> [<package2> ...] .B quickdep [\-\-softdeps] <package1> [<package2> ...]
same output as \fBdepends\fP, but separated by spaces rather than newlines, and same output as \fBdepends\fP, but separated by spaces rather than newlines,
stripped of any dependencies that could not be found in the ports tree. and stripped of any dependencies that could not be found in the ports tree.
Useful in case the list of dependencies is too large to fit on one screen, or Useful in case the list of dependencies is too large to fit on one screen,
if you don't want to filter out manually the ports that are invalid targets for or if you don't want to filter out manually the ports that are invalid
installation. For example, instead of targets for installation. For example, instead of
.B prt\-get depinst xorg-server .B prt\-get depinst xorg-server
you might micromanage the process as follows: you might micromanage the process as follows:
.B for i in $(prt\-get quickdep xorg-server); do if prt\-get isinst $i 2>/dev/null; then prt\-get update \-fr $i; else prt\-get install $i; fi; done .B for i in $(prt\-get quickdep xorg-server); do if prt\-get isinst $i 2>/dev/null; then prt\-get update \-fr $i; else prt\-get install $i; fi; done
@ -243,32 +243,39 @@ for successful builds.
.B deptree [\-\-softdeps] <package> .B deptree [\-\-softdeps] <package>
print a tree of the dependencies of the package print a tree of the dependencies of the package
.B <package>. .B <package>.
Pass the --softdeps flag to also show the installed packages that mention Pass the --softdeps flag to also show the installed packages that might
have been eagerly linked, if they were present when
.B <package> .B <package>
as an optional dependency. (or its dependencies) were built.
Subtrees already shown are marked with '-->' to save some space. In Subtrees already shown are marked with '-->' to save some space. In
order to show them all, add the --all switch. order to show them all, add the --all switch.
.SH "" .SH ""
.TP .TP
.B dependent [\-\-softdeps] <package> .B dependent [\-\-recursive] [\-\-softdeps] [\-\-all] [\-\-tree] <package>
print a list of ports which have print a list of ports whose "Depends on:" line contains
.B <package> .B <package>
in their "Depends on:" line. Use the --softdeps flag to also search the (or its dependents, if --recursive was passed). Use the --softdeps flag to
"Optional:" lines for \fB<package>\fP. also search the "Optional:" lines for \fB<package>\fP.
By default, output is restricted to ports that are installed. To see all 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 the dependencies, use the --all switch. Use --tree to get a nicely indented
list (without duplication), and --tree to get a nicely indented one. list.
.TP .TP
.B dup [-v] [format] .B dup [-v] [format]
List ports which can be found in multiple directories configured in List ports which can be found in multiple directories configured in
.B /etc/prt-get.conf .B /etc/prt-get.conf
Use the verbose switch to simulate the output of version 5.12 and older (likely Use the \fB\-v\fP switch to see a verbose report, which will show for each
to go away in the future). The format string can be used to create user dup the port that takes precedence, and the port that is hidden (including
specified formats. The following symbols are currently replaced: full path and version info). The verbose switch is basically an alias for a
particular combination of the recognized format symbols, namely
.B '* %n\en %p1 %v1 precedes over\en %p2 %v2\en'.
You can customize the output by passing a different format string, whose
symbols will be replaced as follows.
.TP .TP
\ \ \ \(bu \ \ \ \(bu
@ -290,6 +297,21 @@ specified formats. The following symbols are currently replaced:
\ \ \ \(bu \ \ \ \(bu
%v2 \-> Version of port being hidden %v2 \-> Version of port being hidden
.TP
\ \ \ \(bu
%M1 \-> maintainer of port taking precedence
.TP
\ \ \ \(bu
%M2 \-> maintainer of port being hidden
.TP
\ \ \ \(bu
%u1 \-> URL of port taking precedence
.TP
\ \ \ \(bu
%u2 \-> URL of port being hidden
.TP .TP
.B list [\-v|\-vv] [\-\-path] [\-\-regex] [filter] .B list [\-v|\-vv] [\-\-path] [\-\-regex] [filter]
@ -363,7 +385,7 @@ are replaced like this:
up to date and "diff" if it's installed and a new version is in the up to date and "diff" if it's installed and a new version is in the
ports tree. ports tree.
Use "\\n" and "\\t" to format your output (no additional format specified Use "\\n" and "\\t" to format your output (no additional format symbols
suported). The optional format string2 can contain the same variables suported). The optional format string2 can contain the same variables
as format string1 and is used to sort the output. You can specify a as format string1 and is used to sort the output. You can specify a
.B wildcard filter .B wildcard filter
@ -542,6 +564,14 @@ Execute post-install script if it's there
.B \-\-install-scripts .B \-\-install-scripts
Execute pre-install and post-install script if they're there Execute pre-install and post-install script if they're there
The options --pre-install, --post-install, and --install-scripts offer a
convenient way to temporarily override the prt-get.conf directive 'runscripts
no', which was the historical default. Starting with CRUX 3.7, prt-get.conf is
being shipped with 'runscripts yes'. To override this default at the command
line, you have to pass the more cumbersome option --config-set=\(dqrunscripts
no\(dq, or point prt-get to an alternative configuration file using
--config=<file>. (see below for the documentation of these options)
.TP .TP
.B \-\-install-root=<dir> .B \-\-install-root=<dir>
Use <dir> as root directory for your installation; allows you to install Use <dir> as root directory for your installation; allows you to install
@ -551,25 +581,30 @@ an independent installation.
Pre- and post-install scripts will not be executed if the target root directory Pre- and post-install scripts will not be executed if the target root directory
lacks a copy of the ports tree. So if you're maintaining an installation on a lacks a copy of the ports tree. So if you're maintaining an installation on a
volume mounted somewhere other than '/', it's not enough to have the line volume mounted somewhere other than '/', it's not enough to have the
.B runscripts yes line 'runscripts yes' in your prt-get.conf; you also have to ensure that
in your prt-get.conf; you also have to ensure that the pre- and post-install the pre- and post-install scripts can be found in the same location
scripts can be found in the same location relative to <dir>. relative to <dir>.
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
on the parent filesystem. Therefore it is not necessary for <dir> to contain on the parent filesystem. Therefore it is not necessary for <dir> to contain
its own copy of the ports tree, or even a copy of prt-get.conf. its own copy of the ports tree (unless 'runscripts yes' is desired, as
However, if <dir>/etc/pkgadd.conf exists and is different from /etc/pkgadd.conf, explained above) However, if <dir>/etc/pkgadd.conf exists and is different
then install or update commands might behave unexpectedly. In order to preserve from /etc/pkgadd.conf, then install or update commands might behave
the \fBpkgadd.conf(5)\fP settings from the host system, append the option unexpectedly. In order to preserve the \fBpkgadd.conf(5)\fP settings from
--aargs='-c /etc/pkgadd.conf' to your \fBprt-get install\fP the host system, append the option --aargs='-c /etc/pkgadd.conf' to your
command, or just copy the desired directives into <dir>/etc/pkgadd.conf . \fBprt-get install\fP command, or just copy the desired directives into
<dir>/etc/pkgadd.conf .
.TP .TP
.B \-\-log .B \-\-log
Write build output to log file Write build output to log file. Basically a convenient alias for
\fB\-\-config\-set=\(dqwritelog enabled\(dq\fP. Note that there is no similar
alias allowing you to temporarily override the configuration directive
\(dqwritelog enabled\(dq; you have to resort to \fB\-\-config\-set=\(dqwritelog
disabled\(dq\fP if that is your intention.
.TP .TP
.B \-\-no-std-config .B \-\-no-std-config
@ -589,7 +624,7 @@ Set <string> in configuration, overriding configuration file
.TP .TP
.B \-\-config=<file> .B \-\-config=<file>
Use alternative configuration file to read ports directories from Use <file> to read configuration directives, rather than /etc/prt-get.conf.
.SH "" .SH ""

View File

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

View File

@ -184,8 +184,19 @@ InstallTransaction::install( const ArgParser* parser,
InstallTransaction::InstallResult result; InstallTransaction::InstallResult result;
InstallInfo info( package->hasReadme() ); InstallInfo info( package->hasReadme() );
if ( parser->isTest() || if ( parser->isTest() ) {
(result = installPackage( package, parser, update, info )) == SUCCESS) { 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() m_installedPackages.push_back( make_pair( package->path()
+ "/" + package->name(), info)); + "/" + package->name(), info));

View File

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

View File

@ -68,9 +68,9 @@ int Process::execute()
int status = 0; int status = 0;
if ( m_fdlog > 0 ) { if ( m_fdlog > 0 ) {
status = execLog(argc, argv); status = execLog(argv);
} else { } else {
status = exec(argc, argv); status = exec(argv);
} }
delete [] argv; delete [] argv;
@ -78,7 +78,7 @@ int Process::execute()
} }
int Process::execLog(const int argc, char** argv) int Process::execLog(char** argv)
{ {
int status = 0; int status = 0;
int fdpipe[2]; int fdpipe[2];
@ -123,7 +123,7 @@ int Process::execLog(const int argc, char** argv)
} }
int Process::exec(const int argc, char** argv) int Process::exec(char** argv)
{ {
int status = 0; int status = 0;
pid_t pid = fork(); pid_t pid = fork();

View File

@ -32,8 +32,8 @@ public:
private: private:
int exec(const int argc, char** argv); int exec(char** argv);
int execLog(const int argc, char** argv); int execLog(char** argv);
int execShell(const char* shell); int execShell(const char* shell);
int execShellLog(const char* shell); int execShellLog(const char* shell);

View File

@ -271,7 +271,7 @@ void PrtGet::listShadowed()
if (m_parser->otherArgs().size() > 0) if (m_parser->otherArgs().size() > 0)
format = *(m_parser->otherArgs().begin()); format = *(m_parser->otherArgs().begin());
else if (m_parser->verbose() > 0) else if (m_parser->verbose() > 0)
format = "* %n\n %p1 %v1 preceeds over \n %p2 %v2\n"; format = "* %n\n %p1 %v1 precedes over \n %p2 %v2\n";
string output; string output;
Package* p1; Package* p1;
@ -289,8 +289,13 @@ void PrtGet::listShadowed()
StringHelper::replaceAll(output, "%p2", p2->path() + "/" + p2->name()); StringHelper::replaceAll(output, "%p2", p2->path() + "/" + p2->name());
StringHelper::replaceAll(output, "%v1", p1->versionReleaseString()); StringHelper::replaceAll(output, "%v1", p1->versionReleaseString());
StringHelper::replaceAll(output, "%v2", p2->versionReleaseString()); StringHelper::replaceAll(output, "%v2", p2->versionReleaseString());
StringHelper::replaceAll(output, "%M1", p1->maintainer());
StringHelper::replaceAll(output, "%M2", p2->maintainer());
StringHelper::replaceAll(output, "%u1", p1->url());
StringHelper::replaceAll(output, "%u2", p2->url());
StringHelper::replaceAll(output, "\\n", "\n"); StringHelper::replaceAll(output, "\\n", "\n");
StringHelper::replaceAll(output, "\\t", "\t");
cout << output; cout << output;
} }
} }
@ -1186,20 +1191,19 @@ void PrtGet::evaluateResult( InstallTransaction& transaction,
void PrtGet::reportPrePost(const InstallTransaction::InstallInfo& info) { void PrtGet::reportPrePost(const InstallTransaction::InstallInfo& info) {
if (info.preState != InstallTransaction::NONEXISTENT) { if (info.preState != InstallTransaction::NONEXISTENT) {
string preString = "failed"; string preString = (info.preState == InstallTransaction::FAILED) ? "failed" : "ok";
if (info.preState == InstallTransaction::EXEC_SUCCESS) { if (info.preState == InstallTransaction::DEFERRED){
preString = "ok"; preString = "deferred";
} }
cout << " [pre: " << preString << "]"; cout << " [pre: " << preString << "]";
} }
if ( info.postState != InstallTransaction::NONEXISTENT) { if ( info.postState != InstallTransaction::NONEXISTENT) {
string postString = "failed"; string postString = (info.postState == InstallTransaction::FAILED) ? "failed" : "ok";
if (info.postState == InstallTransaction::EXEC_SUCCESS){ if (info.postState == InstallTransaction::DEFERRED){
postString = "ok"; postString = "deferred";
} }
cout << " [post: " << postString << "]"; cout << " [post: " << postString << "]";
} }
} }
/*! create a cache */ /*! create a cache */