KISS

Keep It Simple Stupid

OS X Homebrew: how to install packages from blocked FTP

| comments

I don’t like corporate environments where all the useful stuff is blocked (like FTP, NTP, ssh, git), and you have to deal with sysadmins, security people, and other staff to allow that. Sometimes it’s faster to find a workaround though. Today I’ll tell you how I install Homebrew packages that are supposed to be downloaded via FTP.

As an example, you want to install lftp, which requires gnutls that can be officially downloaded from ftp.gnutls.org only.

Open the terminal (iTerm2). cd /usr/local, open the Library/Formula/gnutls.rb file, and change the

1
url 'ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1/gnutls-3.1.7.tar.xz'

line to

1
url 'http://127.0.0.1:8000/gnutls-3.1.7.tar.xz'

, which means we’ll serve the file ourselves. Commit the change.

Find an online service that allows you to access an FTP server via its webpage. I use light and simple http://www.net2ftp.com/. Download the required file from the url address you replaced in the formula above. Say, you’ve downloaded it to the ~/Downloads directory. What’s the simplest way to start a web server to provide the file? python! cd ~/Downloads and run the server:

1
2
3
➜  ~/Downloads  python -m SimpleHTTPServer &
[1] 93703
➜  ~/Downloads  Serving HTTP on 0.0.0.0 port 8000 ...

Then run the homebrew’s update process:

1
2
3
4
5
6
7
8
9
10
11
12
13
➜  ~/Downloads  brew update --rebase && brew upgrade
Current branch master is up to date.
Already up-to-date.
==> Upgrading 1 outdated package, with result:
gnutls 3.1.7
==> Upgrading gnutls
==> Installing gnutls
==> Downloading http://127.0.0.1:8000/gnutls-3.1.7.tar.xz
1.0.0.127.in-addr.arpa - - [05/Feb/2013 09:01:12] "GET /gnutls-3.1.7.tar.xz HTTP/1.1" 200 -
######################################################################## 100.0%
==> ./configure --disable-static --prefix=/usr/local/Cellar/gnutls/3.1.7
==> make install
  /usr/local/Cellar/gnutls/3.1.7: 858 files, 6.8M, built in 105 seconds

It works! Instead of going to a blocked FTP, homebrew got the file locally. Now stop the server:

1
2
3
4
➜  ~/Downloads  jobs
[1]  + running    python -m SimpleHTTPServer
➜  ~/Downloads  kill %1
[1]  + 93703 terminated  python -m SimpleHTTPServer

Comments