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
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
cpanm Statistics::PCA@0.0.1
# download prinseq, install
wget
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/ 2 Answers
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
PATHin RHEL/Fedora systems but not Ubuntu, that could cause the script to fail. That's not the case here. cpanmis provided in Ubuntu's official software sources. You can install it withsudo apt-get updatefollowed bysudo apt-get install cpanminus. If it is installed, then you should not run this script (as written) because it would probably overwrite the existingcpanm, causing a different file to be installed than the local package database believes is installed. Therefore I recommend checking to make sure thecpanminuspackage is not installed before using this script.- If the
cpanminuspackage is installed, you can remove it, or you can modify the script to not downloadcpanmitself. (Whether or not that will work depends on how specific your needs are to the specific version ofcpanmit downloads, but most likely it will work.) Or you could modify the script to download thecpanmpackage to another directory, like/usr/local/binor/opt/bin. To make sure the script-downloadedcpanmis the one that is run, make sure the directory it's downloaded to appears in yourPATHbefore/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: Whilewgetis more commonly used on Ubuntu systems andcurlis not installed by default, if it's not installed you can simply install it withsudo 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 bothwgetandcurl--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 ofcpanmofficially 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, andf) are supported by essentially everytarimplementation ever.rm: Likechmod, this is a standard command that works almost exactly the same on all Unix-like systems.ln: Likechmodandrm, this is a standard command that works almost exactly the same on all Unix-like systems.
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.