Lesson 7: Packages, Software, Libraries

Homepage Content Slides Video

Warning

This lesson is under construction. Learn from it at your own risk. If you have any feedback, please fill out our General Feedback Survey.

Software

Everything that isn’t hardware.

  • Code that is run on a Computer.
  • Binaries.
  • Scripts.
  • Packages

Libraries

  • Often used to make development easier.
  • Rarely run on it’s own.
  • Shared code.
  • Binaries are linked dynamically to libraries (kind of like DLL’s in Windows)
$ ldd /usr/bin/nano
  linux-vdso.so.1 =>  (0x00007ffc1fdcd000)
  libncursesw.so.5 => /lib64/libncursesw.so.5 (0x00007ff2cfaee000)
  libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007ff2cf8c4000)
  libc.so.6 => /lib64/libc.so.6 (0x00007ff2cf500000)
  libdl.so.2 => /lib64/libdl.so.2 (0x00007ff2cf2fc000)
  /lib64/ld-linux-x86-64.so.2 (0x000055e46c4b4000)

Package Management

  • Automagically manage software and libraries on your system.
  • Examples:
    • Android Play Store
    • Apple App store
    • Steam
    • apt (Debian/Ubuntu)
    • yum (CentOS/Fedora/RHEL)

Package Management

Take care of installation and removal of software

Yum vs. Apt

Yum

  • XML repository format
  • Automatic metadata syncing
  • Supports a plugin module system to make it extensible
  • Checks all dependencies before downloading

Apt

  • Upgrade and Dist-Upgrade
    • Dist-Upgrade applies intelligent upgrading decisions during a major system upgrade
  • Can completely remove all files including config files

Programming Language Package Managers

Examples:

  • Python: pip
  • Ruby: gem, rubygems
  • Haskell: cabal
  • NodeJS: npm
  • ... and so on forever ...

Other Package Managers

Portage
The Source-based package manager for Gentoo.
Pacman
The Simple Arch Linux Package manager.
Nix
A ‘Fully Functional/Transactional’ package manager.
Brew
An Open Source package manager for OSX.
Chocolatey
A package manager for Windows.

Installation from Source

How to install a package from source:

Exercise: Install sl

  1. Install the git, gcc, make and ncurses-devel packages via package manager.
  2. Clone https://github.com/mtoyoda/sl.git using git
  3. Build the software using make
  4. Copy the compiled sl binary into the directory ~/local/bin/.
  5. Update your $PATH to include $HOME/local/bin
  6. Run ‘whereis sl‘ to ensure it’s in your path
  7. Run sl and see what happens!

Answer: Install sl

$ sudo yum install git gcc make ncurses-devel
$ git clone https://github.com/mtoyoda/sl.git
$ cd sl
$ make
gcc -O -o sl sl.c -lncurses
$ mkdir -p ~/local/bin
$ cp sl ~/local/bin/
$ echo "export PATH=$HOME/local/bin:$PATH" >> ~/.bashrc
$ source ~/.bashrc
$ whereis sl
sl: /home/dobc/local/bin/sl
$ sl

Exercise: Install grep

  1. Check the current version of grep
  2. Double check it’s location using which
  3. Download the latest tarball: http://mirrors.kernel.org/gnu/grep/grep-3.1.tar.xz
  4. Unpack using tar
  5. cd into the unpacked folder
  6. Run ‘./configure --prefix=$HOME/local/‘, ‘make‘ and then ‘make install
  7. Run ‘hash -r‘ to ensure your environment knows about the new binary
  8. Check the current version of grep (it should be 3.1 now!)
  9. Double check it’s location using which

Answer: Install grep

$ grep --version
grep (GNU grep) 2.20
$ which grep
alias grep='grep --color=auto'
        /usr/bin/grep
$ wget http://mirrors.kernel.org/gnu/grep/grep-3.1.tar.xz
$ tar -Jxvf grep-3.1.tar.xz
$ cd grep-3.1
$ ./configure --prefix=$HOME/local/
$ make
$ make install
$ hash -r
$ grep --version
grep (GNU grep) 3.1
$ which grep
alias grep='grep --color=auto'
        ~/local/bin/grep

Further Reading