How to Install Programs from SlackBuilds.org to your Slackware Linux System

How to Install Programs from SlackBuilds.org to your Slackware Linux System:

While SlackBuilds.org provides their own HOWTO version, I try to write one for them, in another way, a more detailed though still in pedagogical order for newbies, just incase their article doesn't find your fancy. This is written for People new to Slackware or newbies to Linux, but have successfully installed a slackware system, which isn't all that hard to begin with especially in the more later versions like 12.x or 13.x , if the text install didn't scare you off from installing Slackware then this tutorial shouldn't do much further scaring as well then.

* All commands to be typed in the terminal are indicated as underlined text. *


My Foolish Assumptions:

- I assume you know how to follow instructions, read and comprehend english.

- That you know what the terminal console is and can navigate and input basic commands. If you installed Slackware Linux, and can start a desktop environment such as KDE4, XFCE, LXDE and others on Slackware or better yet, just fully use the CLI, you should have some form of these basics.

- You have your stock Slackware System up and running and an internet connection, or one in a Virtual Machine with an internet connection.

- You have root priviledges to your system.

- I assume you have either a 32 bit or 64 bit PC system. to find out what system you have, at the terminal type in -   uname -m , the output is the one you will you use later on, for example if you got the 64 bit system it will say = x86_64

- You can use both the GUI for the Graphical and the CLI, or even better just the CLI. In this tutorial you can do use a mix of GUI and CLI, but not just fully GUI but this tutorial is entirely possible to use for CLI only, it's actually preferred, and the more you use slackware and Linux or Unix type systems the more you will use the terminal so why not get used to it.

- Know how to use a text editor. Examples: gedit, kwrite, kate, geany, leafpad, mousepad, vi/vim/gvim, emacs, xemacs, nano.

- You do not need to have shell scripting knowledge.

- Some experience with an easy to use hand holding Linux Distribution (like Ubuntu, Mandriva, Mageia, etc-etc.) or other OS with some minimal CLI experience, will really help you out.








The Basics in 11 steps:

(Good luck and do not be afraid, it really isn't that hard!)


1. Go to SlackBuilds.org website and either click the Repositories button and navigate through there to the program you want to install or type in the program your looking for in the search bar provided in slackbuilds, make sure to use the package made for the version for your system the default is usually the latest version at the time of this writing it was 13.37.

2. As an example I will use the program unrar, to keep things simple as it doesn't need any other packages or dependencies as it is normally called in linux terms to install before it. So go to the unrar program page of SlackBuilds.org.

3. In this page the following data will show, due to future changes the page could be different or totally changed however the slackbuilds.org have a set of rules that submitters for programs for slackbuilds follow, just pay attention to basics and you can easily adapt to changes and other variations. As of this writing the following data is found on the said unrar program in slackbuilds.


For this example I will use the needed live links so you may experiment from this tutorial.


SlackBuilds Repository

13.37 > System > unrar (4.0.7)


WinRAR is a powerful archive manager. Unrar is an opensource subset
of RAR from rarlab that can uncompress RAR images.

Maintained by: Niklas 'Nille' Åkerström
Approved by: dsomero
Keywords: rar,winrar,extract,compression,compress,zip,archive

Homepage:
http://www.rarlab.com
Source Downloads:
unrarsrc-4.0.7.tar.gz(41b0a9bca945b4ae2608421afd8f606e)

Download SlackBuild:
unrar.tar.gz
unrar.tar.gz.asc (FAQ)

(the SlackBuild does not include the source)
Individual Files:
• README
• slack-desc
• unrar.1
• unrar.SlackBuild
• unrar.info


- There are 2 live links here, the 2 live links could change in the future and end up broken, but the tutorial will still be adequate enough to show how to install.

- You should read whatever information each package contains, like the README, slack-desc, info, etc-etc just incase or other such info however for the most part, what I show you here are the most needed fundamental/s.

- FYI SlackBuilds website doesn't actually keep the binaries or source codes in their servers as a policy, so all links are external to slackbuilds.org, just the slackbuild scipts are hosted by them.

4. Anyways, First create a directory to hold the SlackBuild scripts, such as SlackBuilds for a directory..., great!, type in or paste the following command in your terminal - mkdir SlackBuilds

- You can change the name of the directory to whatever you like, but for this tutorial I use SlackBuilds for the name of that directory. After creating the directory, navigate into it, using the cd command -       cd SlackBuilds

5. So then you need to download the source download,you can either do that by clicking the link unrarsrc-4.0.7.tar.gz(41b0a9bca945b4ae2608421afd8f606e) by your browser or use copy link with your mouse, and paste it to your downloader, I prefer to use the terminal, so click your terminal program,
at the prompt(usually an $ for a normal user and a # for the root user)
type wget then click the space button on your keyboard and paste the url in or type it in, press enter

Example: - $ wget http://www.rarlab.com/rar/unrarsrc-4.0.7.tar.gz

Wait for it to finish downloading, or simultaneously Download the SlackBuild

And do exactly the same as you did for the one above.

Example: - $ wget http://slackbuilds.org/slackbuilds/13.37/system/unrar.tar.gz

Wait for it to finish downloading.

6. Once you've Downloaded both packages, extract the slackbuild.

- From the terminal, Type $ tar -zxvf unrar.tar.gz to extract the file to the current directory. Now you have a new directory called unrar.

- You can do this in your GUI by usually right clicking your mouse button the package.tar.gz and choosing the option extract here.

7. Move the unrarsrc-4.0.7.tar.gz inside the new unrar directory, by terminal -
$ mv unrarsrc-4.0.7.tar.gz unrar/

- By Graphical, click or highlight the unrarsrc-4.0.7.tar.gz file and drag it into the unrar directory or do a copy and paste into or a cut and paste into the directory.

8. Once the unrarsrc-4.0.7.tar.gz is inside the unrar directory, you should read the text files that it comes with, but more importantly, you need to find the SlackBuild script it will be named like this unrar.SlackBuild (or generically file.SlackBuild), from there make it executable with this command if it isn't already to play it safe just issue the command like so -
$ chmod +x unrar.SlackBuild

9. Open the unrar.SlackBuild with your chosen editor, Look for an ARCH text at the top of the file after all the comments - in this example it will be this:

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i486 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

- Do replace the i486 value with x86_64 if your system is a 64 bit otherwise it is likely a 32 bit and you need not change the value, as stated at the start of this tutorial to find out what your system is at the terminal type in :   uname -m
the value to print out is your system. And FYI an i386, i486, i686 are all 32 bit systems and are not x86_64 or 64 bit systems.

example for 64 bit change:

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=x86_64 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi


- And make sure also that the package source download version you have is the same as the one mentioned in the SlackBuild script in this example it is this:

example:

PRGNAM=unrar
VERSION=4.0.7
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}


- And as in this SlackBuild script and our package both at version 4.0.7 meaning they are the same, and that means that you need not change anything in this file. If however the version we had was newer for the source package downloaded say 4.0.9, you must edit the VERSION value and change it to VERSION=4.0.9 in the script, save and exit the editor program.

example for 4.0.9:

PRGNAM=unrar
VERSION=4.0.9
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}


10. Now it's time to build the program, from the command line, change into root, by typing in the terminal, and yes the space and the dash, matter :    su -

- And press enter, and input your root password and then enter again.

- If you were successful you should now have a # on your prompt instead of the typical $ prompt for normal/non-root users.

- From there issue the command, the dot slash is important
$ ./unrar.SlackBuild

- If all things went well it should start building the package and you will see tons of cryptic stuff roll down your terminal. And if everything is good and done for after the wait to build the package, it will end without error.

11. After the build process, the terminal console will indicate that your file has been built and can be found in the /tmp directory as default where slackbuild scripts from slackbuilds usually puts them. You can install directly from the same directory your in, by issuing the command as root -

installpkg /tmp/unrar.tgz

- It should then start to install it, if all goes well it will install without a hitch.

- And there you have it, you have successfully installed a program from the slackbuilds website, Congratulations.


* Note 1: If your packages chosen from slackbuilds needs dependencies, you must build and install those dependencies in the order mentioned, the information will be shown in the programs pages in slackbuilds, also if you do not meet this criteria properly you wont be able to install anyways.

* Note 2: Tip - After properly building the program before installing or after, save the binary file from the /tmp directory either by GUI or CLI, thats up to you, this way you will have a program already built as a backup and you can install whenever on your system/s, should you need to, saving time, the effort and and power, Hey, compiles task the processor which eats power.

* Note 3: The Binary Packages/Programs you can install in slackware with the package manager end with .tgz or .txz file extensions. The latter one has a much better compression algorithm and saves more space than .tgz, this could matter when your building and saving backups of your built files, regarding saving space. However installing by .tgz is faster, but by modern hardware it shouldn't matter so much. The .tgz has been the more common one as it's been the default for awhile, .txz was introduced to later versions of slackware, I think 13.0, so installing .tgz wont work out of the box for older slackware versions and their package manager.

* Note 4: Below shows the complete unrar.SlackBuild file used in this example for the sake of brevity:

#!/bin/sh

# Slackware build script for unrar

# Copyright 2006  Halim Issa <yallaone@gmail.com>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Updated by Andrew Brouwers
# Updated by Niklas 'Nille' Åkerström

PRGNAM=unrar
VERSION=4.0.7
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i486 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

DOCS="license.txt readme.txt"

case "$ARCH" in
  i486)      SLKCFLAGS="-O2 -march=i486 -mtune=i686"
             ;;
  i686)      SLKCFLAGS="-O2 -march=i686 -mtune=i686"
             ;;
  x86_64)    SLKCFLAGS="-O2 -fPIC"
             ;;
  *)         SLKCFLAGS="-O2"
             ;;
esac

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM
tar xvf $CWD/${PRGNAM}src-$VERSION.tar.gz
cd $PRGNAM
chown -R root:root .
chmod -R a-s,u+w,go+r-w .

make CXXFLAGS="$SLKCFLAGS" -f makefile.unix

install -D -m 755 unrar $PKG/usr/bin/unrar
strip --strip-unneeded $PKG/usr/bin/unrar

mkdir -p $PKG/usr/man/man1
gzip -9c $CWD/unrar.1 > $PKG/usr/man/man1/unrar.1.gz

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
chmod 0644 $PKG/usr/doc/$PRGNAM-$VERSION/*

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}



* Note 5: Sometimes the Source Downloads are actually already pre-built compiled packages that may just need some re-packaging, and may come with other files, not to worry, just download the program's slackbuild, extract the directory and put in the extra files inside, do the same steps, edit the needed information such as ARCH and VERSION in the SlackBuild Script. And generically it should be done. Sometimes the binary can be .deb or .rpm files these are actually linux binaries for easy installs for certain distributions .deb for debian and maybe other debian based distributions and .rpm for RHEL/Centos/SL distributions and clones or derivatives. You may even come across src deb and src rpm which are typically source files for those platforms with some extra configs.

* Note 6: Make sure to make the slackbuild script executable with the chmod +x file.SlackBuild command, failure to make the file executable will make hinder you from building the program/s.

* Note 7: Tip - Learn some Bourne or Bash shell scripting so you can script Linux and understand the slackbuild scripts if not create your very own slackbuild scripts and submit to the slackbuilds.org site to contribute to the community. These 2 shell scripting languages are the Norm in Linux, and bourne for even other *nix systems. Bash is based on Bourne and extends it's features but bash is at the very basic level compatible to the Bourne shell. No matter what it will be useful to you, and it's not at all that hard. You can also make this a stepping stone to learning other scripting languages be it shell or general programming interpreted types or even the full blown compiler/VM byte compiled type languages.

* Note 8: To avoid problems, It's preferred to keep and use one Terminal window only for this tutorial, to avoid confusion and whatever hassle or getting lost for newbie/s.

* Note 9: Some packages/programs do need dependencies some do not and even then there are some which ask if you want to include even other optional dependencies.

* Note 10: GUI=Graphical User Interface and CLI=Command Line Interface...

* Note 11: For window's users Directory is synonymous to mean folder in your world...

* Note 12: By Default the $ is a prompt for normal non-root users and the # is a prompt usually used for root users.






********* Should this help anyone at all, it is my pleasure to, and I will try to refine, edit and update this article whenever I can,

********* However you are solely responsible for your actions and what you do to your system/s, and that means, I cannot be held liable for anything you do wrong at all to any or all of your system/s, well I just had to add that disclaimer. :-P

********* Should you need extra help in slackware the best place to go to is the slackware subforums in Linuxquestions.org, which effectively is the official slackware forums anyways.

so,
Happy Slacking!