Vagrant
A quick reference for getting started with Vagrant — covering basic commands, configuration, and the Vagrantfile.
DPKG is a low-level system tool used to extract, analyze, unpack, install, and remove .deb files on Debian-based Linux distributions.
A .deb file is an archive that contains packaged data. It provides a standard way to distribute and install software on Debian and its derivatives (such as Ubuntu).
The naming convention for .deb files follows this format:
<name>_<version>-<revision>_<architecture>.deb
Where:
<name> — the name of the application<version> — the version number of the application<revision> — the revision number of the deb package itself<architecture> — the target hardware architecture (e.g., amd64, arm64)For example, a program called hello, version 1.0, built for 64-bit ARM processors, would be named: hello_1.0-1_arm64.deb.
Start by creating a directory that follows the Debian package naming format:
mkdir hello_1.0-1_arm64
The package directory mirrors the root filesystem of the target system. Create the appropriate directory structure and copy your executable into it:
mkdir -p hello_1.0-1_arm64/usr/local/bin
cp ~/YourProjects/Hello/hello hello_1.0-1_arm64/usr/local/bin
The control file resides inside a DEBIAN directory (uppercase). Note that a lowercase debian directory is used for source packages — these are not the same thing.
mkdir hello_1.0-1_arm64/DEBIAN
touch hello_1.0-1_arm64/DEBIAN/control
The control file is a list of key-value fields that describe the package. The following fields are mandatory for binary packages:
Package — the name of the programVersion — the version of the programArchitecture — the target architectureMaintainer — the name and email of the package maintainerDescription — a brief description of the programExample:
Package: hello
Version: 1.0
Architecture: arm64
Maintainer: Internal Pointers <[email protected]>
Description: A program that greets you.
You can add a longer description here. Mind the space at the beginning of this paragraph.
The control file can also include additional fields such as the section it belongs to or a dependency list. The dependency list is especially important if your program relies on external libraries.
With everything in place, invoke dpkg-deb to build the package:
dpkg-deb --build --root-owner-group <package-dir>
For our example:
dpkg-deb --build --root-owner-group hello_1.0-1_arm64
The --root-owner-group flag ensures that all files in the package are owned by root, which is the standard practice. Without it, files would be owned by your current user — which may not exist on the target system.
If successful, this generates a .deb file in the current directory. Make sure dpkg-deb is installed on your system before running this command.
After building, it’s good practice to verify that the package installs and uninstalls cleanly.
Install the package:
sudo dpkg -i <APP_NAME>
Remove the package:
sudo dpkg -r <APP_NAME>
Remove the package along with its configuration files:
sudo dpkg -P <APP_NAME>
Verify the package has been fully removed:
dpkg -l | grep <APP_NAME>
If the output is blank, the package was removed successfully.
DPKG supports four lifecycle scripts known as maintainer scripts: preinst, postinst, prerm, and postrm. These files live inside the DEBIAN directory and run at specific stages during installation and removal:
preinst — runs before installationpostinst — runs after installationprerm — runs before removalpostrm — runs after removalThese scripts must be executable, with permissions set between 0555 and 0775.