Sei sulla pagina 1di 5

One of the great things about FreeBSD is the poudriere tool.

With it, you can create your own set of


customized packages for installation on your server. Today, I will be installing packages in a
FreeBSD 9.2 jail. Although I am installing in a jail, the same steps apply to any FreeBSD 9.2 host.
In this post, I will cover how to deliver the packages produced by poudriere. I have already written
about building custom package with poudriere. In this post, Ill show you how to deliver those
packages over http (via nginx) and how to install them.
I will start by configuring nginx to deliver
I will continue by configuring the empty system I created using ezjail.

nginx deliver
These steps are carried out on your poudriere server.
I installed nginx with this command:
pkg install nginx

My nginx file looks like this:


worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;
keepalive_timeout 65;

server {
listen 10.10.0.5:80;
server_name slocum.example.org;

root /usr/local/www/nginx-default/;

location /logs/ {
root /poudriere/data/;
autoindex on;
index index.html index.htm;
}

location /packages/ {
root /poudriere/data;
autoindex on;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;


location = /50x.html {
root /usr/local/www/nginx-dist;
}
}
}

The listen directive specifies an IP address because this host has multiple. The location directives
seen above point to pathnames determined when setting up poudriere. You can see how I did that in
my previous post.
You should enable ngnix by adding this to /etc/rc.conf:
nginx_enable="YES"

Then you can start ngnix with this command:


# service nginx start
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.

Now you should be able to view your build and your packages using the /log and /packages
directories in your browser.

/etc/resolv.conf
In my newly created jail, there is nothing configured. My first step is setting up /etc/resolv.conf so
DNS works. I added this to the file:
search example.com
nameserver 10.55.11.1

Your values must reflect your environment. Only you can decide what goes in your file.

Installing pkg
I am using FreeBSD 9.2, thus, I must install pkg by hand. I installed from the FreeBSD package
servers with this command:
# pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg please wait
_http._tcp.pkg.FreeBSD.org
Installing pkg-1.2.7... done
If you are upgrading from the old package format, first run:

# pkg2ng
Usage: pkg [-v] [-d] [-l] [-N] [-j |-c ] [-C ] [-R ] []

Global options supported:


-d Increment debug level
-j Execute pkg(8) inside a jail(8)
-c Execute pkg(8) inside a chroot(8)
-C Use the specified configuration file
-R Directory to search for individual repository
configurations
-l List available commands and exit
-v Display pkg(8) version
-N Test if pkg(8) is activated and avoid auto-activation

Commands supported:
add Registers a package and installs it on the system
annotate Add, modify or delete tag-value style annotations on
packages
audit Reports vulnerable packages
autoremove Removes orphan packages
backup Backs-up and restores the local package database
check Checks for missing dependencies and database consistency
clean Cleans old packages from the cache
config Display the value of the configuration options
convert Convert database from/to pkgng
create Creates software package distributions
delete Deletes packages from the database and the system
fetch Fetches packages from a remote repository
help Displays help information
info Displays information about installed packages
install Installs packages from remote package repositories
lock Locks package against modifications or deletion
plugins Manages plugins and displays information about plugins
query Queries information about installed packages
register Registers a package into the local database
remove Deletes packages from the database and the system
repo Creates a package repository catalogue
rquery Queries information in repository catalogues
search Performs a search of package repository catalogues
set Modifies information about packages in the local database
ssh ssh packages to be used via ssh
shell Opens a debug shell
shlib Displays which packages link against a specific shared
library
stats Displays package database statistics
unlock Unlocks a package, allowing modification or deletion
update Updates package repository catalogues
updating Displays UPDATING information for a package
upgrade Performs upgrades of packaged software distributions
version Displays the versions of installed packages
which Displays which package installed a specific file

Commands provided by plugins:

For more information on the different commands see 'pkg help '.
#

Configuring pkgng
The previous step installed /usr/local/etc/pkg.conf, but the contents are not needed for what we are
going to do. So I removed that file.
On FreeBSD 9.2, you must set this value in /etc/make.conf to ensure that the new pkg is used, as
opposed to the older commands:
WITH_PKGNG= yes

I then specified our custom FreeBSD repository by first issuing this command:
mkdir /etc/pkg

and then creating /etc/pkg/FreeBSD.conf with this contents:


FreeBSD: {
url: "pkg+http://slocum.example.org/packages/releng_9_2-HEAD-bacula",
mirror_type: "srv",
signature_type: "none",
fingerprints: "/usr/share/keys/pkg",
enabled: true
}

where slocum.example.org is the server which hosts your custom packages.

Installing the packages


Now you should be able to do this:
# pkg upgrade
Updating repository catalogue
digests.txz 100% 1188 1.2KB/s 1.2KB/s
00:00
packagesite.txz 100% 8920 8.7KB/s 8.7KB/s
00:00
Incremental update completed, 18 packages processed:
18 packages updated, 0 removed and 0 added.
Nothing to do

An install looks like this:


# pkg install bash
Updating repository catalogue
The following 1 packages will be installed:

Installing bash: 4.3.0_1

The installation will require 6 MB more space

0 B to be downloaded

Proceed with installing packages [y/N]: y


Checking integrity... done
[1/1] Installing bash-4.3.0_1...Updating /etc/shells
done

If you install a package, all dependencies will also be installed. For example:
# pkg install joe
Updating repository catalogue
digests.txz 100% 1292 1.3KB/s 1.3KB/s
00:00
packagesite.txz 100% 9708 9.5KB/s 9.5KB/s
00:00
Incremental update completed, 20 packages processed:
0 packages updated, 0 removed and 2 added.
The following 2 packages will be installed:

Installing aspell: 0.60.6.1_4


Installing joe: 3.7_2,1

The installation will require 6 MB more space

1 MB to be downloaded

Proceed with installing packages [y/N]: y


aspell-0.60.6.1_4.txz 100% 794KB 793.7KB/s 793.7KB/s
00:00
joe-3.7_2,1.txz 100% 315KB 315.3KB/s 315.3KB/s
00:00
Checking integrity... done
[1/2] Installing aspell-0.60.6.1_4... done
[2/2] Installing joe-3.7_2,1... done

Its fantastic.

Potrebbero piacerti anche