Difference between revisions of "Pkg"

From GhostBSD Wiki
Jump to: navigation, search
(For more Information)
 
(35 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{:Navbar Application Management}}
 
{{:Navbar Application Management}}
 
{{Maintenance}}
 
  
 
== Introduction ==
 
== Introduction ==
  
The package manager pkg is a powerful tool to manipulate pre-compiled copies of all the commands for an application, as well as any configuration files and documentation.  
+
'''pkg''' is the FreeBSD package management tools, offering many features that make dealing with binary packages faster and easier.
 +
See [https://www.freebsd.org/cgi/man.cgi?query=pkg&sektion=8&manpath=freebsd-release-ports '''pkg(8)''']
  
While the two technologies ports and packages are similar, each have their own strengths. Select the technology that meets your requirements for installing a particular application.
 
 
Package Benefits
 
Package Benefits
  
Line 16: Line 14:
 
* Packages do not require any understanding of the process involved in compiling software on FreeBSD.
 
* Packages do not require any understanding of the process involved in compiling software on FreeBSD.
  
Sorce: [https://www.freebsd.org/doc/handbook/ports-overview.html 4.2. Overview of Software Installation]
+
==Overview About PKG Commands==
 +
 
 +
{|class="wikitable" style="width:95%;background:#FFFFFF; border:2px solid #008000;text-align:left;padding: 10px"
 +
|-
 +
! scope="col" style="width: 50px;"|'''Command'''
 +
! scope="col" style="width: 550px;"|'''Explanation'''
 +
|-
 +
|help ''command''
 +
|Display usage information of the specified command.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-add&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports add]   
 +
|Install a package from either a local source or a remote one.<br/>When installing from remote source you need to specify the proto-<br/> col to use when fetching the package.<br/>
 +
Currently supported protocols are FTP, HTTP and HTTPS.<br/>
 +
annotate:  Add, modify or delete tag-value style annotations on packages.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-alias&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports alias]
 +
|display configured aliases
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-annotate&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports annotate]
 +
|Add, modify or delete arbitrary annotations from packages
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-audit&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports audit] 
 +
|Audit installed packages against known vulnerabilities.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-autoremove&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports autoremove]
 +
|Delete packages which were automatically installed as dependen-<br/>cies and are not required any more.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-backup&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports backup] 
 +
|Dump the local package database to a file specified on the command-line.
 +
|-
 +
|bootstrap
 +
|This is for compatibility with the pkg(7) bootstrapper. If pkg is already installed, nothing is done. If invoked with the -f flag an attempt will be made to reinstall pkg from remote repository.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-check&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports check] 
 +
|Sanity checks installed packages.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-clean&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports clean] 
 +
|Clean the local cache of fetched remote packages.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-config&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports config]
 +
|retrieve the value of a given configuration option
 +
|-
 +
|convert    
 +
|Convert to and from the old pkg_add(1) format.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-create&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports create] 
 +
|Create a package, a utility for creating software package distributions.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-delete&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports delete] 
 +
|Delete a package from the database and the system.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-fetch&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports fetch] 
 +
|Fetch packages from a remote repository.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-info&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports info]   
 +
|Display information about installed packages.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-install&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports install]    
 +
|Install a package from a remote package repository.  If a package is found in more than one remote repository, then installation happens from the first one.  Downloading a package is tried from each package repository in turn, until the package is successfully fetched.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-lock&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports lock]   
 +
|Prevent modification or deletion of a package, lock or unlock packages.
 +
|-
 +
|plugins    
 +
|List the available plugins.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-query&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports query] 
 +
|Query information about installed packages.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-register&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports register]   
 +
|Register a package in the database.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-repo&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports repo]   
 +
|Create a local package repository for remote usage.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-rquery&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports rquery] 
 +
|Query information for remote repositories.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-search&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports search] 
 +
|Search for the given pattern in the remote package repositories.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-set&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports set]   
 +
|Modify information in the installed database.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-shell&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports shell] 
 +
|Open a SQLite shell to the local or remote database.  Extreme
 +
    care should be taken when using this command.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-shlib&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports shlib] 
 +
|Displays which packages link to a specific shared library.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-stats&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports stats] 
 +
|Display package database statistics.
 +
|-
 +
|unlock 
 +
|Unlocks packages, allowing them to be modified or deleted.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-update&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports update] 
 +
|Update the available remote repositories as listed <br/>in /usr/local/etc/pkg/repos/GhostBSD.conf
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-updating&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports updating]   
 +
|Display UPDATING entries of installed packages.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-upgrade&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports upgrade]    
 +
|Upgrade a package to a newer version.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-version&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports version]   
 +
|Summarize installed versions of packages.
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-which&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports which] 
 +
|Query the database for package(s) that installed a specific file.
 +
|-
 +
!colspan="2"|'''See also'''
 +
|-
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg_printf&sektion=3&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports pkg_printf]
 +
|family of functions produces output of package data according to a format
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg_repos&sektion=3&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports pkg_repos()]
 +
|Takes the address of a pointer to the repository
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg-repository&sektion=5&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports package repository]
 +
|format and operation of package repositories used by pkg(8)
 +
|-
 +
|[https://www.freebsd.org/cgi/man.cgi?query=pkg.conf&sektion=5&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports pkg.conf]
 +
|system-wide configuration file for pkg, default location of this file is /usr/local/etc/pkg.conf
 +
|}
 +
 
 +
== Function and Examples ==
 +
 
 +
A package can be manipulated with the [https://www.freebsd.org/cgi/man.cgi?query=pkg&sektion=8&manpath=freebsd-release-ports pkg(8)] commands, such as ''pkg install''.
 +
 
 +
pkg only works with binary packages. By default, pkg uses the binary packages from the GhostBSD package mirrors.
 +
 
 +
Each pkg command argument is documented in a command-specific manual page. To read the manual page for pkg install, for example, run either of these commands:
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg&sektion=8&manpath=freebsd-release-ports#COMMANDS # pkg help] install</code>
 +
 
 +
or
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-install&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports # man pkg-install]</code>
 +
 
 +
===Installing Packages===
 +
 
 +
To install a binary package use the following command, where packagename is the name of the package to install:
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-install&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports # pkg install] packagename</code>
 +
 
 +
This command uses repository data to determine which version of the software to install and if it has any uninstalled dependencies.
 +
 
 +
=== Removing Packages===
 +
 
 +
Packages that are no longer needed can be removed with pkg delete. For example:
 +
 
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-delete&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports # pkg delete] packagename</code>
 +
 
 +
===Upgrading Installed Packages===
 +
 
 +
Update the local package repository index
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-update&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports # pkg update]</code>
 +
 
 +
Installed packages can be upgraded to their latest versions by running:
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-upgrade&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports # pkg upgrade]</code>
 +
 
 +
This command will compare the installed versions with those available in the repository catalogue and upgrade them from the repository.
 +
 
 +
If  a kernel has to be upgraded, you have to do a forced upgrade. It is needed that all packages have to be reinstalled, so that all the package are compiled with the right kernel.
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-update&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports # pkg update -f]</code>
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-upgrade&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports # pkg upgrade -fy]</code>
 +
 
 +
===Not Updating A Package===
 +
 
 +
If you have got an application via the ports system and don't like to change it during ''pkg upgrade'' process, do
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-lock&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports #pkg lock] packagename</code>
 +
 
 +
===To Get Info About An Installed Package===
 +
 
 +
If you like to know if a package is installed and which version, you have to write:
 +
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-info&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports pkg info] packagename</code>
 +
 
 +
===Auditing Installed Packages===
 +
 
 +
Software vulnerabilities are regularly discovered in third-party applications. To address this, pkg includes a built-in auditing mechanism. To determine if there are any known vulnerabilities for the software installed on the system, run:
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-audit&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports # pkg audit -F]</code>
 +
 
 +
{|class="wikitable" style="width:95%;background:#FFFFFF; border:2px solid #008000;text-align:left;padding: 10px"
 +
|-
 +
! scope="col" style="width: 100px;"|
 +
! scope="col" style="width: 100px;"|
 +
! scope="col" style="width: 500px;"|
 +
|-
 +
|<nowiki>-</nowiki>F,
 +
|<nowiki>--</nowiki>fetch    
 +
|Fetch the database before checking.
 +
|-
 +
|}
 +
 
 +
===Automatically Removing Unused Packages===
 +
 
 +
Removing a package may leave behind dependencies which are no longer required. Unneeded packages that were installed as dependencies (leaf packages) can be automatically detected and removed using:
 +
 
 +
<code>[https://www.freebsd.org/cgi/man.cgi?query=pkg-autoremove&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports # pkg autoremove]</code>
 +
 
 +
===Repositories===
 +
 
 +
The pkg mirrors are located in: 
 +
* in the US: http://pkg.us.ghostbsd.org/stable/FreeBSD:12:amd64/
 +
* in France: http://pkg.fr.ghostbsd.org/stable/FreeBSD:12:amd64/
 +
* in Cynyda: http://pkg.ghostbsd.org/stable/FreeBSD:12:amd64/
  
== Funktion ==
+
To change the mirror go to the file <code>/etc/pkg/GhostBSD.conf</code> and change the URL. <br/>
 +
There in it is described as:
  
A package can be manipulated with the [https://www.freebsd.org/cgi/man.cgi?query=pkg&sektion=8&manpath=freebsd-release-ports pkg(8)] commands, such as pkg install.
+
* in France: <code> url: "http://pkg.fr.ghostbsd.org/stable/${ABI}/latest",</code>
 +
* in Canada: <code> url: "http://pkg.ca.ghostbsd.org/stable/${ABI}/latest",</code>
 +
* in US:  <code> url: "http://pkg.us.ghostbsd.org/stable/${ABI}/latest",</code>
  
 +
For upgrading your system chose the nearest mirror to your location.
  
 +
== For more Information ==
  
== For more Information read ==
+
Sources:
  
 +
* [https://www.freebsd.org/doc/handbook/pkgng-intro.html FreeBSD Handbook/chapter 4.4. Using pkg for Binary Package Management]
 +
* [https://www.vultr.com/docs/how-to-use-the-pkg-package-manager-on-freebsd-12 VULTR]
  
  

Latest revision as of 09:19, 19 November 2020

Application Management
pkg Software Station Update Station Ports Applications
Back to the Icon Disti GhostBSD.pngWiki

Introduction[edit]

pkg is the FreeBSD package management tools, offering many features that make dealing with binary packages faster and easier. See pkg(8)

Package Benefits

  • A compressed package tarball is typically smaller than the compressed tarball containing the source code for the application.
  • Packages do not require compilation time. For large applications, such as Mozilla, KDE, or GNOME, this can be important on a slow system.
  • Packages do not require any understanding of the process involved in compiling software on FreeBSD.

Overview About PKG Commands[edit]

Command Explanation
help command Display usage information of the specified command.
add Install a package from either a local source or a remote one.
When installing from remote source you need to specify the proto-
col to use when fetching the package.

Currently supported protocols are FTP, HTTP and HTTPS.
annotate: Add, modify or delete tag-value style annotations on packages.

alias display configured aliases
annotate Add, modify or delete arbitrary annotations from packages
audit Audit installed packages against known vulnerabilities.
autoremove Delete packages which were automatically installed as dependen-
cies and are not required any more.
backup Dump the local package database to a file specified on the command-line.
bootstrap This is for compatibility with the pkg(7) bootstrapper. If pkg is already installed, nothing is done. If invoked with the -f flag an attempt will be made to reinstall pkg from remote repository.
check Sanity checks installed packages.
clean Clean the local cache of fetched remote packages.
config retrieve the value of a given configuration option
convert Convert to and from the old pkg_add(1) format.
create Create a package, a utility for creating software package distributions.
delete Delete a package from the database and the system.
fetch Fetch packages from a remote repository.
info Display information about installed packages.
install Install a package from a remote package repository. If a package is found in more than one remote repository, then installation happens from the first one. Downloading a package is tried from each package repository in turn, until the package is successfully fetched.
lock Prevent modification or deletion of a package, lock or unlock packages.
plugins List the available plugins.
query Query information about installed packages.
register Register a package in the database.
repo Create a local package repository for remote usage.
rquery Query information for remote repositories.
search Search for the given pattern in the remote package repositories.
set Modify information in the installed database.
shell Open a SQLite shell to the local or remote database. Extreme

care should be taken when using this command.

shlib Displays which packages link to a specific shared library.
stats Display package database statistics.
unlock Unlocks packages, allowing them to be modified or deleted.
update Update the available remote repositories as listed
in /usr/local/etc/pkg/repos/GhostBSD.conf
updating Display UPDATING entries of installed packages.
upgrade Upgrade a package to a newer version.
version Summarize installed versions of packages.
which Query the database for package(s) that installed a specific file.
See also
pkg_printf family of functions produces output of package data according to a format
pkg_repos() Takes the address of a pointer to the repository
package repository format and operation of package repositories used by pkg(8)
pkg.conf system-wide configuration file for pkg, default location of this file is /usr/local/etc/pkg.conf

Function and Examples[edit]

A package can be manipulated with the pkg(8) commands, such as pkg install.

pkg only works with binary packages. By default, pkg uses the binary packages from the GhostBSD package mirrors.

Each pkg command argument is documented in a command-specific manual page. To read the manual page for pkg install, for example, run either of these commands:

# pkg help install

or

# man pkg-install

Installing Packages[edit]

To install a binary package use the following command, where packagename is the name of the package to install:

# pkg install packagename

This command uses repository data to determine which version of the software to install and if it has any uninstalled dependencies.

Removing Packages[edit]

Packages that are no longer needed can be removed with pkg delete. For example:


# pkg delete packagename

Upgrading Installed Packages[edit]

Update the local package repository index

# pkg update

Installed packages can be upgraded to their latest versions by running:

# pkg upgrade

This command will compare the installed versions with those available in the repository catalogue and upgrade them from the repository.

If a kernel has to be upgraded, you have to do a forced upgrade. It is needed that all packages have to be reinstalled, so that all the package are compiled with the right kernel.

# pkg update -f

# pkg upgrade -fy

Not Updating A Package[edit]

If you have got an application via the ports system and don't like to change it during pkg upgrade process, do

#pkg lock packagename

To Get Info About An Installed Package[edit]

If you like to know if a package is installed and which version, you have to write:

pkg info packagename

Auditing Installed Packages[edit]

Software vulnerabilities are regularly discovered in third-party applications. To address this, pkg includes a built-in auditing mechanism. To determine if there are any known vulnerabilities for the software installed on the system, run:

# pkg audit -F

-F, --fetch Fetch the database before checking.

Automatically Removing Unused Packages[edit]

Removing a package may leave behind dependencies which are no longer required. Unneeded packages that were installed as dependencies (leaf packages) can be automatically detected and removed using:

# pkg autoremove

Repositories[edit]

The pkg mirrors are located in:

To change the mirror go to the file /etc/pkg/GhostBSD.conf and change the URL.
There in it is described as:

For upgrading your system chose the nearest mirror to your location.

For more Information[edit]

Sources: