Skip to content

Instantly share code, notes, and snippets.

@rsudip90
Last active August 14, 2019 00:56
Show Gist options
  • Save rsudip90/63147fc73c357646f0e07631e1594d9a to your computer and use it in GitHub Desktop.
Save rsudip90/63147fc73c357646f0e07631e1594d9a to your computer and use it in GitHub Desktop.
latest system update
#!/bin/bash
# This script installs the dependencies required by cypress.io tool
# on amazon linux AMI as the required dependencies are not easily available.
# path of dynamic executable of cypress
# for ex. /home/ec2-user/.cache/Cypress/3.0.1/Cypress/
CYPRESS_EXECUTABLE_FOLDER="/home/ec2-user/.cache/Cypress/<version>/Cypress"
exitError() {
echo "Error: $1" >&2
exit 1
}
if [[ $EUID -ne 0 ]]; then
echo "Please run as root/sudo"
exit 1
fi
# latest system update
yum update -y
# install xvfb
echo "installing xvfb (X virtual framebuffer)"
yum install -y Xvfb
# install libXScrnSaver from binary package
echo "installing libXScrnSaver"
rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/libXScrnSaver-1.2.2-2.el6.x86_64.rpm || exitError "error while installing libXScrnSaver"
# install pango, xrandr, xcursor, cairo, cups-libs(libcups)
echo "installing pango, xrandr, xcursor, cairo, cups-libs"
yum install -y pango pango pango-devel libXrandr libXrandr-devel libXcursor libXcursor-devel cups-libs || exitError "error while installing pango, xrandr, xcursor, cairo, cups-libs"
# install atk
echo "installing atk library"
rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/atk-1.30.0-1.el6.x86_64.rpm || exitError "error while installing atk"
rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/atk-devel-1.30.0-1.el6.x86_64.rpm || exitError "error while installing atk-devel"
echo "installing gcc compiler"
yum install -y gcc || exitError "error while installing gcc compiler"
# install gconf dependencies
echo "installing gconf with dependencies"
yum install -y libIDL libIDL-devel || exitError "error while installing libIDL libIDL-devel"
rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/ORBit2-2.14.17-6.el6_8.x86_64.rpm || exitError "error while installing ORBIT"
yum install -y gtk-doc indent || exitError "error while installing gtk-doc, indent"
rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/ORBit2-devel-2.14.17-6.el6_8.x86_64.rpm || exitError "error while installing ORBIT-devel"
yum install -y libxml2 libxml2-devel dbus dbus-devel dbus-glib dbus-glib-devel intltool || exitError "error while installing libxml, dbus, dbus-glib intltool"
cd /tmp
wget https://download.gnome.org/sources/GConf/2.32/GConf-2.32.4.tar.bz2
tar -jxvf GConf-2.32.4.tar.bz2
cd GConf-2.32.4
./configure && make
make install
# first install gdk
echo "installing gdk-pixbuf with dependencies"
yum install -y libtiff-devel libjpeg-devel || exitError "error while installing libtiff-devel libjpeg-devel"
cd /tmp
wget https://download.gnome.org/sources/gdk-pixbuf/2.24/gdk-pixbuf-2.24.0.tar.bz2
tar -jxvf gdk-pixbuf-2.24.0.tar.bz2
cd gdk-pixbuf-2.24.0
./configure
make
make install
# install gtk+ with pkgconfig
echo "installing gtk+ with dependencies"
yum install -y libXcomposite libXcomposite-devel || exitError "error while installing libXcomposite"
cd /tmp
wget https://download.gnome.org/sources/gtk+/2.24/gtk+-2.24.0.tar.bz2
tar -jxvf gtk+-2.24.0.tar.bz2
cd gtk+-2.24.0
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure
make
make install
# linking libraries to pre-built cypress
echo "Linking libraries (gconf, gtk, gdk, gdk-pixbuf) to pre-built Cypress at path $CYPRESS_EXECUTABLE_FOLDER"
cd $CYPRESS_EXECUTABLE_FOLDER
ln -PL /usr/local/lib/libgconf-2.so.4
ln -PL /usr/local/lib/libgtk-x11-2.0.so.0
ln -PL /usr/local/lib/libgdk-x11-2.0.so.0
ln -PL /usr/local/lib/libgdk_pixbuf-2.0.so.0
# echo "Done...! Please check out if any dependency is missing with: ldd $CYPRESS_EXECUTABLE_FOLDER/Cypress | grep 'not found'"
if [[ $(ldd $CYPRESS_EXECUTABLE_FOLDER/Cypress | grep 'not found') ]]; then
echo "There are some dependencies that cypress is missing,"
ldd $CYPRESS_EXECUTABLE_FOLDER/Cypress | grep 'not found'
else
echo "Cypress dependencies are installed. YAY"'!!'
fi
Copy link

ghost commented Aug 2, 2018

It looks like this script fails when a dependency is found to be already installed. Instead of proceeding it halts. I'm not sure what would be the best way to go about that, but for my purposes I removed the exit in exitError() so that every command would at least be attempted and a log of failures were documented in stderr. Thank you for this awesome script!

@rsudip90
Copy link
Author

rsudip90 commented Oct 7, 2018

Hey @mitchkm, I'm glad that you found it helpful! Yes, I made the script for the fresh installation purpose and yes, you just remove the exit 1 statement within exitError() function so that the script execution won't be stopped.

@maxterry
Copy link

Thanks for the helpful blog post and script!

The mirror.centos.org ORBit2-2.14.17-6 links are now 404ing. Changing to the latest version, ORBit2-2.14.17-7, resolves it.

This change, along with hardcoding the current version in the path and @mitchkm's removal of the exit in exitError, are in this fork for Cypress 3.1.5:

https://gist.github.com/1083/1ffff52f8f9104a49163fd1b8ec7cf20

@rsudip90
Copy link
Author

rsudip90 commented May 7, 2019

Thanks @1083. Yes, the link is broken for Orbit2.2 (even yours too at this moment)!!. I think they all keep changing over the time (as of writing this, they're at this version). These are low level system dependencies to make the cypress work. You always have to test the script and have to make the fix if there are any glitches!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment