The tremendously successful Drupal community observes stringent requirements about many things, in particular, licensing and the prohibition of bundling third-party JavaScript.

While these policies may seem onerous at first glance, it turns out there is another project with a written guarantee to provide third-party code in a form that meets the expectations of Drupal and does so in a way that completely automates all that tedious effort into one-click oblivion. I'm talking about the Debian GNU/Linux operating system.

Drupal's libraries module

The libraries module for Drupal appeared as an initial attempt to help track third-party JavaScript.

The module has been available in Debian for almost a year and has recently been provided in the wheezy-backports distribution for people running the stable version of Debian.

The library provides a standard way for other modules to reference third-party JavaScript but it still leaves the web master with some manual work to go out and download all the necessary JavaScript and copy it into the right place. This is where Debian comes to the rescue.

Using the module in practice

I've recently uploaded JSCommunicator to Debian and wanted to provide a convenient way for people to get it in Drupal.

Therefore, in addition to providing the JSCommunicator packages, I created an extra package, drupal7-mod-jscommunicator.

JSCommunicator itself depends on other JavaScript, specifically, the JsSIP library. I repeated the same process for JsSIP. This gives us the following collection of four related packages:

Third-party libraryLibrary itselfDrupal module, packaged
JSCommunicatorlibjs-jscommunicatordrupal7-mod-jscommunicator
JsSIPlibjs-jssipdrupal7-mod-jssip

If you explore the package details in Debian's package catalog you will notice that each package depends on the other packages it requires.

Debian's package management utility, apt-get, can transitively resolve all the relationships between this set of packages. In fact, on a newly built server, you can simply run the command:

apt-get install drupal7-mod-jscommunicator

and the apt-get utility will install Apache, MySQL, Drupal itself, the libraries module, all the related JavaScript libraries and the final Drupal module of JSCommunicator itself. It really is that easy. Here is an example of the output displayed by the command on a freshly built server:

# apt-get -d install drupal7-mod-jscommunicator
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  apache2 apache2-bin apache2-data curl dbconfig-common drupal7
  drupal7-mod-jssip drupal7-mod-libraries fontconfig-config fonts-dejavu-core
  javascript-common libaio1 libapache2-mod-php5 libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap libarchive-extract-perl libc6
  libcurl3 libdbd-mysql-perl libdbi-perl libedit2 libfontconfig1 libgcrypt11
  libgd3 libhtml-template-perl libjbig0 libjpeg8 libjs-jssip libjson-c2
  liblocale-gettext-perl liblog-message-simple-perl liblua5.1-0
  libmodule-pluggable-perl libmysqlclient18 libonig2 libperl4-corelibs-perl
  libpng12-0 libpod-latex-perl libqdbm14 librtmp0 libssh2-1 libterm-ui-perl
  libtext-charwidth-perl libtext-iconv-perl libtext-soundex-perl libtiff5
  libuuid-perl libvpx1 libxml2 libxpm4 locales mysql-client mysql-client-5.5
  mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 perl
  perl-base perl-modules php5 php5-cli php5-common php5-gd php5-json
  php5-mysql php5-readline ssl-cert wwwconfig-common
Suggested packages:
  apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  php-pear glibc-doc libclone-perl libmldbm-perl libnet-daemon-perl
  libplrpc-perl libsql-statement-perl rng-tools libgd-tools
  libipc-sharedcache-perl libterm-readkey-perl tinyca perl-doc
  libterm-readline-gnu-perl libterm-readline-perl-perl make libb-lint-perl
  libcpanplus-dist-build-perl libcpanplus-perl libfile-checktree-perl
  liblog-message-perl libobject-accessor-perl php5-user-cache
  openssl-blacklist postgresql-client
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data curl dbconfig-common drupal7
  drupal7-mod-jscommunicator drupal7-mod-jssip drupal7-mod-libraries
  fontconfig-config fonts-dejavu-core javascript-common libaio1
  libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3
  libaprutil1-ldap libarchive-extract-perl libcurl3 libdbd-mysql-perl
  libdbi-perl libfontconfig1 libgd3 libhtml-template-perl libjbig0 libjpeg8
  libjs-jssip libjson-c2 liblog-message-simple-perl liblua5.1-0
  libmodule-pluggable-perl libmysqlclient18 libonig2 libperl4-corelibs-perl
  libpng12-0 libpod-latex-perl libqdbm14 librtmp0 libssh2-1 libterm-ui-perl
  libtext-soundex-perl libtiff5 libvpx1 libxpm4 mysql-client mysql-client-5.5
  mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5
  php5-cli php5-common php5-gd php5-json php5-mysql php5-readline ssl-cert
  wwwconfig-common
The following packages will be upgraded:
  libc6 libedit2 libgcrypt11 liblocale-gettext-perl libtext-charwidth-perl
  libtext-iconv-perl libuuid-perl libxml2 locales perl perl-base perl-modules
12 upgraded, 60 newly installed, 0 to remove and 222 not upgraded.
Need to get 37.2 MB of archives.
After this operation, 152 MB of additional disk space will be used.
Do you want to continue [Y/n]? 

Libraries API in Drupal 8

Contrary to an earlier version of this blog, the libraries module is not joining the core in Drupal 8 however its use has been strongly encouraged for any new modules submitted through the Drupal community approval process. This means there will be further opportunity for Drupal users to consolidate on their use of Debian to completely automate the management of all third-party libraries and modules throughout their Drupal system(s).