Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Relocatable install (enables fpm package build) #601

wants to merge 2 commits into from

9 participants


While not pretty, this patch adds features to so a package can be built using (tested for debian).

specialunderwear added some commits
@specialunderwear specialunderwear Added relative_path_if_relocatable.
Some packaging tools will install into a tmp directory and then create the package
out of this installation. Because of the tight coupling between configuration
paths and --root, we needed to add an extra option allowing us to ignore --root
for configuration paths.
@specialunderwear specialunderwear relocatable should be false by default. 952841a

@david-guenault @dguenault Can you look at this patch and see that it doesn't break anything. fpm is very cool and will help out in making packages, which is sorely lacking for Shinken.. Anything to make it easier is a Good Thing in my mind. :-) What do you think?


If you think this is a safe inclusion, this will be very good for 1.2.1. (I will tentatively mark it for 1.2)


It might be a little work to create a package that passes lintian checks. However FPM is GREAT for internal use and makes it super easy to create a package quickly on any commit. Which is very much needed in testing/hotfix envirinments. Since this patch is harmless, I'd really appreciate it if you'd accept it, whether you are going to use it or not.

Collaborator is used by packagers so you should ask before to hvad (fedora packaging) and others packagers. This only impact so i do not have any problem with it if it does not break existing usage


@baloo @hvad Any issue with this patch?


this might do more for confusion than good, imo there need to be an experienced debian maintainer which does the official package, It has to support debian file structure and software rules. Otherwise it would look very unprofessional. FPM is a great tool for "personal deb's" but an official .deb is also expected to follow file structure rules etc, simply package the software with this instead of .tar.gz is imo not a good solution, the best would be to attract a debian maintainer to chime in.


@kiranos exactly which rules are violated when a package is created with fpm?


no rules are violated per default, it all depends on how the packager uses the tool, if he places let say ui in /home/shinken instead of /usr/share/shinken etc, using a tool like fpm would make these issues easier to arise, as a more inexperienced maintainer would do it.

An experienced maintener which follows all rules would probably not need fpm to build the package :) I think its ok to use but not build an official shinken repo with it.


well the defaults yield a proper package so that is no problem.


I think this is really useful as long as it integrates without adverse side-effects. I could use an easy way of making .debs for this.


@baloo @hvad can we have you inputs on this? Thanks.



I think FPM can not make package acceptable to be included in distributions like Debian or Fedora / EPEL. I personally would not use it for this type of tool is never a good job but it makes it easier to hugly and quickly package. Version 1.2.2 of shinken in RPM is in the depot testing Fedora;-).



hvad. You make a good point, but what about enterprise users that want to make their own .deb packages. This would make it easier to have custom packages. I know quite a few admins that use this to much success.


I don't get the point with this patch. Why would you want to package as relocatable ? If you want to do such things and for "i want my own package"-usage, building with a relocatable virtualenv is the way to go:

virtualenv --relocatable env
. env/bin/activate
python install

Ship the directory, and that's it.

Pretty much as you would do with ruby/bundler for production usage.

I don't get the point of "relocating" but if it may help, here is how it's installed in debian package


The point is that the full install paths are written to the generated config files. With relocated enabled, the are kept at /etc/shinken

@naparuba naparuba closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 11, 2012
  1. @specialunderwear

    Added relative_path_if_relocatable.

    specialunderwear authored
    Some packaging tools will install into a tmp directory and then create the package
    out of this installation. Because of the tight coupling between configuration
    paths and --root, we needed to add an extra option allowing us to ignore --root
    for configuration paths.
  2. @specialunderwear
This page is out of date. Refresh to see the latest.
Showing with 35 additions and 11 deletions.
  1. +1 −0  setup.cfg
  2. +34 −11
1  setup.cfg
@@ -5,3 +5,4 @@ var-path=/var/lib/shinken
45 100644 → 100755
@@ -37,6 +37,7 @@
from setuptools import setup, find_packages
from glob import glob
import os
+import os.path
import itertools
import ConfigParser
@@ -116,6 +117,10 @@ class install(_install):
+ boolean_options = _install.boolean_options + [
+ 'relocatable'
+ ]
def initialize_options(self):
self.etc_path = None
@@ -125,6 +130,7 @@ def initialize_options(self):
self.plugins_path = None
self.owner = None = None
+ self.relocatable = None
def finalize_options(self):
@@ -142,6 +148,8 @@ def finalize_options(self):
self.owner = DEFAULT_OWNER
if is None: = DEFAULT_GROUP
+ if self.relocatable is None:
+ self.relocatable = False
if self.root:
for attr in ('etc_path', 'var_path', 'plugins_path', 'run_path', 'log_path'):
@@ -163,8 +171,9 @@ def initialize_options (self):
self.run_path = None
self.log_path = None
self.plugins_path = None
+ self.root = None
self._install_scripts = None
+ self.relocatable = None
self.owner = None = None
@@ -176,6 +185,8 @@ def finalize_options (self):
('install_scripts', '_install_scripts'),
+ ('relocatable', 'relocatable'),
+ ('root', 'root'),
('etc_path', 'etc_path'),
@@ -212,11 +223,11 @@ def generate_default_shinken_file(self):
buf =
# substitute
- buf = buf.replace("$ETC$", self.etc_path)
- buf = buf.replace("$VAR$", self.var_path)
- buf = buf.replace("$RUN$", self.run_path)
- buf = buf.replace("$LOG$", self.log_path)
- buf = buf.replace("$SCRIPTS_BIN$", self._install_scripts)
+ buf = buf.replace("$ETC$", relative_path_if_relocatable(self.relocatable, self.root, self.etc_path))
+ buf = buf.replace("$VAR$", relative_path_if_relocatable(self.relocatable, self.root, self.var_path))
+ buf = buf.replace("$RUN$", relative_path_if_relocatable(self.relocatable, self.root, self.run_path))
+ buf = buf.replace("$LOG$", relative_path_if_relocatable(self.relocatable, self.root, self.log_path))
+ buf = buf.replace("$SCRIPTS_BIN$", relative_path_if_relocatable(self.relocatable, self.root, self._install_scripts))
# write out the new file
f = open(outfile, "w")
@@ -259,7 +270,11 @@ def update_configfiles(self):
-""" % (self.owner,, self.var_path, self.run_path, dname))
+""" % (self.owner,
+ relative_path_if_relocatable(self.relocatable, self.root, self.var_path),
+ relative_path_if_relocatable(self.relocatable, self.root, self.run_path),
+ dname))
# And now the resource.cfg path with the value of libexec path
# Replace the libexec path by the one in the parameter file
@@ -269,7 +284,7 @@ def update_configfiles(self):'updating path in %s', outname)
update_file_with_string(inname, outname,
- self.plugins_path)
+ relative_path_if_relocatable(self.relocatable, self.root, self.plugins_path))
# And update the nagios.cfg file for all /usr/local/shinken/var
# value with good one
@@ -284,7 +299,10 @@ def update_configfiles(self):
-""" % (self.owner,, self.run_path, self.log_path)
+""" % (self.owner,
+ relative_path_if_relocatable(self.relocatable, self.root,self.run_path),
+ relative_path_if_relocatable(self.relocatable, self.root,self.log_path))
# UPDATE Shinken-specific.cfg files too
@@ -293,12 +311,13 @@ def update_configfiles(self):
outname = os.path.join(self.build_dir, name)
update_file_with_string(inname, outname,
- "/usr/local/shinken/var", self.var_path)
+ "/usr/local/shinken/var",
+ relative_path_if_relocatable(self.relocatable, self.root, self.var_path))
# And update the default log path too'updating log path in %s', outname)
update_file_with_string(inname, outname,
- "%s/nagios.log" % self.log_path)
+ "%s/nagios.log" % relative_path_if_relocatable(self.relocatable, self.root, self.log_path))
class install_config(Command):
@@ -402,6 +421,10 @@ def get_gid(group_name):
"Maybe you should create this group"
% group_name)
+def relative_path_if_relocatable(relocatable, root, path):
+ if relocatable:
+ return os.path.join('/', os.path.relpath(path, root))
+ return path
def ensure_dir_exist(f):
dirname = os.path.dirname(f)
Something went wrong with that request. Please try again.