From e7d2481dcbc42923fd0f285cf724fbb5e6f9308d Mon Sep 17 00:00:00 2001 From: John McQuah Date: Fri, 23 Jun 2023 14:48:05 -0400 Subject: [PATCH] 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 --- doc/prt-get.8 | 115 ++++++++++++++++++++++++------------- doc/prt-get.conf.5 | 12 ++-- src/installtransaction.cpp | 15 ++++- src/installtransaction.h | 1 + src/process.cpp | 8 +-- src/process.h | 4 +- src/prtget.cpp | 20 ++++--- 7 files changed, 113 insertions(+), 62 deletions(-) diff --git a/doc/prt-get.8 b/doc/prt-get.8 index 5fc04d4..12e4658 100644 --- a/doc/prt-get.8 +++ b/doc/prt-get.8 @@ -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] 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] [ ...] -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] [ ...] -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] print a tree of the dependencies of the package .B . -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 -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] -print a list of ports which have +.B dependent [\-\-recursive] [\-\-softdeps] [\-\-all] [\-\-tree] +print a list of ports whose "Depends on:" line contains .B -in their "Depends on:" line. Use the --softdeps flag to also search the -"Optional:" lines for \fB\fP. +(or its dependents, if --recursive was passed). Use the --softdeps flag to +also search the "Optional:" lines for \fB\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=. (see below for the documentation of these options) + .TP .B \-\-install-root= Use 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 . +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 . The setting for --install-root determines which package database is used for reading/writing (so /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 to contain -its own copy of the ports tree, or even a copy of prt-get.conf. -However, if /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 /etc/pkgadd.conf . +its own copy of the ports tree (unless 'runscripts yes' is desired, as +explained above) However, if /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 +/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 in configuration, overriding configuration file .TP .B \-\-config= -Use alternative configuration file to read ports directories from +Use to read configuration directives, rather than /etc/prt-get.conf. .SH "" diff --git a/doc/prt-get.conf.5 b/doc/prt-get.conf.5 index 1bd5e2d..bb1327e 100644 --- a/doc/prt-get.conf.5 +++ b/doc/prt-get.conf.5 @@ -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 :-) diff --git a/src/installtransaction.cpp b/src/installtransaction.cpp index 31f66c9..f51daa3 100644 --- a/src/installtransaction.cpp +++ b/src/installtransaction.cpp @@ -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)); diff --git a/src/installtransaction.h b/src/installtransaction.h index a766cdf..bc246c7 100644 --- a/src/installtransaction.h +++ b/src/installtransaction.h @@ -71,6 +71,7 @@ public: enum State { EXEC_SUCCESS, FAILED, + DEFERRED, NONEXISTENT }; struct InstallInfo { diff --git a/src/process.cpp b/src/process.cpp index c5865cd..0a6b255 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -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(); diff --git a/src/process.h b/src/process.h index 416e65a..97433fc 100644 --- a/src/process.h +++ b/src/process.h @@ -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); diff --git a/src/prtget.cpp b/src/prtget.cpp index 12ac51c..bb40e24 100644 --- a/src/prtget.cpp +++ b/src/prtget.cpp @@ -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 */