Version information
This version is compatible with:
- FreeBSD
Start using this module
Add this module to your Puppetfile:
mod 'ptomulik-portsutil', '0.1.3'
Learn more about managing modules with a PuppetfileDocumentation
ptomulik-portsutil
Table of Contents
Overview
This library contains extension modules for searching FreeBSD
ports(7) and
packages. It uses make search
command to search available ports and
portversion(1)
to query already installed packages. The portversion
is a part of the
port-maintenance-tools
package, which may be installed with
pkg install port-maintenance-tools
Both, the old pkg
and the new pkgng
databases are supported. The library also allows manipulating build options
(normally set with make config
) and determining other characteristics of
FreeBSD packaging system.
The library is developed primarily for ptomulik-portsng module, which implements ports provider for package resource.
Module Description
Library contents
The library contains the following ruby modules:
- Puppet::Util::PTomulik::Package::Ports::PortSearch - methods for searching ports INDEX,
- Puppet::Util::PTomulik::Package::Ports::PkgSearch - search installed packages,
- Puppet::Util::PTomulik::Package::Ports::Functions - common stuff used by other modules,
and the following classes:
- Puppet::Util::PTomulik::Package::Ports::Options - FreeBSD ports options (normally settable by make search),
- Puppet::Util::PTomulik::Package::Ports::PortRecord - represents single record from ports INDEX,
- Puppet::Util::PTomulik::Package::Ports::PkgRecord - single record from package database,
- Puppet::Util::PTomulik::Package::Ports::Record - superclass for PkgRecord and PortRecord
The module Puppet::Util::PTomulik::Package::Ports includes both the PortSearch and PkgSearch, so it may be used if you wish to have the functionality of both modules in your class.
Library functionality
The PortSearch module provides methods that facilitate searching ports
INDEX for information describing available ports. The PkgSearch module
provides method that facilitate searching the database of installed packages.
It supports the old pkg database format and the new pkgng. Search methods
in both modules are designed such that they yield one record for each package
found in database. The returned record is either PortRecord object (for
PortSearch) or PkgRecord (for PkgSearch). The record is basically a
{:field=>value}
hash (the record classes inherit from Hash), but it also
provides some additional methods (see API docs for details). Example fields
that may be found in a record are :name
, :pkgname
, :portorigin
, :path
,
etc..
Searches are customizable. You may, for example, specify what fields should be included in search results (in records).
You may search ports INDEX by
pkgname,
portname, by
portorigin, or (with a little
extra effort) perform a custom search by any key supported by the make search
command (see
ports(7)). You may
also perform a heuristic search by name without stating whether the name
represents pkgname, portname or portorigin (see API docs for
search_ports
method).
Installed packages may be searched by name (the list of names is passed directly portversion(1)). It's also easy to retrieve information about all installed packages.
When compiling FreeBSD ports, the user has possibility to set some build options with make config command. Here, the same build options may be easily manipulated with Options class. The Options object represents a set of options for a single port/package. The options are implemented as a hash with simple key/value validation and munging. They may be read from or written to options files - the ones that normally lay under /var/db/ports/.
Terms and definitions
This section explains few terms used across the documentation.
FreeBSD ports collection and its terminology
Ports and packages in FreeBSD may be identified by either portnames, pkgnames or portorigins. We use the following terminology when referring ports/packages:
- a string in form
'apache22'
or'ruby'
is referred to as portname - a string in form
'apache22-2.2.25'
or'ruby-1.8.7.371,1'
is referred to as a pkgname - a string in form
'www/apache22'
or'lang/ruby18'
is referred to as a port origin or portorigin
See http://www.freebsd.org/doc/en/books/porters-handbook/makefile-naming.html
Setup
What portsutil affects
This is just a library and shouldn't alter your system (it performs mostly read-only operations). The Options class writes ports options to options files, so the contents of options files may change if you save ones. The module uses Facter and some read-only shell commands to query information related to FreeBSD ports/packages.
Setup Requirements
You may need to enable pluginsync in your puppet.conf
.
Usage
See Reference.
Reference
The complete API documentation may be generated with yard as follows:
bundle exec rake yard
The generated documentation is written to doc/
. Note that this works only on
ruby >= 1.9.
Limitations
Nothing that could be currently mentioned.
Development
The project is held at github:
- https://github.com/ptomulik/puppet-portsutil Issue reports, patches, pull requests are welcome!
2016-09-18 Paweł Tomulik ptomulik@meil.pw.edu.pl
- added workarounds for options.local files not being handled by old ports
- converted execpipe and execute_command to module_functions
- removed .scripts directory 2016-09-17 Paweł Tomulik ptomulik@meil.pw.edu.pl
- release 0.1.2
- fix options_file_default_syntax to return :with_without instead of :with
- release 0.1.1
- fix parsing/generating file options in WITH/WITHOUT syntax
- release 0.1.0
- add support for ancient FreeBSDs (>=9.0) 2016-09-16 Paweł Tomulik ptomulik@meil.pw.edu.pl
- release 0.0.11
- fixed incompatibility with puppet 2.7 (execpipe) 2016-09-15 Paweł Tomulik ptomulik@meil.pw.edu.pl
- release 0.0.10
- fixed incompatibilities with ruby 1.8 2016-05-19 Paweł Tomulik ptomulik@meil.pw.edu.pl
- release 0.0.9 [created because 0.0.8 is deleted on forge.puppetlabs.com]
- release 0.0.8
- fixed path to ports in Vagrantfile
- release 0.0.7
- removed deprecated Modulefile
- Vagrantfile: provision freebsd with ports initialized
- correct .gitignore to be properly handled by "puppet module build"
- release 0.0.6
- added Vagrantfile to simplify manual testing on FreeBSD VMs
- added metadata.json to allow new features of forge.puppetlabs.com
- added few notes to README.rst 2016-03-18 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.0.5
- correct projects www address in Modulefile
- release 0.0.4
- run tests on travis-ci on more versions of ruby and puppet
- adjust tests to run smoothly on rspec 3.x
- cleaned up code 2016-03-18 Pavel N. Savenkov amentain@users.noreply.github.com
- updated options.rb to accept option names starting with a digit 2013-02-03 Pawel Tomulik ptomulik@meil.pw.edu.pl
- changed yardoc config to use github flavored markdown 2014-01-19 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.0.3
- fixed some links in README.md 2014-01-18 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.0.2
- fixed bug with withenv method
- release 0.0.1
- initial commit
Dependencies
- ptomulik/vash (>= 0.1.6)
Portsutil - puppet utility module for FreeBSD ports Copyright (C) 2013-2014 Paweł Tomulik <ptomulik@meil.pw.edu.pl>. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.