Ubuntu – How to create a deb from binaries

debpackaging

I have a few binary files: foo, bar.so, and foo.lnk. I want to make a deb that will extract foo to /usr/share/foo/foo, bar to that same directory, and foo.lnk to /usr/share/applications. I dont want to include any source and there are a few dependencies that I need to make sure are installed.

I've found some resources such as http://www.webupd8.org/2010/01/how-to-create-deb-package-ubuntu-debian.html and https://wiki.debian.org/IntroDebianPackaging . The problem is that they are guides meant to include the source. Furthermore, I really dont understand how I specify where to extract certain files to.

Best Answer

I found a relatively simple way to do it, all that's missing from that are how to run the pre-install and post-install scripts. (And if there's a way to add an uninstall script).

http://ubuntuforums.org/showthread.php?t=910717

  1. Decide on the name of your package. Standard Debian notation is all lowercase in the following format:

    <project>_<major version>.<minor version>-<package revision>
    

    For example, you could name your first package...

    helloworld_1.0-1
    
  2. Create a directory to make your package in. The name should be the same as the package name.

    mkdir helloworld_1.0-1
    
  3. Pretend that the packaging directory is actually the root of the file system. Put the files of your program where they would be installed to on a system.

    mkdir helloworld_1.0-1/usr  
    mkdir helloworld_1.0-1/usr/local  
    mkdir helloworld_1.0-1/usr/local/bin  
    cp "~/Projects/Hello World/helloworld" helloworld_1.0-1/usr/local/bin  
    
  4. Now create a special metadata file with which the package manager will install your program.

    mkdir helloworld_1.0-1/DEBIAN  
    gedit helloworld_1.0-1/DEBIAN/control
    

    Put something like this in that file.

    Package: helloworld
    Version: 1.0-1
    Section: base
    Priority: optional
    Architecture: i386
    Depends: libsomethingorrather (>= 1.2.13), anotherDependency (>= 1.2.6)
    Maintainer: Your Name <you@email.com>
    Description: Hello World
     When you need some sunshine, just run this
     small program!
    

    The space before each line in the description is important.

  5. Now you just need to make the package:

    dpkg-deb --build helloworld_1.0-1