2
\$\begingroup\$

Is this bad practice? Also, how can it be improved?

#!/usr/bin/env bash
RUBY_VERSION=2.1.0
printf "Installing Ruby $RUBY_VERSION\\n"
if [ -d ruby_build ]; then
 rm -Rf ruby_build
fi
if [[ `command -v ruby` && `ruby --version | colrm 11` == "ruby $RUBY_VERSION" ]] ; then
 echo "You already have this version of Ruby: $RUBY_VERSION"
 exit 113
fi
sudo apt-get build-dep -y ruby1.9.1
mkdir ruby_build && cd ruby_build
curl -O "http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-$RUBY_VERSION.tar.gz"
tar xf "ruby-$RUBY_VERSION.tar.gz"
cd "ruby-$RUBY_VERSION"
./configure
make
sudo checkinstall -y --pkgversion "$RUBY_VERSION" --provides "ruby-interpreter" --replaces="ruby-1.9.2"
cd ../.. && rm -Rf ruby_build
Jamal
35.2k13 gold badges134 silver badges238 bronze badges
asked Feb 15, 2014 at 15:18
\$\endgroup\$
1
  • \$\begingroup\$ It really seems like this is a job for rvm unless there is some other logic you can't show us. It can be set to build from source. \$\endgroup\$ Commented Oct 28, 2015 at 18:01

1 Answer 1

2
\$\begingroup\$

First,I would like to point out that not all .deb-based distributions are as fond of sudo as Ubuntu is. For example, Debian doesn't use sudo out of the box.

It appears that you're trying to build a newer version of Ruby than is available in the stock package repository. In that case, why not make a proper .deb package with its .dsc and publish it in a private APT repository? Then, everything integrates properly into the distribution the way package management is supposed to work, including the build process and subsequent updates. Everyone will have a better experience when you work with the system instead of against it.

answered Feb 15, 2014 at 20:29
\$\endgroup\$
2
  • \$\begingroup\$ Hmm, actually setting up my own PPA might not be too bad a solution. Can even make most of it public (such as NodeJS, Ruby, CouchDB &etc); just keeping the internal components private. \$\endgroup\$ Commented Feb 16, 2014 at 5:45
  • \$\begingroup\$ Agreed, setting up a private PPA is the best approach, however that option was dismissed as something to be done later down the track. Well it is over 1.5 years later, so I suppose this is down the track! \$\endgroup\$ Commented Oct 29, 2015 at 13:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.