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
Right-click on your solution file. Choose Add > Installation Configuration File.
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.
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.
You may use dpkg-query -L your_package | grep etc to list all package files and directories inside the /etc/ directory.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With