Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am starting in linux because I need it for my reseach. Since I have little time and no local expert support, this is a need based self-learning experience. I have to install a tool and I got this script for installing, download some libraries and create dependencies. Yet I have found that it contains some commands that work on RED-HAT and not in Ubuntu (like yum). Because I lack knowledge, I would like to know if there are other parts in the code that I should modify in order I can make this work. Could you help me please?

Thanks in advance.

SCRIPT:

#!/bin/sh
set -e -x

#######################################################################
# cpanm
# version 1.6908

# DEPENDENCIES
yum install -y make gcc tar curl perl perl-Module-Build

# go to bin
cd /usr/bin
# download script, make it exec
curl -LO https://raw.github.com/miyagawa/cpanminus/1.6908/cpanm
chmod +x cpanm

#######################################################################
# prinseq
# version 20.4

# create your base folder
mkdir -p /opt/prinseq
cd /opt/prinseq
BASE_FOLDER=/opt/prinseq

# prinseq native deps: cairo libs
yum install -y cairo cairo-devel

# random prereqs
cpanm Test::Simple@0.98
cpanm Pod::Parser@1.60

# for some reason, this is PathTools@3.40
cpanm Cwd@3.40

cpanm common::sense@3.6
cpanm JSON::XS@2.33
cpanm JSON@2.57
cpanm Getopt::Long@2.39
cpanm Pod::Usage@1.61
cpanm Digest::MD5@2.52
cpanm version@0.9902
cpanm MIME::Base64@3.13

# update module::build
cpanm Module::Metadata@1.000011
cpanm JSON::PP@2.27202
cpanm CPAN::Meta::YAML@0.008
cpanm Parse::CPAN::Meta@1.4404
cpanm CPAN::Meta::Requirements@2.122
cpanm CPAN::Meta@2.130880
cpanm Perl::OSType@1.003
cpanm Module::Build@0.4005

# cairo bindings
cpanm ExtUtils::Depends@0.304
cpanm ExtUtils::PkgConfig@1.14
cpanm Cairo@1.103

# stats related
cpanm Math::MatrixReal@2.08
cpanm Math::Cephes::Matrix@0.51
cpanm Text::SimpleTable@2.03
cpanm Want@0.21
# need old version of contextual::return
cpanm http://search.cpan.org/CPAN/authors/id/D/DC/DCONWAY/Contextual-Return-v0.2.1.tar.gz
cpanm Statistics::PCA@0.0.1

# download prinseq, install
wget http://resources.ohnosequences.com/prinseq/prinseq-lite-0.20.3.tar.gz
tar -xzf prinseq-lite-0.20.4.tar.gz
rm prinseq-lite-0.20.4.tar.gz
chmod +x prinseq-lite-0.20.4/*.pl
# links
ln -sf $BASE_FOLDER/prinseq-lite-0.20.3/*.pl /usr/bin/
share|improve this question

2 Answers 2

up vote 2 down vote accepted

You're asking if there are parts of the code other than yum calls that should be modified.

It's sometimes hard to know this for sure, since the software your script automatically downloads and uses (cpanm) could have bugs or other issues that make it work differently on different distributions. I suspect that is not the case, but I cannot know for sure.

There can be other problems too. For example, your script downloads cpanm to /usr/bin, which is fine, but:

  • If the script had downloaded it to a directory that is typically listed in PATH in RHEL/Fedora systems but not Ubuntu, that could cause the script to fail. That's not the case here.
  • cpanm is provided in Ubuntu's official software sources. You can install it with sudo apt-get update followed by sudo apt-get install cpanminus. If it is installed, then you should not run this script (as written) because it would probably overwrite the existing cpanm, causing a different file to be installed than the local package database believes is installed. Therefore I recommend checking to make sure the cpanminus package is not installed before using this script.
  • If the cpanminus package is installed, you can remove it, or you can modify the script to not download cpanm itself. (Whether or not that will work depends on how specific your needs are to the specific version of cpanm it downloads, but most likely it will work.) Or you could modify the script to download the cpanm package to another directory, like /usr/local/bin or /opt/bin. To make sure the script-downloaded cpanm is the one that is run, make sure the directory it's downloaded to appears in your PATH before /usr/bin.
  • There may be other such subtle differences.

With that said, we can see if there are any other obvious changes (besides changing yum install -y ... to apt-get update followed by apt-get install -y ..., and changing the package names as kraxor explains) that are needed, by enumerating all the commands you are using--except yum--and seeing if any of them are missing or work in a substantially different way on Ubuntu from the way they work on RHEL/Fedora.

You have (in order of first appearance):

  • set: This is a shell builtin and works the same in most Bourne-style shells; it does not have to be changed.
  • cd: This is a shell builtin and works the same in basically every Unix shell ever.
  • curl: While wget is more commonly used on Ubuntu systems and curl is not installed by default, if it's not installed you can simply install it with sudo apt-get update && sudo apt-get install curl. I don't recommend adding that to your script; just run it yourself before using the script for the first time. It's a bit odd that your script uses both wget and curl--most scripters pick one--but there's nothing wrong with using both, so long as both are installed.
  • chmod: This is a standard command that works almost exactly the same on all Unix-like systems.
  • cpanm: This is the command the script downloads and installs before using. Unless it has idiosyncracies that make it work differently on Ubuntu, it should work just the same. See above about the possibility of using the version of cpanm officially provided in Ubuntu, instead.
  • tar: This is a standard command and while some flags are GNU/Linux specific, it works essentially the same on all recent GNU/Linux systems including any version of Ubuntu, RHEL, or Fedora in the past decade or so. Furthermore, the flags used (x, z, and f) are supported by essentially every tar implementation ever.
  • rm: Like chmod, this is a standard command that works almost exactly the same on all Unix-like systems.
  • ln: Like chmod and rm, this is a standard command that works almost exactly the same on all Unix-like systems.
share|improve this answer
    
Thanks! I have read this carefully, yet I have an extra question. I have installed 'cpanminus' independently and eliminated the cpanm installation by commenting the lines 'curl -LO raw.github.com/miyagawa/cpanminus/1.6908/cpanm'; and 'chmod +x cpanm'. Now, do I have to conserve all the following lines starting with cpanm? –  Elka_GN Aug 6 at 16:29
    
Those are the cpan modules... now I know. I will try the rest for my self. Thanks to all. –  Elka_GN Aug 6 at 16:35
    
@Elka_GN Presumably, for the script to do it's job, the lines that call cpanm (in this case, that have it as their first word) should/must be kept. –  Eliah Kagan Aug 6 at 20:51
    
I had problems when installing JSON-XS and JSON modules with the script, as I pointed out in my other question. Found a patch but it was Chinese to me. I decided to install JSON-XS independently by: sudo cpanm JSON::XS. It worked. The same for the next line in script (cpanm JSON). Would you recomend to eliminate the @number from all the cpanm modules lines, since it seems to be causing the trouble? – Elka_GN –  Elka_GN Aug 7 at 15:18

The main difference should be that Ubuntu uses apt instead of yum, and some of the packages have different names.

The equivalent of yum install -y would be apt-get install -y.

cairo and cairo-devel should be changed to libcairo2 and libcairo2-dev.

Usually we don't install make, gcc, etc. individually, but use the build-essential metapackage.

Other than that, the other commands look distro-independent. Try "translating" the yum commands using these guidelines and test-run them on an Ubuntu system. If they run successfully, then you should be alright.

share|improve this answer
1  
For further user I will post what I have done to get the script work. –  Elka_GN Aug 5 at 21:57
    
I made the "translation" as @kraxor suggested. Also, changed 'perl-Module-Build' by 'libmodule-build-perl'. Finally I wrote a new 'sudo apt-get' line for 'curl' and 'libmodule-build-perl'. That make the code run without error messages. I hope the installing was finished properly. –  Elka_GN Aug 5 at 22:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.