Skip to content

Add Ubuntu/Debian support #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 59 additions & 3 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ else
fi
fi

# WITH_DEP=true bin/setup will install system dependencies (mac only)
# WITH_DEP=true bin/setup will install system dependencies (mac and ubuntu/debian only)
if [ -n "$WITH_DEP" ]; then
echo "Checking system dependencies..."
# Ubuntu/Debian support was once working; Here it determines if you're on a mac or debian
# Here it determines if you're on a Mac or Ubuntu/Debian
IS_MAC=false; IS_DEBIAN=false
[[ -f /etc/debian_version ]] && IS_DEBIAN=true
[[ $(command -v sw_vers) && $(sw_vers -productVersion | cut -f2 -d.) -ge 7 ]] && IS_MAC=true
Expand All @@ -90,11 +90,67 @@ if [ -n "$WITH_DEP" ]; then
echo $PATH | grep $(cd $(which gem)/..;pwd) > /dev/null
[[ $? -ne 0 ]] && echo 'For ruby gems to work, add the current path to your profile (.bashrc, .zshrc, etc):
export PATH="$(cd $(which gem)/..;pwd):$PATH"'
elif $IS_DEBIAN; then
# Installing ruby
if [[ ! $(command -v ruby) ]]; then
append_log successfully sudo apt-get install -y build-essential libffi-dev libgdbm-dev libncurses5-dev libreadline-dev libssl-dev libyaml-dev zlib1g-dev

echo "Downloading Ruby 2"
wget -qO - "ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.0-stable.tar.gz" | tar xzf -

echo "Installing Ruby 2"
quietly cd ruby-* && ./configure --silent --prefix=/usr/local/lib/ruby --bindir=/usr/local/bin && make --silent && sudo make install --silent && cd ..
quietly successfully rm -rf ruby-*
fi
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericboehs, What you think about this approach?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not bad.

The latest version of ruby 2.0 is available here: ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.0-stable.tar.gz .. but nice sed work ;) We could probably just assume if they have any version of ruby 2.0 it's good enough.

Line 98: Tick marks have been deprecated in favor of$()` (see). But that doesn't matter as 95-102 could be:

if $(ruby -e'p !!RUBY_VERSION[/^2.0/]'); then

As I mentioned in my previous comment, you could pipe wget's output directly to tar. So 106-108:

append_log successfully wget -qO- "ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.0-stable.tar.gz" | tar xzf -

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to put wget and tar on the same line as you said, but:

bzip2: Compressed file ends unexpectedly;
    perhaps it is corrupted?  *Possible* reason follows.
bzip2: Inappropriate ioctl for device
    Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

tar: Child returned status 2
tar: Error is not recoverable: exiting now
cp: cannot stat `phantomjs-*/bin/phantomjs': No such file or directory

Here is the line:

# $PJSURL = "https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2"
append_log successfully wget -qO - $PJSURL | tar xjpf -

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try dropping the p flag from tar. This works for me:

wget -qO - https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2 | tar xjf -

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm looks like the p flag just preserves permissions, so I'm not sure why that would fail.

Here's my full output:

wget -qO - https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2 | tar xjf - && ls -al phantomjs-* && rm -r phantomjs-*
total 56
drwxr-xr-x    8 ericboehs  staff    272 Jun  5 12:56 .
drwx------   43 ericboehs  staff   1462 Aug  2 22:37 ..
-rw-r--r--    1 ericboehs  staff  14945 Jun  5 12:56 ChangeLog
-rw-r--r--    1 ericboehs  staff   1429 Jun  5 12:56 LICENSE.BSD
-rw-r--r--    1 ericboehs  staff   3957 Jun  5 12:56 README.md
drwxr-xr-x    3 ericboehs  staff    102 Jun  5 12:56 bin
drwxr-xr-x  102 ericboehs  staff   3468 Jun  5 12:56 examples
-rw-r--r--    1 ericboehs  staff   1888 Jun  5 12:56 third-party.txt

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to remove quietly successfully and now It works!


# Installing memcached
append_log successfully sudo apt-get install -y memcached

# Installing ImageMagick
append_log successfully sudo apt-get install -y imagemagick libdjvulibre-dev libjpeg-dev libtiff-dev libwmf-dev libmagickcore-dev libmagickwand-dev libmagick++-dev

# Installing PhantomJS
LATEST_PHANTOMJS_VERSION=`wget -qO - "https://code.google.com/p/phantomjs/downloads/list?can=1" | sed -E 's/^.*(phantomjs)-(.*)-linux-.*$/\2/' | sed -e '/^[0-9].*/!d' | sort | sed '$!d'`
PJS32="https://phantomjs.googlecode.com/files/phantomjs-$LATEST_PHANTOMJS_VERSION-linux-i686.tar.bz2"
PJS64="https://phantomjs.googlecode.com/files/phantomjs-$LATEST_PHANTOMJS_VERSION-linux-x86_64.tar.bz2"
[[ $(dpkg-architecture -qDEB_HOST_ARCH) = 'amd64' ]] && PJSURL=$PJS64 || PJSURL=$PJS32

wget -qO - $PJSURL | tar xvjf -
append_log successfully sudo cp phantomjs-*/bin/phantomjs /usr/local/bin/
quietly successfully rm -rf phantomjs-*

append_log successfully sudo apt-get install -y libfreetype6 fontconfig
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these needed for phantomjs too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes


echo "Installing system libraries so we can compile some gems"

quietly successfully sudo apt-get install -y g++ libcurl3

# For nokogiri gem
append_log successfully sudo apt-get install -y libxml2-dev libxslt1-dev

# Using NodeJS as javascript runtime
quietly successfully sudo add-apt-repository -y ppa:chris-lea/node.js
quietly successfully sudo apt-get update
append_log successfully sudo apt-get install -y nodejs

# Installing Heroku Toolbelt
append_log successfully wget -qO toolbelt.sh https://toolbelt.heroku.com/install-ubuntu.sh
append_log successfully sh toolbelt.sh
quietly successfully rm toolbelt.sh

# Installing Postgres
quietly successfully sudo apt-get install -y python-software-properties
quietly successfully sudo add-apt-repository -y ppa:pitti/postgresql
quietly successfully sudo apt-get update
append_log successfully sudo apt-get install -y postgresql-9.2 postgresql-server-dev-9.2 postgresql-contrib-9.2 postgresql-client-9.2
quietly successfully sudo sed -i 's/peer$/trust/g' /etc/postgresql/9.2/main/pg_hba.conf
quietly successfully sudo sed -i 's/md5$/trust/g' /etc/postgresql/9.2/main/pg_hba.conf
append_log sudo service postgresql restart && sudo su postgres -c "createuser -s -d $USER" && createdb
fi
fi

echo "Installing libraries..."
append_log successfully gem list -i bundler || gem install bundler
append_log gem list -i bundler || gem install bundler
append_log successfully bundle install --path vendor/bundle --binstubs vendor/bundle/bin

# Flush all the memcaches
Expand Down