Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
raphink committed Oct 24, 2011
0 parents commit 2275650
Show file tree
Hide file tree
Showing 9 changed files with 1,201 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ChangeLog
@@ -0,0 +1,21 @@
0.04 (2009-07-24):
- let users deal with their own apt sources

0.03 (2007-09-17):
- do not use links anymore, create script to allow different configuration
directories for various pbuilders
- use "mkdir -p" execs to create root directories
- do not use virtual resources anymore, depend on the pbuilder::common class
instead for the package and group
- add $bindir, $confdir, $cachedir and $chrootdir arguments to the pbuilder
type

0.02 (2007-09-14):
- change lots of configuration directories
- manage multiple instances of pbuilder with virtual resources for general
files
- automatically create/update pbuilders
- add ensure argument to allow purging pbuilders

0.01 (2007-09-13):
Initial release
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions README
@@ -0,0 +1,115 @@
= Overview

Pbuilder is a building utility for Debian systems based on sbuild.


= Dependencies

This module is only tested on puppet master and client versions 0.24.7,
so it could be that it depends on that version (or higher).


= Reference

To use this module, drop it into your modules path.


= Classes

- pbuilder::common, included by the pbuilder definition


= Definitions

- pbuilder

== pbuilder

=== Parameters

The pbuilder type takes the following arguments :
- ensure: whether the pbuilder should be present
Possible values: "present", "absent"
Defaults to "present"
- release: the Debian/Ubuntu release to be used
(sarge/etch/lenny/dapper/feisty/gusty/etc.)
Defaults to $lsbdistcodename
- arch: the architecture of the pbuilder (i386, amd64, etc.)
Defaults to $architecture
- methodurl: the URL used to grab the packages from
(e.g. http://ftp.debian.org/debian)
Defaults to "" (not functional, only useful for "ensure => absent")
- site: a hash used to find the right apt.config directory
(in puppet://${server}/apt/${release}/${arch}/${site})
Defaults to "" (not functional, only useful for "ensure => absent")
- debbuildopts: the options to send to debuild (see `man dpkg-buildpackage`)
Defaults to "-b"
- bindmounts: a list of space-separated directories to bind-mount in the chroot
Defaults to ""
- bindir: where to put the pbuilder script
Defaults to "/usr/local/bin"
- chrootdir: where to put the basetgz tarball
Defaults to "/var/chroot/pbuilder"
- confdir: where to store the configuration for the script
Defaults to "/etc/pbuilder"
- cachedir: where to create the aptcache, build and result directories
Defaults to "/var/cache/pbuilder"


This module assumes the following directories:

Configuration:
- ${confdir}/$name : root for the pbuilder conf
- ${confdir}/$name/pbuilderrc : configuration file for the pbuilder
- ${confdir}/$name/apt.config : apt config file (including sources.list) for the pbuilder
- ${confdir}/$name/hooks : hooks for the pbuilder

Cache:
- ${cachedir}/$name : root for the pbuilder cache
- ${cachedir}/$name/aptcache : aptcache for the pbuilder
- ${cachedir}/$name/build : build directory for the pbuilder
- ${cachedir}/$name/result : result packages for the pbuilder

Chroot:
- ${chrootdir}/base_$name.tgz : compressed chroot for the pbuilder



=== Examples


==== Set a pbuilder using the release and architecture of the host

pbuilder { "feisty":
methodurl => "http://archive.ubuntu.com/ubuntu",
}


==== Destroy an old existing pbuilder

pbuilder { "dapper":
ensure => absent
}


==== Set an am64 pbuilder for the etch release, including sources in the .changes

pbuilder { "etch-amd64":
release => etch,
methodurl => "http://ftp.debian.org/debian",
debbuildopts => "-sa"
}



=== Important note

You have to provide a valid apt.config directory for your pbuilder.
You can use the apt class for that, and notify the private pbuilder_update Exec.


= Licence

Copyright © 2007-2009 Raphaël Pinson <raphink@gmail.com>
See the LICENSE file for the full license.

4 changes: 4 additions & 0 deletions TODO
@@ -0,0 +1,4 @@

TODO:
- manage sudo rules for pbuilder (depend on sudo module ?)
- add a $users argument to define users allowed to use pbuilder and add them to the pbuilder group??? not sure
49 changes: 49 additions & 0 deletions manifests/common.pp
@@ -0,0 +1,49 @@
# pbuilder puppet module
# See README for more infos
#
# Copyright © 2007 Raphaël Pinson <raphink@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#


# Class: pbuilder::common
#
# This class is imported from the pbuilder type. It manages generic resources for pbuilder.
#
# Parameters:
#
# Actions:
# Installs the pbuilder package and UNIX group.
#
# Requires:
#
# Sample Usage:
# include "pbuilder::common"
#
class pbuilder::common {

# Call this class from within the pbuilder definition


package { "pbuilder":
ensure => installed
}

group { "pbuilder":
ensure => present
}

}

180 changes: 180 additions & 0 deletions manifests/init.pp
@@ -0,0 +1,180 @@
# pbuilder puppet module
# See README for more infos
#
# Copyright © 2007 Raphaël Pinson <raphink@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# Define: pbuilder
#
# This definition provides a pbuilder resource.
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
define pbuilder ($ensure="present",
$release=$lsbdistcodename, $arch=$architecture, $methodurl="",
$debbuildopts="-b", $bindmounts="",
$bindir="/usr/local/bin", $chrootdir="/var/chroot/pbuilder",
$confdir="/etc/pbuilder", $cachedir="/var/cache/pbuilder") {


# Include commons (package and group)
include "pbuilder::common"

$script = "${bindir}/pbuilder-${name}"

# directories
$pbuilder_confdir = "${confdir}/${name}"
$pbuilder_cachedir = "${cachedir}/${name}"
$builddir = "${pbuilder_cachedir}/build"
$resultdir = "${pbuilder_cachedir}/result"
$aptcachedir = "${pbuilder_cachedir}/aptcache"

# conf
$pbuilderrc = "${pbuilder_confdir}/pbuilderrc"
$aptconfdir = "${pbuilder_confdir}/apt.config"
$hookdir = "${pbuilder_confdir}/hooks"

# base
$basetgz = "${chrootdir}/base_${name}.tgz"


case $ensure {
present: {
# LEGACY: ensure all the dirs exist recursively
# the file type can't do that yet
exec {
"confdir-${name}":
command => "/bin/mkdir -p ${pbuilder_confdir}",
creates => "${pbuilder_confdir}";
"bindir-${name}":
command => "/bin/mkdir -p ${bindir}",
creates => "$bindir";
"chrootdir-${name}":
command => "/bin/mkdir -p ${chrootdir}",
creates => "$chrootdir";
"cachedir-${name}":
command => "/bin/mkdir -p ${pbuilder_cachedir}",
creates => "$pbuilder_cachedir";
}

file {
$script:
ensure => present,
mode => 755,
content => template("pbuilder/script.erb"),
require => Exec["bindir-${name}"];
# $link:
# ensure => link,
# target => $script,
# require => Exec["bindir-${name}"];
[ $builddir, $resultdir, $aptcachedir ]:
ensure => directory,
require => Exec["cachedir-${name}"];
$aptconfdir:
ensure => directory,
recurse => true,
require => Exec["confdir-${name}"];
$hookdir:
ensure => directory,
recurse => true,
# TODO hookdir source
# source => "puppet://${server}/pbuilder/hookdir/${site}",
require => Exec["confdir-${name}"];
$pbuilderrc:
ensure => present,
content => template("pbuilder/pbuilderrc.erb"),
require => Exec["confdir-${name}"];

}

# apt::sources_list {
# "pbuilder-${name}-$operatingsystem":
# ensure => present,
# content => template("apt/${operatingsystem}/${operatingsystem}.list.erb"),
# confdir => "${aptconfdir}",
# require => [ File["$aptconfdir/sources.list.d"], Exec["confdir-${name}"] ];
# "pbuilder-${name}-Hebex":
# ensure => present,
# content => template("apt/${operatingsystem}/Hebex.list.erb"),
# confdir => "${aptconfdir}",
# require => [ File["$aptconfdir/sources.list.d"], Exec["confdir-${name}"] ],
# }

# create the pbuilder if it was not created yet
exec { "create_pbuilder_${name}":
command => "${script} create",
creates => $basetgz,
require => [ Package[pbuilder],
File[$script], File[$aptconfdir],
File[$pbuilderrc], File[$builddir], File[$aptcachedir],
Exec["chrootdir-${name}"]
]
}

# update the pbuilder if the config changes but only if $basetgz exists
exec { "update_pbuilder_${name}":
command => "${script} update --override-config",
onlyif => "/usr/bin/test -f ${basetgz}",
subscribe => [ File[$aptconfdir], File[$pbuilderrc] ],
refreshonly => true,
require => [ Package[pbuilder],
File[$script], File[$aptconfdir],
File[$pbuilderrc], File[$builddir], File[$aptcachedir],
Exec["chrootdir-${name}"]
]
}
}

absent: {
# clean pbuilder to be sure no proc/dev is mounted in $builddir
exec { "clean_pbuilder_${name}":
command => "${script} clean",
onlyif => "/usr/bin/test -f ${script}",
require => Package[pbuilder]
}

file {
# remove single files
[ $script, $pbuilderrc, $basetgz]:
require => Exec["clean_pbuilder_${name}"],
ensure => absent;
# recursively remove internal directories
[ $aptconfdir, $builddir, $resultdir, $aptcachedir ]:
require => Exec["clean_pbuilder_${name}"],
ensure => absent,
recurse => true,
force => true;
# recursively remove containing directories
[ $pbuilder_confdir, $pbuilder_cachedir ]:
require => [ Exec["clean_pbuilder_${name}"],
File[$script], File[$pbuilderrc],
File[$aptconfdir],
File[$builddir], File[$resultdir], File[$aptcachedir]
],
ensure => absent,
force => true;
}
}
}

}

0 comments on commit 2275650

Please sign in to comment.