Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debian Package Creation- How to install configuration files?

I've been really stuck on this minor (I'm sure) issue so any help would be greatly appreciated. I've created a standard ubuntu package with dh_make. The purpose of this package is to create a package that will set up all the ldap related packages that a system needs including it's configuration. One of the steps I'm trying to do is to copy over an /etc/ldap.conf file while making a backup of the existing file. How do I do this? I tried to create a postinst script that looks essentially like the following, but I'm not clear on how the package stores the files and I get an error saying missing etc/ldap.conf file. What's the best way to do this? Here is my postinst script:

#!/bin/bash -xv

install -v -b etc/ldap.conf /etc/ldap.conf  > /tmp/tst 2>&1

Here is my skeleton structure:

    root@hqd-clientb-16:~/navldapubuntu-0.1/debian# tree


     ├── changelog
     ├── compat
     ├── control
     ├── copyright
     ├── docs
     ├── etc
        └── ldap.conf
     ├── install
     ├── postinst
     ├── README.Debian
     ├── README.source
     ├── rules
     ├── source
       └── format
     ├── navldapubuntu
       └── etc
     ├── navldapubuntu.debhelper.log
     ├── navldapubuntu.dirs
     └── navldapubuntu.doc-base.EX

Here's some additional information of the package I created.

    dpkg --contents tnoldapubuntu_0.1-1_all.deb (truncated output)
    ./usr/
    ./usr/share/
    ./usr/share/doc
./usr/share/doc/navldapubuntu/ ./usr/share/doc/navldapubuntu/copyright ./usr/share/doc/navldapubuntu/README.Debian ./usr/share/doc/navldapubuntu/changelog.Debian.gz ./etc/ldap.conf
like image 206
user2175757 Avatar asked Mar 18 '13 18:03

user2175757


People also ask

How do I install a config file?

Right-click on your solution file. Choose Add > Installation Configuration File.

Where is the config file in Debian?

conffiles are listed in /var/lib/dpkg/info/*. conffiles for each package. The recommended method to assemble -config packages is to divert and symlink in the postinst, and remove symlinks and diversions in the prerm script.

Where do I put config files in Linux?

Most global config files are located in the /etc directory. The following is a list of the most useful of these sub-directories: /etc/X11/ – xorg specific config files. /etc/cups/ – sub-directory containing configuration for the Common UNIX Printing System.

How can you list the configuration files of an installed package?

You may use dpkg-query -L your_package | grep etc to list all package files and directories inside the /etc/ directory.


1 Answers

There is a special tool that designed for creation of configuration packages: http://debathena.mit.edu/config-packages

Here is a simple template that could be helpful for a quick start.

List of files

  • template (directory)
  • template/debian (directory)
  • template/debian/control
  • template/debian/changelog
  • template/debian/displace
  • template/debian/rules
  • template/debian/postinst
  • template/debian/install
  • template/debian/docs
  • template/debian/compat
  • template/README
  • template/BUILD
  • template/files (directory)
  • template/files/etc/ldap.conf.mycompanyname

Content

template/debian/control:

Source: PACKAGE_NAME
Section: morpho/misc
Priority: optional
Maintainer: MAINTAINER
Build-Depends: debhelper, config-package-dev (>= 5.0~)

Package: PACKAGE_NAME
Architecture: all
Depends: ${misc:Depends}, DEPENDENCY [, DEPENDENCY ...]
Provides: ${diverted-files}
Conflicts: ${diverted-files}
Description: PACKAGE_DESCRIPTION_SHORT
PACKAGE_DESCRIPTION_LONG.

template/debian/displace

/etc/ldap/ldap.conf.mycompanyname

template/debian/install

files/* /

template/debian/postinst

#!/bin/sh
set -e
#DEBHELPER#

POSTINST_SCRIPT

template/debian/rules

#!/usr/bin/make -f

# Exclude *.svn* from building 
# you probably don't need this if don't use SVN
export DH_ALWAYS_EXCLUDE=.svn

# Core (check http://debathena.mit.edu/config-packages for more information)
%:
        dh $@ --with=config-package

# Prevent dh_installdeb of treating files in /etc as configuration files
# you need this if need configuration files been always rewritten
# even if changed
override_dh_installdeb:
        dh_installdeb
        rm debian/*/DEBIAN/conffiles

template/debian/docs

README
BUILD

And finally you can build this package with the following command:

dpkg-buildpackage -us -uc -I.svn
like image 79
Stanislav German-Evtushenko Avatar answered Nov 03 '22 01:11

Stanislav German-Evtushenko