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
(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
to read every Pkgfile, which makes it rather slow; if you like this,
consider using the cache functionality, so you only have to spend this
time once after updating the ports tree has been updated.
to read every Pkgfile, which makes it rather slow. If you like searching by
description, consider using the cache functionality, so you only have to
read all the Pkgfiles after each update of the ports tree.
.TP
.B fsearch [\-\-full] [\-\-regex] <pattern>
Search the ports tree for
.B pattern
as file name in their footprint. When called without '--full', strips
the directories from the file names before matching; this behaviour
will change in prt-get 0.6, where full path search will be the
default. Pattern can be a shell-like wildcard pattern (e.g. prt-get
fsearch "*.h") or a regular expression (e.g. prt-get fsearch --regex 'liblz(o2|ma).*')
the directories from the file names before matching.
Pattern can be a shell-like wildcard pattern (e.g. prt-get fsearch "*.h")
or a regular expression (e.g. prt-get fsearch --regex 'liblz(o2|ma).*')
.TP
@ -217,18 +216,19 @@ Print the port's README file if it exists; if set, uses $PAGER
.TP
.B depends [\-\-softdeps] <package1> [<package2> ...]
print a recursive list of dependencies needed to install the packages passed
as argument. It shows a list of the dependencies that were found in the ports tree,
plus a list of the dependencies that could not be found. Pass the --softdeps flag
if you want the sorting algorithm to consider optional dependencies too.
print a recursive list of dependencies needed to install the packages
passed as argument. It shows a list of the dependencies that were found in
the ports tree, plus a list of the dependencies that could not be found.
Pass the --softdeps flag if you want the sorting algorithm to consider
optional dependencies too.
.TP
.B quickdep [\-\-softdeps] <package1> [<package2> ...]
same output as \fBdepends\fP, but separated by spaces rather than newlines, 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
if you don't want to filter out manually the ports that are invalid targets for
installation. For example, instead of
same output as \fBdepends\fP, but separated by spaces rather than newlines,
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 if you don't want to filter out manually the ports that are invalid
targets for installation. For example, instead of
.B prt\-get depinst xorg-server
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
@ -243,32 +243,39 @@ for successful builds.
.B deptree [\-\-softdeps] <package>
print a tree of the dependencies of the 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>
as an optional dependency.
(or its dependencies) were built.
Subtrees already shown are marked with '-->' to save some space. In
order to show them all, add the --all switch.
.SH ""
.TP
.B dependent [\-\-softdeps] <package>
print a list of ports which have
.B dependent [\-\-recursive] [\-\-softdeps] [\-\-all] [\-\-tree] <package>
print a list of ports whose "Depends on:" line contains
.B <package>
in their "Depends on:" line. Use the --softdeps flag to also search the
"Optional:" lines for \fB<package>\fP.
(or its dependents, if --recursive was passed). 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
the dependencies, add the --all switch; use --recursive to get a recursive
list (without duplication), and --tree to get a nicely indented one.
the dependencies, use the --all switch. Use --tree to get a nicely indented
list.
.TP
.B dup [-v] [format]
List ports which can be found in multiple directories configured in
.B /etc/prt-get.conf
Use the verbose switch to simulate the output of version 5.12 and older (likely
to go away in the future). The format string can be used to create user
specified formats. The following symbols are currently replaced:
Use the \fB\-v\fP switch to see a verbose report, which will show for each
dup the port that takes precedence, and the port that is hidden (including
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
\ \ \ \(bu
@ -290,6 +297,21 @@ specified formats. The following symbols are currently replaced:
\ \ \ \(bu
%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
.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
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
as format string1 and is used to sort the output. You can specify a
.B wildcard filter
@ -542,6 +564,14 @@ Execute post-install script if it's there
.B \-\-install-scripts
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
.B \-\-install-root=<dir>
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
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
.B runscripts yes
in your prt-get.conf; you also have to ensure that the pre- and post-install
scripts can be found in the same location relative to <dir>.
volume mounted somewhere other than '/', it's not enough to have the
line 'runscripts yes' in your prt-get.conf; you also have to ensure that
the pre- and post-install scripts can be found in the same location
relative to <dir>.
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
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.
However, if <dir>/etc/pkgadd.conf exists and is different from /etc/pkgadd.conf,
then install or update commands might behave unexpectedly. In order to preserve
the \fBpkgadd.conf(5)\fP settings from the host system, append the option
--aargs='-c /etc/pkgadd.conf' to your \fBprt-get install\fP
command, or just copy the desired directives into <dir>/etc/pkgadd.conf .
its own copy of the ports tree (unless 'runscripts yes' is desired, as
explained above) However, if <dir>/etc/pkgadd.conf exists and is different
from /etc/pkgadd.conf, then install or update commands might behave
unexpectedly. In order to preserve the \fBpkgadd.conf(5)\fP settings from
the host system, append the option --aargs='-c /etc/pkgadd.conf' to your
\fBprt-get install\fP command, or just copy the desired directives into
<dir>/etc/pkgadd.conf .
.TP
.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
.B \-\-no-std-config
@ -589,7 +624,7 @@ Set <string> in configuration, overriding configuration file
.TP
.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 ""

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,7 +130,7 @@ 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
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
@ -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

@ -184,8 +184,19 @@ 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));

View File

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

View File

@ -68,9 +68,9 @@ int Process::execute()
int status = 0;
if ( m_fdlog > 0 ) {
status = execLog(argc, argv);
status = execLog(argv);
} else {
status = exec(argc, argv);
status = exec(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 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;
pid_t pid = fork();

View File

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

View File

@ -271,7 +271,7 @@ void PrtGet::listShadowed()
if (m_parser->otherArgs().size() > 0)
format = *(m_parser->otherArgs().begin());
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;
Package* p1;
@ -289,8 +289,13 @@ void PrtGet::listShadowed()
StringHelper::replaceAll(output, "%p2", p2->path() + "/" + p2->name());
StringHelper::replaceAll(output, "%v1", p1->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, "\\t", "\t");
cout << output;
}
}
@ -1186,20 +1191,19 @@ 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 << "]";
}
}
/*! create a cache */