DEV Community

Ben Santora
Ben Santora

Posted on • Edited on

Creating a Basic .deb Package

Create a .deb package - simple 'hello deb' program.
Package Directory Structure

  1. Set up the package directory:
mkdir -p ~/hello-package/DEBIAN
mkdir -p ~/hello-package/usr/local/bin
Enter fullscreen mode Exit fullscreen mode
  1. Add the control file:
nano ~/hello-package/DEBIAN/control
Enter fullscreen mode Exit fullscreen mode

Paste the following:

Package: hello-deb
Version: 1.0
Architecture: all
Maintainer: Your Name <your.email@example.com>
Description: A simple Hello Deb package for testing .deb creating on WSL
Enter fullscreen mode Exit fullscreen mode
  1. Create the script:
echo -e '#!/bin/bash\necho "Hello, Deb!"' > ~/hello-package/usr/local/bin/hello-deb
chmod +x ~/hello-package/usr/local/bin/hello-deb
Enter fullscreen mode Exit fullscreen mode

Build the .deb Package
Run:

dpkg-deb --build ~/hello-package
Enter fullscreen mode Exit fullscreen mode

You should now see hello-package.deb in your home directory

After building the package, install it using dpkg:

sudo dpkg -i ~/hello-package.deb
Enter fullscreen mode Exit fullscreen mode

Run the installed script:

hello-deb
Enter fullscreen mode Exit fullscreen mode

end

As you might guess, the process becomes more complex as the packages grow in functionality, adding components such as dependencies, configuration files, documentation, scripts for installation and removal, and multiple binaries or shared resources.

Some Useful Links on Debian Package Creation:

• Debian Packaging Wiki
https://wiki.debian.org/Packaging
• A Beginner's Guide to Debian Packaging (YouTube)
https://www.youtube.com/watch?v=fr_5n2hJ2eU
• Debian Repository Setup
https://wiki.debian.org/DebianRepository/Setup
• APT Sources List Configuration
https://wiki.debian.org/SourcesList
• Debian Packaging Tutorial (PDF)
https://www.debian.org/doc/manuals/packaging-tutorial/packaging-tutorial.pdf

Ben Santora - December 2024

Top comments (1)