The problem I am addressing is that of writing and building a Perl module in such a way that it builds and installs using both CPAN and Debian packaging.
On Ubuntu you will want the packages libmodule-starter-perl, dh-make and dh-make-perl. These will provide commands module-starter, dh_make and dh-make-perl. Note the variable use of hyphens and underscores!
The wrinkles occur because CPAN and Debian handle configuration files differently. I assume that the configuration files are going to be installed in /etc/$ProjectName.
Add the following at the end of your Makefile.PL, assuming you are using Module::Install.
package MY; sub postamble { return << "EOF"; INST_ETC = blib/etc DESTINSTALLETC = \$(DESTDIR)/etc # This target is used by both CPAN and Debian builds config:: $(MKPATH) $(INST_ETC) # This target is used by both CPAN and Debian builds pure_all:: $(CP) -r etc/* $(INST_ETC) # This target is used only by CPAN builds; Debian uses debian/conffiles pure_install:: all $(MKPATH) $(DESTINSTALLETC)/$(NAME) $(CP) -r $(INST_ETC)/* $(DESTINSTALLETC)/$(NAME) EOF } |
This will deal with installing things correctly when you do a 'make install'. In this fragment the DESTINSTALLETC macro defines where you ultimately want things installed.
Unfortunately, the Debian system does not use 'make install', not even with a fake root or over-rides to DESTDIR. To deal with Debian packaging you need a debian/conffiles in the project directory. This should list the source files, normally living in the etc directory, e.g
etc/log4perl.conf etc/sessiontimewatcher.conf etc/sql/schema.sql etc/sql/test.sql
Now, the following script, run from one level above the project directory will build a Debian package for you
#!/bin/bash -xe # Script to build a Perl module for Debian. # Before running this script you must have created debian/control # and debian/conffiles in the module's directory. debian/control # will get created automatically the first time that you run this # script, you can then edit it to suit. debian/conffiles you have # to create yourself. export DEB_BUILD_OPTIONS=nocheck if [ ! -d $1 ]; then module-starter --module=$1 --mi --author='A N Other' \ --email=nobody@example.com fi cd $1 if [ -f Makefile ]; then make distclean else perl Makefile.PL fi cd .. dh-make-perl --notest --noinstall --version 7 --verbose $1 cd $1 debuild -d -us -uc