Using CMake/CPack to create a Debian package with init.d scripts

Posted on 2011-05-09
Last Modified: 2012-05-11
I have a CMakeLists.txt that has an additional CPack generator so that if I type "make package" it will generate a Debian package based upon the INSTALL target. This works just fine.

The binary being packaged is a daemon so as part of the package install I want to install the necessary init.d script. Unfortunately, the documentation for CMake/CPack are not wonderful and I am unable to figure out the correct way to do this such that it will install the scripts in the correct location and also not overwrite if they already exist but prompt to do so (just like one would expect if the Debian package had been created using the standard Debian package creation tools.

I could use the standard Debian package tools to do this but using CMake is so much simpler given the simplicity of the package and the fact we already have CMake build files. So my question is, is there a correct way to use CPack to install init.d scripts? This would seem a pretty fundamental thing to want to do so I am surprised I can't find how to do this.
Question by:evilrix
    1 Comment
    LVL 39

    Accepted Solution

    I did this in the end by just adding an INSTALL(FILES...) command.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now