Search code examples
ubuntuubuntu-server

Building ubuntu server packages


I have developed some C++ apps on my Ubuntu desktop. I want to create installation packages so that I can install them on a Ubuntu server.

Can anyone provide guidelines on how to create an Ubuntu server package?


Solution

  • The easiest way is to create an "install" section in your makefile which will install the program, then run checkinstall. You may need to install it with aptitude install checkinstall.

    checkinstall runs make install, finds out what was changed, then builds a package based on it.


    To do the install section in a makefile, just put the commands it would take to install your program. Here's an example of a program that creates a binary called "myprogram" and needs some configuration in /etc:

    # make example
    myprogram: main.o something_else.o
        gcc -o myprogram main.o something_else.o -llibrary_goes_here
    
    install: myprogram
        cp myprogram /usr/bin #install binary
        cp -R etc /etc/myprogram # copy "etc" folder to /etc/myprogram
    

    There's a command called install that's like cp and lets you specify permissions, but I don't know the syntax well enough.

    You'd also need a section for each .o file that says how to compile it (probably gcc -c filename.cpp).