[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
slackware:package_management_hands_on [2014/02/09 16:41 (UTC)] kikinovakslackware:package_management_hands_on [2014/02/20 06:33 (UTC)] kikinovak
Line 465: Line 465:
 # installpkg /tmp/Terminal-0.4.8-i486-1.txz # installpkg /tmp/Terminal-0.4.8-i486-1.txz
 </code> </code>
 +
 +==== Modify an official Slackware package ====
 +
 +The main reason for rebuilding an official package is to modify it, for example to add or strip certain functionalities. In the following example, we will rebuild the ''audacious-plugins'' package in order to modify the Audacious audio player. The vanilla application sports two different graphical interfaces, and we will disable one of them.
 +
 +Let's begin with removing the package if it is installed:
 +
 +<code>
 +# removepkg audacious-plugins
 +</code>
 +
 +Now create a suitable directory to store the source code:
 +
 +<code>
 +# cd /root/source
 +# mkdir audacious-plugins
 +# cd audacious-plugins
 +# links mirrors.slackware.com 
 +</code>
 +
 +Fetch the contents of the ''/source/xap/audacious-plugins'' directory and make the ''audacious-plugins.SlackBuild'' script executable:
 +
 +<code>
 +# chmod +x audacious-plugins.SlackBuild
 +# ls -lh
 +total 1,4M
 +-rw-r--r-- 1 root root 1,4M nov.  24 15:28 audacious-plugins-3.3.1.tar.xz
 +-rwxr-xr-x 1 root root 4,0K nov.  24 15:28 audacious-plugins.SlackBuild*
 +-rw-r--r-- 1 root root  892 nov.  24 15:28 slack-desc
 +</code>
 +
 +Now edit ''audacious-plugins.SlackBuild'' and add one option:
 +
 +<code>
 +...
 +# Configure:
 +CFLAGS="$SLKCFLAGS" \
 +CXXFLAGS="$SLKCFLAGS" \
 +./configure \
 +  --prefix=/usr \
 +  --libdir=/usr/lib${LIBDIRSUFFIX} \
 +  --sysconfdir=/etc \
 +  --mandir=/usr/man \
 +  --enable-amidiplug \
 +  --disable-gtkui \          -> add this option
 +  --program-prefix= \
 +  --program-suffix= \
 +  ${ARCHOPTS} \
 +  --build=$ARCH-slackware-linux
 +...
 +</code>
 +
 +Build and install the package:
 +
 +<code>
 +# ./audacious-plugins.SlackBuild
 +...
 +Slackware package /tmp/audacious-plugins-3.3.1-i486-1.txz created.
 +# installpkg /tmp/audacious-plugins-3.3.1-i486-1.txz
 +</code>
 +
 +==== Choosing your configuration options for compiling ====
 +
 +The source configuration script (or more exactly the sometimes very long line in the SlackBuild beginning with ''./configure'') often displays an overview of activated and/or deactivated options. To interrupt the package construction process and display this overview, you can temporarily edit the SlackBuild like this:
 +
 +<code>
 +...
 +# Configure:
 +CFLAGS="$SLKCFLAGS" \
 +CXXFLAGS="$SLKCFLAGS" \
 +./configure \
 +  --prefix=/usr \
 +  --libdir=/usr/lib${LIBDIRSUFFIX} \
 +  --sysconfdir=/etc \
 +  --mandir=/usr/man \
 +  --enable-amidiplug \
 +  --program-prefix= \
 +  --program-suffix= \
 +  ${ARCHOPTS} \
 +  --build=$ARCH-slackware-linux
 +
 +exit 1          -> add this option to interrupt the script
 +
 +# Build and install:
 +make $NUMJOBS || make || exit 1
 +make install DESTDIR=$PKG || exit 1
 +... 
 +</code>
 +
 +Now run the script and wait a few seconds for the configuration overview:
 +
 +<code>
 +# ./audacious-plugins.SlackBuild
 +...
 +Configuration:
 +  
 +...
 +
 +Interfaces
 +----------
 +GTK (gtkui):                            yes
 +Winamp Classic (skins):                 yes
 +</code>
 +
 +Use the ''./configure --help'' option to display a list of all the possible options:
 +
 +<code>
 +# tar xvf audacious-plugins-3.3.1.tar.xz
 +# cd audacious-plugins-3.3.1
 +# ./configure --help | less
 +...
 +--disable-speedpitch    disable Speed and Pitch effect plugin
 +--disable-gtkui         disable GTK interface (gtkui)
 +--disable-skins         disable Winamp Classic interface (skins)
 +--disable-lyricwiki     disable LyricWiki plugin (default=enabled)
 +...
 +</code>
 +
 +<note tip>The SlackBuild script already takes care of automatically uncompressing the source tarball to the ''/tmp'' directory. So you can simply run ''./configure --help | less'' from this directory, without manually uncompressing the source tarball to the current directory.</note>
 +
 +<note>In the present case, activating certain functionalities like for example managing proprietary audio formats will depend on the presence of the corresponding libraries on your system.</note>
 +
 +Once you've chosen all your configuration options, get rid of the temporary ''exit 1'' command in your script and launch the build and installation process:
 +
 +<code>
 +# ./audacious-plugins.SlackBuild
 +...
 +Slackware package /tmp/audacious-plugins-3.3.1-i486-1.txz created.
 +# installpkg /tmp/audacious-plugins-3.3.1-i486-1.txz
 +</code>
 +
 +===== Building third-party packages =====
 +
 +Slackware offers only a limited choice of packages compared to behemoth distributions like Ubuntu or Debian. More often than not, you'll want to install a package that's not provided by the distribution. In that case, what can a poor boy do?
 +
 +The [[http://slackbuilds.org|SlackBuilds.org website]] is probably the best address to find third-party software. You won't find any packages there, because SlackBuilds.org is //not// a binary package repository nor will it ever be. It's an extremely clean and well organized collection of build scripts, each one reviewed and tested. Using these scripts will enable you to build about every piece of third party software under the sun.
 +  
 +==== Building packages using the SlackBuilds.org scripts ====
 +
 +In the following example, we will build and install the ''cowsay'' package using the build script provided by SlackBuilds.org. 
 +
 +For a start, ''cd'' into the build directory we've defined earlier:
 +
 +<code>
 +# cd /root/source
 +</code>
 +
 +Download the following components into this directory :
 +
 +  - the compressed tarball containing the scripts to build the package;
 +  - the compressed source code tarball.
 +
 +In our case:
 +
 +<code>
 +# links http://slackbuilds.org
 +</code>
 +
 +  - In the Search field in the upper left corner of the screen, type ''cowsay'', move the cursor to ''Search'' (CursorDown key) and confirm by hitting <key>Enter</key>.
 +  - Follow the ''cowsay'' link on the search results page.
 +  - Once you're on the ''cowsay'' page, download the SlackBuild (''cowsay.tar.gz'') and the source code (''cowsay-3.03.tar.gz'') and quit Links.
 +
 +<note tip>Alternatively, use ''lynx'' instead of ''links''.</note>
 +
 +Here's our two downloaded tarballs:
 +
 +<code>
 +# ls -l cowsay*
 +-rw-r--r-- 1 root root 15136 nov.  25 08:14 cowsay-3.03.tar.gz
 +-rw-r--r-- 1 root root  2855 nov.  25 08:14 cowsay.tar.gz
 +</code>
 +
 +Uncompress the tarball containing the scripts:
 +
 +<code>
 +# tar xvzf cowsay.tar.gz 
 +cowsay/
 +cowsay/cowsay.SlackBuild.patch
 +cowsay/README
 +cowsay/slack-desc
 +cowsay/cowsay.SlackBuild
 +cowsay/cowsay.info
 +</code>
 +
 +Eventually, you can do a little cleanup and delete the tarball:
 +
 +<code>
 +# rm -f cowsay.tar.gz
 +</code>
 +
 +Now move the source tarball to the newly created ''cowsay/'' directory:
 +
 +<code>
 +# mv -v cowsay-3.03.tar.gz cowsay/
 +« cowsay-3.03.tar.gz » -> « cowsay/cowsay-3.03.tar.gz »
 +</code>
 +
 +Here's what we have:
 +
 +<code>
 +# tree cowsay
 +cowsay
 +|-- cowsay-3.03.tar.gz
 +|-- cowsay.info
 +|-- cowsay.SlackBuild
 +|-- cowsay.SlackBuild.patch
 +|-- README
 +`-- slack-desc
 +</code>
 +
 +Now ''cd'' into that directory. Check if the ''cowsay'' SlackBuild is executable, and then launch it to start the package construction:
 +
 +<code>
 +# cd cowsay/
 +# ls -l cowsay.SlackBuild
 +-rwxr-xr-x 1 kikinovak users 1475 mai   27  2010 cowsay.SlackBuild*
 +# ./cowsay.SlackBuild
 +...
 +</code>
 +
 +If everything goes well, the process spews out a package in ''/tmp'', or more exactly in the ''$OUTPUT'' directory defined by the script:
 +
 +<code>
 +...
 +Slackware package /tmp/cowsay-3.03-noarch-1_SBo.tgz created.
 +</code>
 +
 +All that's left to do is install the package using ''installpkg'':
 +
 +<code>
 +# installpkg /tmp/cowsay-3.03-noarch-1_SBo.tgz 
 +# cowsay Hi there ! 
 + -------------
 +< Hi there ! >
 + ------------- 
 +        \   ^__^
 +          (oo)\_______
 +            (__)\       )\/\
 +                ||----w |
 +                ||     ||
 +</code>
 +
 +==== Managing package dependencies ====
 +
 +Some packages require the presence of other packages, either to build (//build dependencies//) and/or to run (//runtime dependencies) correctly. In some cases, a required package can depend itself on one or more other packages, and so on.
 +
 +To take an example, let's have a look at the ''libgnomeprint'' page on SlackBuilds.org. The package description is followed by the following caveat:
 +
 +<code>
 +This requires: libgnomecups.
 +</code>
 +
 +Moreover, every script tarball contains an ''*.info'' file which states explicitly all the required package dependencies. If we look at the ''libgnomeprint.info'' file, we'll find a ''REQUIRES'' field:
 +
 +<code>
 +PRGNAM="libgnomeprint"
 +VERSION="2.18.8"
 +HOMEPAGE="http://www.gnome.org"
 +...
 +REQUIRES="libgnomecups" ----> package dependency
 +...
 +</code>
 +
 +<note>The ''REQUIRES'' field has been introduced with Slackware 14.0.</note>
 +
 +This simply means that before we build the ''libgnomeprint'' package, we have to build and install the ''libgnomecups'' package.
 +
 +Besides strictly required dependencies, a package can also have some optional dependencies to offer some extra functionality. As an example, the Leafpad text editor can be built against the optional ''libgnomeprint'' and ''libgnomeprintui'' dependencies.
 +
  
 **WORK IN PROGRESS** **WORK IN PROGRESS**
 slackware:package_management_hands_on ()