[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

Ceci est une ancienne révision du document !


Les scripts SlackBuild

Un script SlackBuild est un 'shell script' (généralement compatible avec le shell bash: Bourne-Again SHell.) dont le rôle est d'automatiser la configuration, la compilation et la création de paquets Slackware (des fichiers *.tgz, *.txz, *.tbz) à partir d'archives du code source.

Sommaire

La méthode générale pour créer un paquet Slackware à partir des sources peut être résumée comme suit, même si certains détails peuvent varier d'un système de construction à l'autre.

  1. Décompresser l'archive source (habituellement un fichier .tar.gz ou .tar.bz2) dans un “répertoire de travail.”
  2. Créer un fichier slack-desc, qui décrit le logiciel suivant un format normalisé.
  3. Configurer le fichier source, et appliquer les correctifs, si nécessaire.
  4. Lancer la compilation/construction sur les fichiers-source afin de produire les fichiers binaires.
  5. Installer le programme dans un répertoire provisoire. Cette étape peut s'avérer délicate, suivant quelle procédure dans make install (ou dans un outil semblable) est employée par le système d'agencement des paquets. Dans les Makefiles standards GNU, la variable DESTDIR passée à make install peut suffire. Dans le cas de Makefiles non-standards et de méthodes de construction de paquets où cette option n'est pas prévue, on devra envisager d'écrire des correctifs au Makefile (ou au fichier équivalent) on devra aussi adapter les réglages de la configuration du système de construction (build system).
  6. Copier la documentation du programme et les autres fichiers nécessaires (y compris les scripts de post-installation ) dans les sous-répertoires appropriés du répertoire temporaire d'installation. Le choix de ces emplacements doit respecter la structure adoptée par Slackware pour l'installation des programmes par le gestionnaire de paquets, à savoir dans le dossier /usr/.
  7. Employer l'utilitaire makepkg depuis le répertoire temporaire (où se fait l'installation, suivant le présent exemple) pour créer un paquet Slackware qu'on peut ensuite installer en appelant la commande installpkg.

Bien qu'on puisse faire à la main, point par point, ce qui vient d'être décrit, la démarche est ennuyeuse, parfois compliquée, et elle nécessite la saisie au clavier de beaucoup de commandes. L'automatisation de ce travail par un script shell permet à l'utilisateur de partager son processus avec l“ensemble de la communauté. De plus il est logique d'utiliser et de modifier des scripts SlackBuilds existants pour la mise à jour d'un programme donné vers une version plus récente.

Creating SlackBuild scripts

A good hands-on tutorial on creating a SlackBuild script can be found here, and there are also a few templates available to get a feeling for what is needed from a script.

However, software may be written in different programming languages, use different build systems, or may even simply be written in an interpreted programming language with no obvious way to “install” it. In such cases, many steps involved in writing a SlackBuild script will differ from the standard way. Blindly copying and pasting commands from other SlackBuild scripts may or may not work.

It is recommended that anybody who wishes to write a SlackBuild script, study and understand the build system of a software project before attempting to write a SlackBuild script for it. A degree of proficiency in writing shell scripts is also a definite benefit, as it is the practice to use Bourne shell compatible scripts for SlackBuilds. Ideally, simple C projects which use the standard GNU Make system is a good way to start practicing writing SlackBuild scripts.

For new script writers, it is a good idea to perform the above steps manually to create the package from source, before actually writing a SlackBuild script. This reduces the chances of bugs and unexpected behaviour in the script.

Submitting SlackBuild scripts to a public repository such as http://www.slackbuilds.org may additionally require adherence to certain conventions and coding standards. For instance, it would be necessary for the script to determine the target architecture at runtime rather than hard-coding it into the script. These standards attempt to make SlackBuild scripts as portable as possible.

Automated SlackBuild generators

Some tools exist that can assist you with creating a SlackBuild script. Here are a few examples.

Sources

  • Originally written by V.Harishankar for the SlackDocs Wiki Project

 fr:slackware:slackbuild_scripts ()