.\" Copyright (c) 2006-2011 Doug Barton dougb@FreeBSD.org .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd December 12, 2011 .Dt PORTMASTER 8 .Os .Sh NAME .Nm portmaster .Nd manage your ports without external databases or languages .Sh SYNOPSIS Common Flags: .Op Fl -force-config CGHKgntvw [B|b] [f|i] [D|d] .Op Sy [[--packages|-P]|[--packages-only|-PP]] | [--packages-build] .Op Fl -packages-if-newer .Op Fl -delete-build-only .Op Fl -always-fetch .Op Fl -local-packagedir= .Op Fl -packages-local .Op Fl -delete-packages .Op Fl -no-confirm .Op Fl -no-term-title .Op Fl -no-index-fetch .Op Sy --index|--index-first|--index-only .Op Fl m Ar arguments for make .Op Fl x Ar glob pattern to exclude from building .Nm .Op Common Flags .Ar full name of port directory in /var/db/pkg .Nm .Op Common Flags .Ar full path to /usr/ports/foo/bar .Nm .Op Common Flags .Ar glob pattern of directories from /var/db/pkg .Pp PLEASE NOTE: Glob patterns now update every port that matches. This is a change from pre-version-2.3 behavior. .Pp .Nm .Op Common Flags .Op Fl -update-if-newer .Ar Multiple full names or paths from /usr/ports or /var/db/pkg, and/or multiple globs from /var/db/pkg .Nm .Op Common Flags . (Use in /usr/ports/foo/bar to build that port) .Nm .Op Common Flags .Fl a .Nm .Fl -show-work .Op Fl Gv .Op Fl m Ar args .Nm .Op Common Flags .Fl o Ar .Nm .Op Common Flags .Op Fl R .Fl r Ar name/glob of port in /var/db/pkg (can be specified more than once) .Nm .Fl l .Nm .Op --index-only [-t] .Fl L .Nm .Fl -list-origins .Nm .Op Fl -force-config|-G .Op Fl P|-PP .Op Fl aftv .Fl F .Nm .Op Fl n|y .Op Fl b .Op Fl D|d .Fl e Ar name/glob of a single port directory in /var/db/pkg .Nm .Op Fl n|y .Op Fl b .Op Fl D|d .Fl s .Nm .Op Fl n|y .Op Fl t .Fl -clean-distfiles .Nm .Op Fl n|y .Op Fl -index|-index-only .Fl -clean-packages .Nm .Op Fl n|y .Op Fl -index|-index-only .Op Fl v .Fl -check-depends .Nm .Op Fl n|y .Op Fl v .Fl -check-port-dbdir .Nm .Fl h|--help .Nm .Fl -version .Pp The .Qq glob patterns mentioned above are not regular expressions. For example: .Qq portmaster perl would match every port directory name in .Pa /var/db/pkg that fits the pattern .Qq /var/db/pkg/perl* . .Sh QUICK START GUIDE This manual contains a lot of valuable information about .Nm , and you should read the entire manual to give you a better idea about how it works and what choices are available to you. However in the interests of getting you started quickly please see the EXAMPLES section at the end of the manual. .Sh DESCRIPTION The .Nm utility is a tool for updating your ports. It does not use an external database to track what you have installed. Rather it uses the existing ports infrastructure, including what is located in .Pa /var/db/pkg . The focus of this tool is to keep the dependency tracking information for your ports up to date. This allows you to safely update a specific port without having to update all of the ports .Qq above it. In the rare case where you do need to recompile ports which depend on a port you are updating, the .Fl r option exists to accomplish this. .Pp By default .Nm updates the port you specify on the command line. This will occur whether there is a new version for it or not. It will first recurse through the port and all of its dependencies (if any) to handle any port OPTIONS via the 'make config' interface. You will be presented with an OPTIONS dialog if you have never built the port before, or if the OPTIONS have changed. You can force dialogs for all ports by using the .Fl -force-config option. .Pp While recursing through dependencies, if you are not using any of the .Fl -packages* options, a 'make checksum' process will be launched in the background to either verify that the correct distfiles are available or start downloading the new ones. If you stop .Nm with ^C, an attempt will be made to kill off the child processes started for this purpose. .Pp While checking dependencies if a port has CONFLICTS set they will be compared to your installed ports and if you already have an alternate version of the dependency that is required by the port you are building it will be used in place of the default dependency. .Pp When the config and dependency checking phase is over the user will be presented with a list of ports that will be installed and/or upgraded, and asked to approve before proceeding. This behavior can be suppressed with the .Fl -no-confirm option. .Pp If the dependency check does not find a port that needs updating that step will be skipped prior to building the port(s) specified on the command line. In addition to this optimization, information about up-to-date dependencies, choices made on which ports to build for interactive mode, and ports already visited for 'make config' are all cached to enhance performance and prevent duplicated efforts. .Pp While recursing through the dependencies, if a port is marked IS_INTERACTIVE this will be flagged. In the absence of this notification, under normal circumstances the only user interaction required after the port starts building is to answer questions about the deletion of stale distfiles. This can be eliminated with the .Fl d or .Fl D options. .Pp There are a number of .Fl -packages* options available to save the time that would normally be spent building the port(s). Users interested in a reasonable balance between speed of installation and maximum performance should consider the .Fl -packages-build option, perhaps combined with the .Fl -delete-build-only option. .Pp If there is no .Fl B option specified when updating an existing port, a backup package will be created before .Xr pkg_delete 1 is called. If you are using the .Fl b option, these packages can be found in a directory called .Qq portmaster-backup in the directory specified by the .Ev PACKAGES environment variable, usually .Pa /usr/ports/packages . If there is no .Fl b option specified, the backup package will be deleted once the new version of the port is successfully installed. If the installation fails for whatever reason, a helpful message will be printed, along with instructions on where to find the backup package. .Pp After the port is built, if the .Fl w option is being used, all shared libraries installed by the old port (if any) will be saved to .Pa /usr/local/lib/compat/pkg . After installation if there are any new files with the same names as those in .Pa /usr/local/lib/compat/pkg the old files will be deleted, and .Xr ldconfig 8 will be run via .Pa /etc/rc.d/ldconfig . .Pp After the new port is built, but before it is installed the runtime dependencies will be checked to make sure they are up to date. If the .Fl g option is used a package will be created for the new (or newly installed) version. .Pp When installing a port or using the .Fl -check-depends option, if there are other ports that depend on this port the dependent ports .Pa +CONTENTS file(s), and the .Pa +REQUIRED_BY file for the new port will be updated. .Pp At the conclusion of a successful installation, any .Pa pkg-message files that were installed, and a summary of the work performed will be displayed. If the .Fl -delete-build-only option is in use, those packages that were installed during the current run of .Nm AND were only ever listed as build dependencies during this run will be deleted. .Pp If something goes wrong during the process (e.g., a port build fails, a port is marked BROKEN) .Nm will report any work done successfully as described above, then exit. .Pp The question is often asked, .Dq Why is it not possible to proceed with the ports that do not have errors? The answer is that (unfortunately) .Nm is not omniscient, and cannot guess what resolution the user would like to have for this problem. Manual intervention is therefore required. .Sh OPTIONS The options are as follows: .Pp Common Flags: .Bl -tag -width F1 .It Fl -force-config run 'make config' for all ports (overrides -G) .It Fl C prevents 'make clean' from being run before building .It Fl G prevents 'make config' .It Fl H hide details of the port build and install in a log file .It Fl K prevents 'make clean' from being run after building .It Fl B prevents creation of the backup package for the installed port .It Fl b create and keep a backup package of an installed port .It Fl g create a package of the new port .It Fl n run through all steps, but do not make or install any ports .It Fl t recurse dependencies thoroughly, using all-depends-list. .Sy RECOMMENDED FOR USE ONLY WHEN NEEDED, NOT ROUTINELY. When applied to the .Fl -clean-distfiles option it allows a distfile to be kept if it matches any up to date port, not just the ones that are installed. .It Fl v verbose output .It Fl w save old shared libraries before deinstall .It [-R] Fl f always rebuild ports (overrides .Fl i ) .It Fl i interactive update mode -- ask whether to rebuild ports .It Fl D no cleaning of distfiles .It Fl d always clean distfiles .It Fl m Ar arguments for make any arguments to supply to .Xr make 1 .It Fl x avoid building or updating ports that match this pattern. Can be specified more than once. If a port is not already installed the exclude pattern will be run against the directory name from .Pa /usr/ports . .It Fl -no-confirm do not ask the user to confirm the list of ports to be installed and/or updated before proceeding .It Fl -no-term-title do not update the xterm title bar .It Fl -no-index-fetch skip fetching the INDEX file .It Fl -index use INDEX-[7-9] exclusively to check if a port is up to date .It Fl -index-first use the INDEX for status, but double-check with the port .It Fl -index-only do not try to use .Pa /usr/ports . For updating ports when no .Pa /usr/ports directory is present the .Fl PP|--packages-only option is required. See the ENVIRONMENT section below for additional requirements. .It Fl -delete-build-only delete ports that are build-only dependencies after a successful run, only if installed this run .It Fl -update-if-newer (only for multiple ports listed on the command line) do not rebuild/reinstall if the installed version is up to date .It Fl P|--packages use packages, but build port if not available .It Fl PP|--packages-only fail if no package is available. The .Fl PP option must stand alone on the command line. In other words, you cannot do .Fl PPav (for example). .It Fl -packages-build use packages for all build dependencies .It Fl -packages-if-newer use package if newer than installed even if the package is not the latest according to the ports tree .It Fl -always-fetch fetch package even if it already exists locally .It Fl -local-packagedir= where local packages can be found, will fall back to fetching if no local version exists. This option should point to the full path of a directory structure created in the same way that 'make package' (or the .Nm .Fl g option) creates it. I.e., the package files are contained in .Pa /All , there are LATEST_LINK symlinks in the .Pa /Latest directory, and symlinks to the packages in .Pa /All in the category subdirectories, such as .Pa /devel , .Pa /ports-mgmt , etc. .It Fl -packages-local use packages from .Fl -local-packagedir only .It Fl -delete-packages after installing from a package, delete it .El .Pp Features: .Bl -tag -width F1 .It Fl a check all ports, update as necessary .It Fl -show-work show what dependent ports are, and are not installed (implies .Fl t ) . .It Fl o Ar replace the installed port with a port from a different origin .It [-R] Fl r Ar name/glob of port directory in /var/db/pkg rebuild the specified port, and all ports that depend on it. The list of dependent ports is built according to origin (i.e., .Pa category/portname ) not by the version number of the installed port. So if you do .Nm .Fl r Ar fooport-1.23 and it is necessary to restart using .Fl R but the newly installed port is now fooport-1.24 you can do .Nm .Fl R Fl r Ar fooport-1.24 and it should pick up where you left off. The .Fl r option can be specified more than once. .It Fl R used with the .Fl r or .Fl f options to skip ports updated on a previous run. When used with .Fl r it will also prevent the rebuild of the parent port if it, and all of its dependencies are up to date. .It Fl l list all installed ports by category .It Fl L list all installed ports by category, and search for updates .It Fl -list-origins list directories from /usr/ports for root and leaf ports. This list is suitable for feeding to .Nm either on another machine or for reinstalling all ports. See EXAMPLES below. .It [--force-config|-G] [-aftv] Fl F fetch distfiles only .It Fl n answer no to all user prompts for the features below .It Fl y answer yes to all user prompts for the features below .It [-n|y] [-b] [-D|d] Fl e Ar name/glob of a single port directory in /var/db/pkg expunge a port using .Xr pkg_delete 1 , and optionally remove all distfiles. Calls .Fl s after it is done expunging in case removing the port causes a dependency to no longer be necessary. .It [-n|y] [-b] [-D|d] Fl s clean out stale ports that used to be depended on .It [-t] [-n] Fl -clean-distfiles recurse through the installed ports to get a list of distinfo files, then recurse through all files in .Pa /usr/ports/distfiles to make sure that they are still associated with an installed port. If not, offer to delete the stale file. With the .Fl t option a distfile is considered valid if it is in use by any port, not just those installed. .It [-t] .Fl y .Fl -clean-distfiles does the same as above, but deletes all files without prompting. .It [--index|--index-only] [-n] Fl -clean-packages offer to delete stale packages. The .Fl -index-only option is required if no ports tree is available. .It [--index|--index-only] .Fl y .Fl -clean-packages does the same as above, but deletes all out of date files without prompting. .It [-n|y] [-v] Fl -check-depends cross-check and update dependency information for all ports .It [-n|y] [-v] Fl -check-port-dbdir check for stale entries in .Pa /var/db/ports .It Fl h|--help display help message .It Fl -version display the version number .El .Sh ENVIRONMENT The directory pointed to by the .Ev PACKAGES variable (by default .Pa /usr/ports/packages ) will be used to store new and backup packages. When using 'make package' for the .Fl g option, the ports infrastructure will store packages in .Pa ${PACKAGES}/All , aka .Ev PKGREPOSITORY . When using the .Fl b option, .Nm stores its backup packages in .Pa ${PACKAGES}/portmaster-backup so that you can create both a backup package and a package of the newly installed port even if they have the same version. .Pp When using the .Fl -packages* options the package files will be downloaded to .Pa ${PACKAGES}/portmaster-download . .Nm will respect the .Ev PACKAGESITE and .Ev PACKAGEROOT (by default http://ftp.freebsd.org) variables. .Nm attempts to use both of these variables in the same way that .Xr pkg_add 1 does. .Pp The .Ev UPGRADE_TOOL variable is set to .Qq Nm , and the .Ev UPGRADE_PORT and .Ev UPGRADE_PORT_VER variables are set to the full package name string and version of the existing package being replaced, if any. .Pp When using the .Fl -index-only option the .Ev PACKAGES variable must be set to a directory where the superuser has write permissions. Other useful variables include: .Bd -literal MASTER_SITE_INDEX (default http://www.FreeBSD.org/ports/) FETCHINDEX (default fetch -am -o) INDEXDIR (default $PORTSDIR, or $TMPDIR for --index-only) INDEXFILE (default auto per FreeBSD version) .Ed .Pp If you use non-standard OPTIONS settings for package building and wish to use the .Fl -index-only option without a ports tree you must generate your own INDEX file so that the dependencies match. .Pp If you wish to customize your build environment on a per-port basis you might want to take a look at .Pa /usr/ports/ports-mgmt/portconf .Pp To log actions taken by .Nm along with a date/time stamp you can define .Ev PM_LOG in your rc file with the full path of the file you would like to log to. If running .Nm with .Xr sudo 8 (see below) then you should make sure that the file is writable by the unprivileged user. .Pp By default .Nm creates backup packages of installed ports before it runs .Xr pkg_delete 1 during an update. If that package creation fails it is treated as a serious error and the user is prompted. However for scripted use of .Nm this can be a problem. In situations where the user is ABSOLUTELY SURE that lack of a backup package should not be a fatal error .Ev PM_IGNORE_FAILED_BACKUP_PACKAGE can be defined to any value in the rc file. .Pp For those who wish to be sure that specific ports are always compiled instead of being installed from packages the .Ev PT_NO_INSTALL_PACKAGE variable can be defined in the .Xr make 1 environment, perhaps in .Pa /usr/local/etc/ports.conf if using .Pa /usr/ports/ports-mgmt/portconf , or in .Pa /etc/make.conf . This setting is not compatible with the .Fl PP/--packages-only option. .Sh FILES .Bl -tag -width "1234" -compact .It Pa /usr/local/etc/portmaster.rc .It Pa $HOME/.portmasterrc Optional system and user configuration files. The variables set in the script's getopts routine can be specified in these files to enable those options. These files will be read by the parent .Nm process, and all variables in them will be exported. If a .Pa portmaster.rc file is placed in the same directory as the .Nm script itself, it will be read as described above. .Pp .It Pa /var/db/pkg/*/+IGNOREME If this file exists for a port that is already installed, several things will happen: .Bl -tag -width F1 .It 1. The port will be ignored for all purposes. This includes dependency updates even if there is no directory for the port in .Pa /usr/ports and there is no entry for it in .Pa /usr/ports/MOVED . If the .Fl v option is used, the fact that the port is being ignored will be mentioned. .It 2. If using the .Fl L option, and a new version exists, the existence of the .Pa +IGNOREME file will be mentioned. .It 3. If you do a regular update of the port, or if the .Fl a option is being used you will be asked if you want to update the port anyway. .El .Pp .It Pa /var/db/pkg/*/PM_UPGRADE_DONE_FLAG Indicates to a subsequent .Fl a , .Fl f , or .Fl r run which includes the .Fl R option that a port has already been rebuilt, so it can be safely ignored if it is up to date. .Pp .It Pa /tmp/port_log-* If the .Fl H option is used, and the installation or upgrade is not successful, the results of the build and install will be saved in this file. Substitute the value of .Ev TMPDIR in your environment as appropriate. .El .Sh EXIT STATUS .Ex -std .Sh ADVANCED FEATURE: SU_CMD The ports infrastructure has limited support for performing various operations as an unprivileged user. It does this by defining SU_CMD, which is typically .Xr su 1 . In order to support complete management of your ports as an unprivileged user, escalating to .Qq root privileges only when necessary, .Nm can use .Xr sudo 1 to handle the escalated privileges. To accomplish this you must have the following directories configured so that the unprivileged user can access them: .Bl -tag -width F1 .It 1. WRKDIRPREFIX - This is usually set to Pa /usr/ports/category/port/work , however it is suggested that you configure another directory outside your ports tree for access by the unprivileged user, and assign this variable to that value in your .Pa /etc/make.conf . .It 2. DISTDIR - This is usually set to Pa /usr/ports/distfiles . This directory can be safely set up for access by the unprivileged user, or a new directory can be specified as above. .It 3. TMPDIR - Usually Pa /tmp , but can also be set to another directory in your shell environment if desired. .El .Pp It is further assumed that the following directories will be owned by root: .Bl -tag -width F1 .It Pa /var/db/pkg .It Pa /var/db/ports .It LOCALBASE - Usually Pa /usr/local .It PACKAGES - Usually Pa /usr/ports/packages .It PKGREPOSITORY - Usually Pa ${PACKAGES}/All .El .Pp You will then need to install and configure .Xr sudo 1 . This can easily be done with .Pa /usr/ports/security/sudo . Then you will need to define PM_SU_CMD in your .Pa /etc/portmaster.rc file, or your .Pa $HOME/.portmasterrc file. For example: .Pp .Dl "PM_SU_CMD=/usr/local/bin/sudo" .Pp You can optionally define the PM_SU_VERBOSE option as well to notify you each time .Nm uses the PM_SU_CMD. This is particularly useful if you are experimenting with a tool other than .Xr sudo 1 to handle the privilege escalation, although at this time .Xr sudo 1 is the only supported option. .Pp PLEASE NOTE: You cannot upgrade the .Xr sudo 1 port itself using this method. .Sh EXAMPLES The following are examples of typical usage of the .Nm command: .Pp Update one port: .Dl "portmaster fooport-1.23 or" .Dl "portmaster fooport or" .Dl "portmaster foo/fooport" .Pp Use a package if available: .Dl "portmaster --packages fooport-1.23" .Pp Update multiple ports: .Dl "portmaster fooport-1.23 barport baz/blahport" .Pp Build a port locally but use packages for build dependencies, then delete the build dependencies when finished: .Dl "portmaster --packages-build --delete-build-only fooport-1.23" .Pp Update a system using only packages that are available locally: .Dl "portmaster -PP --local-packagedir= -a" .Pp Update all ports that need updating: .Dl "portmaster -a" .Pp Update all ports that need updating, and delete stale distfiles after the update is done: .Dl "1. portmaster -aD" .Dl "2. portmaster --clean-distfiles" .Pp More complex tasks (please see the details for these options above): .Dl "portmaster -r fooport-1.23" .Dl "portmaster -r fooport-1.23 -r barport-2.34" .Dl "portmaster -o emulators/linux_base-fc4 linux_base-8-8.0_15" .Dl "portmaster -a -x gstreamer -x linux" .Pp Print only the ports that have available updates. This can be used as an alias in your shell. Be sure to fix the line wrapping appropriately. .Dl "portmaster -L |" .Dl "egrep -B1 '(ew|ort) version|Aborting|installed|dependencies|" .Dl "IGNORE|marked|Reason:|MOVED|deleted|exist|update' | grep -v '^--'" .Pp Using .Nm to do a complete reinstallation of all your ports: .Dl "1. portmaster --list-origins > ~/installed-port-list" .Dl "2. Update your ports tree" .Dl "3. portmaster -ty --clean-distfiles" .Dl "4. portmaster --check-port-dbdir" .Dl "5. portmaster -Faf" .Dl "6. pkg_delete -a" .Dl "7. rm -rf /usr/local/lib/compat/pkg" .Dl "8. Back up any files in /usr/local you wish to save," .Dl " such as configuration files in /usr/local/etc" .Dl "9. Manually check /usr/local and /var/db/pkg" .Dl " to make sure that they are really empty" .Dl "10. Re-install portmaster" .Dl "11. portmaster `cat ~/installed-port-list`" .Pp You probably want to use the -D option for the installation and then run --clean-distfiles [-y] again when you are done. You might also want to consider using the --force-config option when installing the new ports. .Pp Alternatively you could use .Nm Fl a Fl f Fl D to do an .Dq in place update of your ports. If that process is interrupted for any reason you can use .Nm Fl a Fl f Fl D Fl R to avoid rebuilding ports already rebuilt on previous runs. However the first method (delete everything and reinstall) is preferred. .Sh SEE ALSO .Xr make 1 , .Xr pkg_add 1 , .Xr pkg_delete 1 , .Xr su 1 , .Xr ports 7 , .Xr ldconfig 8 , .Xr sudo 8 .Sh AUTHORS This manual page was written by .An Doug Barton .