Difference between revisions of "Pkg"

From GhostBSD Wiki
Jump to: navigation, search
(More Differences between pkg and pkgng)
Line 1: Line 1:
 
{{:Navbar Application Management}}
 
{{:Navbar Application Management}}
  
== Explanation ==
+
== Introduction ==
 +
 
 +
'''pkgng''' is the next generation replacement for the traditional FreeBSD package management tools, offering many features that make dealing with binary packages faster and easier. [[File:Icon FreeBSD.png|50px|link=https://www.freebsd.org/doc/handbook/pkgng-intro.html]]
  
 
For beginners with GhostBSD it is a bit confusing which package manager is now working on my computer.
 
For beginners with GhostBSD it is a bit confusing which package manager is now working on my computer.
  
For now '''pkgng''' is like a synonym for '''pkg'''.   
+
For now pkgng is a synonym for pkg. It emphasize, that the package manager '''pkgng'''   is a new  version from '''pkg''' and is designed to work with versions of FreeBSD starting with 10.X. [https://www.freebsd.org/doc/handbook/pkgng-intro.html see also 4.4.1. Getting Started with pkg on the FreeBSD Handbook]. The differences between pkg and pkgng are described on page [[pkg#More Differences between pkg and pkgng|pkg]]
 +
 
 +
    '''Important:''' Once the package database has been converted to the new pkg format, <br/>the traditional pkg_* tools should no longer be used. <br/>And from this time on is '''pkg''' the name of the new generation package manager.
 +
 
 +
The new generation package manager [https://www.freebsd.org/cgi/man.cgi?query=pkg&sektion=8&manpath=freebsd-release-ports '''pkg(8)'''] is a powerful tool to manipulate pre-compiled copies of all the commands for an application, as well as any configuration files and documentation.
 +
 
 +
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
 +
 
 +
* 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.
 +
 
 +
Sorce: [[File:Icon FreeBSD.png|50px|link=https://www.freebsd.org/doc/handbook/ports-overview.html]]'''Handbook: 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/TrueOS package mirrors.
 +
 
 +
"GhostBSD now use TrueOS packages base from ports." See: [https://ghostbsd.org/19.09_release_announcement What changed since 19.04].
 +
 
 +
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 catalogues of the enabled package repositories
 +
 
 +
<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.
 +
 
 +
===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 France: <code>http://pkg.fr.ghostbsd.org/stable/FreeBSD:12:amd64/</code>
 +
* in Canada: <code>http://pkg.ghostbsd.org/stable/FreeBSD:12:amd64/</code>
 +
* in US:  <code>http://pkg.us.ghostbsd.org/stable/FreeBSD:12:amd64/</code>
 +
 
 +
For upgrading your system chose the nearest mirror to your location.
  
It describes, that the package manager [[pkgng]]  is a new  version and designed to work with versions of FreeBSD starting with 10.X. [https://www.freebsd.org/doc/handbook/pkgng-intro.html see also 4.4.1. Getting Started with pkg on the FreeBSD Handbook]
+
To change the mirror go to the file <code>/usr/local/etc/pkg/repos/GhostBSD.conf</code> and change the URL.
  
That means:
+
== For more Information ==
  
To install a package '''with the older version of pkg''' you had to write:
+
Source: *[https://www.freebsd.org/doc/handbook/pkgng-intro.html FreeBSD Handbook/chapter 4.4. Using pkg for Binary Package Management]
<code>pkg_add package name</code>
+
With the '''new generation of pkg''' you have to write:
+
<code>pkg install package name</code>
+
  
== More Differences between pkg and pkgng ==
 
  
If you like to know more about the differences between pkg (old version) and pkgng (new generation) please look in the [https://wiki.freebsd.org/PkgPrimer FreeBSD Wiki]
 
  
For the future: If we speak from pkg, than it means the new generation. And all further instructions you will find there: [[pkgng]].
 
  
  
  
 
[[Category:Application Management]]
 
[[Category:Application Management]]

Revision as of 00:23, 24 February 2020

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

Introduction

pkgng is the next generation replacement for the traditional FreeBSD package management tools, offering many features that make dealing with binary packages faster and easier. Icon FreeBSD.png

For beginners with GhostBSD it is a bit confusing which package manager is now working on my computer.

For now pkgng is a synonym for pkg. It emphasize, that the package manager pkgng is a new version from pkg and is designed to work with versions of FreeBSD starting with 10.X. see also 4.4.1. Getting Started with pkg on the FreeBSD Handbook. The differences between pkg and pkgng are described on page pkg

   Important: Once the package database has been converted to the new pkg format, 
the traditional pkg_* tools should no longer be used.
And from this time on is pkg the name of the new generation package manager.

The new generation package manager pkg(8) is a powerful tool to manipulate pre-compiled copies of all the commands for an application, as well as any configuration files and documentation.

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

  • 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.

Sorce: Icon FreeBSD.pngHandbook: 4.2. Overview of Software Installation

Overview About PKG Commands

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

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/TrueOS package mirrors.

"GhostBSD now use TrueOS packages base from ports." See: What changed since 19.04.

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

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

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


# pkg delete packagename

Upgrading Installed Packages

Update the local catalogues of the enabled package repositories

# 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.

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

#pkg lock packagename

To Get Info About An Installed Package

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

pkg info packagename

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:

# pkg audit -F

-F, --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:

# pkg autoremove

Repositories

The pkg mirrors are located in:

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

To change the mirror go to the file /usr/local/etc/pkg/repos/GhostBSD.conf and change the URL.

For more Information

Source: *FreeBSD Handbook/chapter 4.4. Using pkg for Binary Package Management