docs: function custom(platforms, platform) {
      var plat;
      var id;
      var uri;
      var url;
      var version;
      var subdir;
      var platdir;
      var download_dir;
      var tmp_dir;
      var lib_dir;
      var isUri;
      if (!(platform in platforms)) {
          return Q.reject(new Error('judpack library "' + platform + '" not recognized.'));
      }
  
      plat = _.extend({}, stubplatform, platforms[platform]);
      version = plat.version;
      // Older tools can still provide uri (as opposed to url) as part of extra
      // config to create, it should override the default url provided in
      // platfroms.js
      url = plat.uri || plat.url;
      id = plat.id;
      subdir = plat.subdirectory;
      platdir = plat.altplatform || platform;
      // Return early for already-cached remote URL, or for local URLs.
      uri = URL.parse(url);
      isUri = uri.protocol && uri.protocol[1] != ':'; // second part of conditional is for awesome windows support. fuuu windows
      if (isUri) {
          download_dir = path.join(util.libDirectory, platdir, id, version);
          lib_dir = path.join(download_dir, subdir);
          if (fs.existsSync(download_dir)) {
              events.emit('verbose', id + ' library for "' + platform + '" already exists. No need to download. Continuing.');
              return Q(lib_dir);
          }
      } else {
          // Local path.
          lib_dir = path.join(url, subdir);
          return Q(lib_dir);
      }
  
      return HooksRunner.fire('before_library_download', {
          platform:platform,
          url:url,
          id:id,
          version:version
      }).then(function() {
          var uri = URL.parse(url);
          var d = Q.defer();
          npm.load(function(err) {
              // Check if NPM proxy settings are set. If so, include them in the request() call.
              var proxy;
              if (uri.protocol == 'https:') {
                  proxy = npm.config.get('https-proxy');
              } else if (uri.protocol == 'http:') {
                  proxy = npm.config.get('proxy');
              }
              var strictSSL = npm.config.get('strict-ssl');
  
              // Create a tmp dir. Using /tmp is a problem because it's often on a different partition and sehll.mv()
              // fails in this case with "EXDEV, cross-device link not permitted".
              var tmp_subidr = 'tmp_' + id + '_' + process.pid + '_' + (new Date()).valueOf();
              tmp_dir = path.join(util.libDirectory, 'tmp', tmp_subidr);
              shell.rm('-rf', tmp_dir);
              shell.mkdir('-p', tmp_dir);
  
              var size = 0;
              var request_options = {url:url};
              if (proxy) {
                  request_options.proxy = proxy;
              }
              if (typeof strictSSL == 'boolean') {
                  request_options.strictSSL = strictSSL;
              }
              events.emit('verbose', 'Requesting ' + JSON.stringify(request_options) + '...');
              events.emit('log', 'Downloading ' + id + ' library for ' + platform + '...');
              var req = request.get(request_options, function(err, res, body) {
                  if (err) {
                      shell.rm('-rf', tmp_dir);
                      d.reject(err);
                  } else if (res.statusCode != 200) {
                      shell.rm('-rf', tmp_dir);
                      d.reject(new Error('HTTP error ' + res.statusCode + ' retrieving version ' + version + ' of ' + id + ' for ' + platform));
                  } else {
                      size = body.length;
                  }
              });
              req.pipe(zlib.createUnzip())
              .on('error', function(err) {
                  // Sometimes if the URL is bad (most likely unavailable version), and git-wip-us.apache.org is
                  // particularly slow at responding, we hit an error because of bad data piped to zlib.createUnzip()
                  // before we hit the request.get() callback above (with a 404 error). Handle that gracefully. It is
                  // likely that we will end up calling d.reject() for an HTTP error in the request() callback above, but
                  // in case not, reject with a useful error here.
                  d.reject(new Error('Unable to fetch platform ' + platform + '@' + version + ': Error: version not found.'));
              })
              .pipe(tar.Extract({path:tmp_dir}))
              .on('error', function(err) {
                  shell.rm('-rf', tmp_dir);
                  d.reject(err);
              })
              .on('end', function() {
                  events.emit('verbose', 'Downloaded, unzipped and extracted ' + size + ' byte response.');
                  events.emit('log', 'Download complete');
                  var entries = fs.readdirSync(tmp_dir);
                  var entry = path.join(tmp_dir, entries[0]);
                  shell.mkdir('-p', download_dir);
                  shell.mv('-f', path.join(entry, '*'), download_dir);
                  shell.rm('-rf', tmp_dir);
                  d.resolve(HooksRunner.fire('after_library_download', {
                      platform:platform,
                      url:url,
                      id:id,
                      version:version,
                      path: lib_dir,
                      size:size,
                      symlink:false
                  }));
              });
          });
          return d.promise.then(function () { return lib_dir; });
      });
  }