You've already forked macports-base
mirror of
https://github.com/macports/macports-base.git
synced 2026-07-12 18:18:43 -07:00
port: add 'prefix' action to display the configured prefix
Adds a new `port prefix` command that prints MacPorts' installation prefix on stdout, unadorned, so it can be used directly in shell scripts. Closes: https://trac.macports.org/ticket/72961
This commit is contained in:
@@ -64,6 +64,7 @@ MAN1= \
|
||||
port-patch.1 \
|
||||
port-pkg.1 \
|
||||
port-platform.1 \
|
||||
port-prefix.1 \
|
||||
port-provides.1 \
|
||||
port-quit.1 \
|
||||
port-rdependents.1 \
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
'\" t
|
||||
.TH "PORT\-PREFIX" "1" "2\&.12\&.99" "MacPorts 2\&.12\&.99" "MacPorts Manual"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
port-prefix \- Print the prefix for which MacPorts was configured
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
.nf
|
||||
\fBport\fR \fBprefix\fR
|
||||
.fi
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
This command prints the installation prefix of your MacPorts installation, i\&.e\&., the directory under which MacPorts and all ports are installed\&. The prefix is set at configure time and defaults to \fI/opt/local\fR\&.
|
||||
.SH "GLOBAL OPTIONS"
|
||||
.sp
|
||||
Please see the section \fBGLOBAL OPTIONS\fR in the \fBport\fR(1) man page for a description of global port options\&.
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
\fBport\fR(1)
|
||||
.SH "AUTHORS"
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
(C) 2026 The MacPorts Project
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
@@ -0,0 +1,28 @@
|
||||
// vim: set et sw=4 ts=8 ft=asciidoc tw=80:
|
||||
port-prefix(1)
|
||||
==============
|
||||
|
||||
NAME
|
||||
----
|
||||
port-prefix - Print the prefix for which MacPorts was configured
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
[cmdsynopsis]
|
||||
*port* *prefix*
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This command prints the installation prefix of your MacPorts installation, i.e.,
|
||||
the directory under which MacPorts and all ports are installed. The prefix is
|
||||
set at configure time and defaults to '/opt/local'.
|
||||
|
||||
include::global-flags.txt[]
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
man:port[1]
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
(C) 2026 The MacPorts Project
|
||||
@@ -1077,6 +1077,11 @@ version
|
||||
Display the release number of the installed MacPorts infrastructure\&.
|
||||
.RE
|
||||
.PP
|
||||
prefix
|
||||
.RS 4
|
||||
Display the prefix for which MacPorts was configured\&.
|
||||
.RE
|
||||
.PP
|
||||
selfupdate
|
||||
.RS 4
|
||||
Updates the MacPorts system, ports tree(s) and base tools if needed, from the MacPorts rsync server, installing the newest infrastructure available\&.
|
||||
|
||||
@@ -539,6 +539,9 @@ mirror::
|
||||
version::
|
||||
Display the release number of the installed MacPorts infrastructure.
|
||||
|
||||
prefix::
|
||||
Display the prefix for which MacPorts was configured.
|
||||
|
||||
selfupdate::
|
||||
Updates the MacPorts system, ports tree(s) and base tools if needed, from
|
||||
the MacPorts rsync server, installing the newest infrastructure available.
|
||||
|
||||
@@ -2680,6 +2680,13 @@ proc action_platform { action portlist opts } {
|
||||
}
|
||||
|
||||
|
||||
proc action_prefix { action portlist opts } {
|
||||
global macports::prefix
|
||||
puts ${prefix}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
proc action_dependents { action portlist opts } {
|
||||
if {[require_portlist portlist]} {
|
||||
return 1
|
||||
@@ -4152,6 +4159,7 @@ set action_array [dict create \
|
||||
\
|
||||
version [list action_version [ACTION_ARGS_NONE]] \
|
||||
platform [list action_platform [ACTION_ARGS_NONE]] \
|
||||
prefix [list action_prefix [ACTION_ARGS_NONE]] \
|
||||
\
|
||||
uninstall [list action_uninstall [ACTION_ARGS_PORTS]] \
|
||||
\
|
||||
|
||||
@@ -35,6 +35,10 @@ set portpath .
|
||||
set portbuildpath ./build
|
||||
set macports::portdbpath .
|
||||
|
||||
set test_tclsh [file normalize [file join $macports::autoconf::top_srcdir tests test-tclsh]]
|
||||
set port_script [file normalize [file join $pwd .. .. port port.tcl]]
|
||||
testConstraint portClientAvailable [expr {[file executable $test_tclsh] && [file readable $port_script]}]
|
||||
|
||||
|
||||
test get_default_subport {
|
||||
Get default subport unit test.
|
||||
@@ -59,5 +63,13 @@ test get_subbuildpath {
|
||||
return "Get subbuild path successful."
|
||||
} -result "Get subbuild path successful."
|
||||
|
||||
test action_prefix {
|
||||
`port prefix` prints the configured prefix and nothing else.
|
||||
} -constraints {
|
||||
portClientAvailable
|
||||
} -body {
|
||||
exec -ignorestderr $test_tclsh $port_script prefix
|
||||
} -result $pwd/tmpdir
|
||||
|
||||
|
||||
cleanupTests
|
||||
|
||||
Reference in New Issue
Block a user