Skip to content

Instantly share code, notes, and snippets.

@dvtate
Last active December 5, 2022 15:42
Show Gist options
  • Save dvtate/f3a684ea064bb40260f1d55df7b4dd12 to your computer and use it in GitHub Desktop.
Save dvtate/f3a684ea064bb40260f1d55df7b4dd12 to your computer and use it in GitHub Desktop.
A short guide on how to package software into .deb packages for debian, ubuntu and linux mint based linux distros

How To Create Debian Packages

This guide is copied from this video: https://www.youtube.com/watch?v=ep88vVfzDAo

Note: Commands here are just for examples. They will NOT run as they are shown here. You have to adapt them to your own needs and system.

  1. Create the directory to hold the project:

    mkdir /home/USER/debpkgs/my-program_version_architecture

  2. Create a directory called "DEBIAN" inside the project directory:

    mkdir /home/USER/debpkgs/my-program_version_architecture/DEBIAN

  3. Copy files into project root directory and include the final paths:

    /usr/bin/ would be /home/USER/debpkgs/my-program_version_architecture/usr/bin/

    /opt/ would /home/USER/debpkgs/my-program_version_architecture/opt/

  4. Create a control file in DEBIAN:

    touch /home/USER/debpkgs/my-program_version_architecture/DEBIAN/control

  5. Now add the necessary meta data to the control file:

    Package: my-program
    Version: 1.0
    Architecture: all
    Essential: no
    Priority: optional
    Depends: packages, my-program, needs, to, run
    Maintainer: Your Name
    Description: A short description of my-program that 
     will be displayed when the package is being selected for installation. 
    
  6. If desired a "preinst" and/or "postinst" script can be added that execute before and/or after installation. They must be given proper execute permissions to run:

    touch /home/USER/debpkgs/my-program_version_architecture/DEBIAN/postinst

    Add commands you'd like to run in postinst and then set the permissions to 755.

  7. Now generate package:

    dpkg-deb --build /home/USER/debpkgs/my-program_version_architecture

  8. The package will be in /home/USER/debpkgs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment