Hey look, it’s 2012/12/12 – cool! But that’s not what this post is about.

It always pissed me off big time that the more popular Linux distros don’t install the development files (like header files) or the documentation for the software that comes with them. Being a developer – this is a big pain in the ass for me. It became a really big pain in the ass when I switched from Slackware to Linux Mint a couple of months ago.

I’m no free software fanatic, but damn, why the hell not include the development tools and documentation with Linux? Not only will that make my life easier, but it may encourage some other people to dabble in programming on Linux. Otherwise, do you know what a serious roadblock it is to get a newbie to figure out that there’s a metapackage called build-essential and a package called libgtk2.0-dev which you have to type in exactly like that, with the lib and the dot and the (wrong) version and the dash and the dev? Hell, it’s easier to set up a development environment in Windows (you should be ashamed, Debian).

Whining about it would have been enough, but I actually needed to solve this problem, so here is the solution, you can use it too. It’s a shell script you can download here or copy paste from here:

#!/bin/sh
#
# install-all-dev-packages.sh
#
# Author: Andrew Smith http://littlesvr.ca
# Version 1.0 (12 Dec 2012)
#
# The following script installs all the -dev and -doc packages that should have
# been installed with your software but were omitted for some stupid reason.
#
# Tested on Linux Mint 13 but should work on any Debian/Ubuntu/Mint 
# or really on any Debian derivative.
#
# If you get errors like A : Conflicts: B but C is to be installed
# then add those packages (all of the A) into the following list:  
BADPKGLIST="libdb5.1 libglew1.5 libglew1.6 librdf0"

# List of all available packages
apt-cache pkgnames > /tmp/allpackages

NEWPKGLIST="build-essential"

echo "Searching for required -dev and -doc packages..."
for PKG in `dpkg --get-selections | cut -f 1`
do
  # Make sure it's not in the ignore list
  echo $BADPKGLIST | grep -q $PKG
  if [ $? -eq 0 ]
  then
    continue
  fi
  # See if a -dev package is available
  grep -qe "^$PKG-dev$" /tmp/allpackages
  if [ $? -eq 0 ]
  then
    NEWPKGLIST=" $NEWPKGLIST $PKG-dev"
  fi
  # See if a -doc package is available
  grep -qe "^$PKG-doc$" /tmp/allpackages
  if [ $? -eq 0 ] 
  then
    NEWPKGLIST=" $NEWPKGLIST $PKG-doc"
  fi
done

echo "The following packages have been found:"
echo
echo sudo apt-get install $NEWPKGLIST
echo
echo -n "Do you want to install them? (y/n) "
read YN
if [ a$YN = ay ]
then
  sudo apt-get install $NEWPKGLIST --install-suggests
fi

if [ $? -eq 100 ]
then
  echo
  echo "If you got apt-get erros such as 'A Conflicts: B but C is to be installed'"\
       " then make a change at the top of this script to ignore those packages,"\
       " hopefully that will work."
fi

There is potential for some typical apt-get quircks with the “bla bla is to be installed screw you haha” messages but that’s solvable, you just need to edit the script and blacklist those packages that are erroring. Presumably the list will be different on different OS versions.

Enjoy, you’re welcome!