Requirements file for apt-get, similar to pip Requirements file for apt-get, similar to pip python python

Requirements file for apt-get, similar to pip


Your question is that you want to have a list of system dependences in one file, for being able to install it with one command.

I don't recomend you to include the version of a package in the system dependencies. In the soft system dependences like "build-essential" or "uuid-dev" you normally want the latest version of the package. In the "hard dependeces" like python, postgres or whatever, normally the version is specified in the name of the package itself, like "python2.6-dev" or "postgresql-8.4". Another problem you may have defining the exact version of the package is that maybe the version 8.4.11-1 of postgresql-8.4 will not be available in the repository in three months or in a year, and you will end up installing the current version in the repo.

Example. You can create a file named "requirements.system" with the system packages you need for you project:

python-virtualenvpython2.6-devuuid-devpython-pippostgresql-8.4

Then, in your INSTALL file explain how to install the system packages.

# Install system depencences by runningcat ~/project/install/requirements.system | xargs sudo aptitude install

We have running this configuration for about two years, having to recreate the enviroment from the scrach a few times and we never had a problem.


We use the aptfile format at work. It's simply a bash wrapper with some helpers built-in.


I usually create a list of installed packages with apt list --installed | awk -F/ '{print $1}' | grep -v Listing... > installed_packages.txt.

Explanation:

  • apt list --installed echoes a list of currently installed packages including versions
  • awk -F/ '{print $1}' gets rid of the package versions, this makes the file independent of your distribution (downstream compatibility between Mint, Ubuntu, Debian stable/testing, upstream not neccessarily)
  • grep -v Listing... gets rid of the "interactive" display of apt (first line)
  • all of that is then piped to a single file

You can then install on another system via cat installed_packages.txt | xargs apt install -y using each line of said file as an argument for apt.