Install Packages on NetBSD 7.1 using pkgin
Many so-called GNU/Linux distributions provide a convenient way of searching, installing and upgrading software by using binary archives found on “repositories”. NetBSD, and more widely, all operating systems relying on pkgsrc have tools like pkg_add and pkg_delete, but those are unable to correctly handle binary upgrades, and sometimes even installation itself.
Traditionally installing packages or software on NetBSD is done through the pkgsrc collection which consists of more than 18,000 packages as of April 2018.Building and installing packages such as KDE, GNOME, the Apache HTTP Server or Perl is performed through the use of a system of makefiles. This can automatically fetch the source code, unpack, patch, configure, build and install the package such that it can be removed again later.
An alternative to compiling from source is to use a precompiled binary package. In either case, any prerequisites/dependencies will be installed automatically by the package system, without need for manual intervention.
This is the purpose of pkgin, to provide the user a convenient way to handle binary packages, using the same working mechanisms than tools like apt-get (on Debian/Ubuntu) or yum(Redhat/CentOS7)
Pkgin is available via github, pkgsrc-wip and is present in pkgsrc as pkgtools/pkgin.
In this tutorial,we will look at how to install pkgin and we will do that using pkgsrc.The system used in this tutorials has the following configuration
Hostname – server.example.com
IP Address – 192.168.234.152/24
Operating System – NetBSD 7.1
Step 1 :
We will first install the latest version pkgsrc.To download the latest pkgsrc stable tarball, run:
wget http://ftp.netbsd.org/pub/pkgsrc/stable/pkgsrc.tar.gz
or
ftp ftp://ftp.netbsd.org/pub/pkgsrc/stable/pkgsrc.tar.gz
Then, extract it with:
$ tar -xzf pkgsrc.tar.gz -C /usr
This will create the directory pkgsrc/ in /usr/ and all the package source will be stored under /usr/pkgsrc/.
This will time some time to complete.Time to get some cofee
step 2: Installation
After packages are extracted and stored in the /usr/pkgsrc
we will go ahead to install pkgin which can be found in the pkgtools.
We run the following commands:
cd /usr/pkgsrc/pkgtools/pkgin/
After changing into the directory, we will run the command below to install pkgin.
make install clean
This command will also take some time to complete,after which pkgin will be installed.
First thing to do before using pkgin is to setup a repository in the /usr/pkg/etc/pkgin/repositories.conf file :
echo http://ftp.fr.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/7.1/All/ > /usr/pkg/etc/pkgin/repositories.conf
Now you can build the initial database:
# pkgin update
This operation will download the pkg_summary(5) file from the repository and then populate the SQLite database.
Once this is completed, pkgin is fully functionnal.
step 3 : Testing
Pkgin is successfully and working perfectly.We can now use pkgin to install,update,upgrade,remove binary packages.
Few Usage examples are below:
List available packages:
# pkgin avail
List installed packages:
# pkgin list
Search for a regular expression in the database:
# pkgin search foo.*bar
Install a package and its dependencies:
# pkgin install foo
Install many packages and their dependencies:
# pkgin install foo bar baz
Remove a package and its reverse dependencies:
# pkgin remove foo
Upgrade a package:
# pkgin install foo
Remove orphan dependencies:
# pkgin autoremove
stay tuned for more articles on NetBSD
References:
http://pkgin.net/
https://en.wikipedia.org/wiki/NetBSD
https://www.netbsd.org/docs/software/packages.html