How to install fpm package builder on Ubuntu/Debian

Problem:

You want to build a package using the fpm command, but you see the following error message:

fpm: command not found

Solution:

First, install rubygems:

sudo apt -y install rubygems

and now install fpm using rubygems:

sudo gem install fpm