Ceci est une ancienne révision du document !


Dernière mise-à-jour : 2020/02/21 05:23

LRF202 - Gestion des Paquets

LAB #1 - Compiler à partir des sources

Historiquement il était nécessaire d'installer un logiciel à partir de ses fichiers sources.

Pour comprendre ce qui est la compilation d'un logiciel, commencez par télécharger le logiciel hello :

[root@centos7 ~]# wget https://ftp.gnu.org/gnu/hello/hello-2.1.1.tar.gz
--2018-07-16 11:10:26--  https://ftp.gnu.org/gnu/hello/hello-2.1.1.tar.gz
Résolution de ftp.gnu.org (ftp.gnu.org)… 208.118.235.20
Connexion à ftp.gnu.org (ftp.gnu.org)|208.118.235.20|:443… connecté.
requête HTTP transmise, en attente de la réponse… 200 OK
Taille : 389363 (380K) [application/x-gzip]
Enregistre : «hello-2.1.1.tar.gz»

hello-2.1.1.tar.gz                100%[===========================================================>] 380,24K   946KB/s    ds 0,4s    

2018-07-16 11:10:27 (946 KB/s) - «hello-2.1.1.tar.gz» enregistré [389363/389363]

Ensuite désarchivez le logiciel :

[root@centos7 ~]# tar xvf hello-2.1.1.tar.gz
hello-2.1.1/
hello-2.1.1/intl/
hello-2.1.1/intl/ChangeLog
hello-2.1.1/intl/Makefile.in
hello-2.1.1/intl/config.charset
hello-2.1.1/intl/locale.alias
hello-2.1.1/intl/ref-add.sin
hello-2.1.1/intl/ref-del.sin
hello-2.1.1/intl/gmo.h
hello-2.1.1/intl/gettextP.h
hello-2.1.1/intl/hash-string.h
hello-2.1.1/intl/plural-exp.h
hello-2.1.1/intl/eval-plural.h
hello-2.1.1/intl/os2compat.h
hello-2.1.1/intl/libgnuintl.h
hello-2.1.1/intl/loadinfo.h
hello-2.1.1/intl/bindtextdom.c
hello-2.1.1/intl/dcgettext.c
hello-2.1.1/intl/dgettext.c
hello-2.1.1/intl/gettext.c
hello-2.1.1/intl/finddomain.c
hello-2.1.1/intl/loadmsgcat.c
hello-2.1.1/intl/localealias.c
hello-2.1.1/intl/textdomain.c
hello-2.1.1/intl/l10nflist.c
hello-2.1.1/intl/explodename.c
hello-2.1.1/intl/dcigettext.c
hello-2.1.1/intl/dcngettext.c
hello-2.1.1/intl/dngettext.c
hello-2.1.1/intl/ngettext.c
hello-2.1.1/intl/plural.y
hello-2.1.1/intl/plural-exp.c
hello-2.1.1/intl/localcharset.c
hello-2.1.1/intl/localename.c
hello-2.1.1/intl/osdep.c
hello-2.1.1/intl/os2compat.c
hello-2.1.1/intl/intl-compat.c
hello-2.1.1/intl/plural.c
hello-2.1.1/intl/VERSION
hello-2.1.1/po/
hello-2.1.1/po/Makefile.in.in
hello-2.1.1/po/Makevars
hello-2.1.1/po/remove-potcdate.sin
hello-2.1.1/po/quot.sed
hello-2.1.1/po/boldquot.sed
hello-2.1.1/po/en@quot.header
hello-2.1.1/po/en@boldquot.header
hello-2.1.1/po/insert-header.sin
hello-2.1.1/po/Rules-quot
hello-2.1.1/po/POTFILES.in
hello-2.1.1/po/hello.pot
hello-2.1.1/po/ca.po
hello-2.1.1/po/da.po
hello-2.1.1/po/de.po
hello-2.1.1/po/de_DE.po
hello-2.1.1/po/el.po
hello-2.1.1/po/eo.po
hello-2.1.1/po/es.po
hello-2.1.1/po/et.po
hello-2.1.1/po/fi.po
hello-2.1.1/po/fr.po
hello-2.1.1/po/gl.po
hello-2.1.1/po/he.po
hello-2.1.1/po/hr.po
hello-2.1.1/po/hu.po
hello-2.1.1/po/id.po
hello-2.1.1/po/it.po
hello-2.1.1/po/ja.po
hello-2.1.1/po/ko.po
hello-2.1.1/po/lv.po
hello-2.1.1/po/nb.po
hello-2.1.1/po/nl.po
hello-2.1.1/po/nn.po
hello-2.1.1/po/pl.po
hello-2.1.1/po/pt.po
hello-2.1.1/po/pt_BR.po
hello-2.1.1/po/ru.po
hello-2.1.1/po/sk.po
hello-2.1.1/po/sl.po
hello-2.1.1/po/sv.po
hello-2.1.1/po/tr.po
hello-2.1.1/po/uk.po
hello-2.1.1/po/ca.gmo
hello-2.1.1/po/da.gmo
hello-2.1.1/po/de.gmo
hello-2.1.1/po/de_DE.gmo
hello-2.1.1/po/el.gmo
hello-2.1.1/po/eo.gmo
hello-2.1.1/po/es.gmo
hello-2.1.1/po/et.gmo
hello-2.1.1/po/fi.gmo
hello-2.1.1/po/fr.gmo
hello-2.1.1/po/gl.gmo
hello-2.1.1/po/he.gmo
hello-2.1.1/po/hr.gmo
hello-2.1.1/po/hu.gmo
hello-2.1.1/po/id.gmo
hello-2.1.1/po/it.gmo
hello-2.1.1/po/ja.gmo
hello-2.1.1/po/ko.gmo
hello-2.1.1/po/lv.gmo
hello-2.1.1/po/nb.gmo
hello-2.1.1/po/nl.gmo
hello-2.1.1/po/nn.gmo
hello-2.1.1/po/pl.gmo
hello-2.1.1/po/pt.gmo
hello-2.1.1/po/pt_BR.gmo
hello-2.1.1/po/ru.gmo
hello-2.1.1/po/sk.gmo
hello-2.1.1/po/sl.gmo
hello-2.1.1/po/sv.gmo
hello-2.1.1/po/tr.gmo
hello-2.1.1/po/uk.gmo
hello-2.1.1/po/ChangeLog
hello-2.1.1/po/LINGUAS
hello-2.1.1/README
hello-2.1.1/ABOUT-NLS
hello-2.1.1/AUTHORS
hello-2.1.1/COPYING
hello-2.1.1/ChangeLog
hello-2.1.1/INSTALL
hello-2.1.1/Makefile.am
hello-2.1.1/Makefile.in
hello-2.1.1/NEWS
hello-2.1.1/THANKS
hello-2.1.1/TODO
hello-2.1.1/aclocal.m4
hello-2.1.1/config.guess
hello-2.1.1/config.h.in
hello-2.1.1/config.rpath
hello-2.1.1/config.sub
hello-2.1.1/configure
hello-2.1.1/configure.ac
hello-2.1.1/depcomp
hello-2.1.1/install-sh
hello-2.1.1/missing
hello-2.1.1/mkinstalldirs
hello-2.1.1/BUGS
hello-2.1.1/ChangeLog.O
hello-2.1.1/contrib/
hello-2.1.1/contrib/ChangeLog
hello-2.1.1/contrib/Makefile.am
hello-2.1.1/contrib/Makefile.in
hello-2.1.1/contrib/de_franconian_po.txt
hello-2.1.1/contrib/evolution.txt
hello-2.1.1/contrib/hello.1
hello-2.1.1/doc/
hello-2.1.1/doc/gpl.texi
hello-2.1.1/doc/ChangeLog
hello-2.1.1/doc/Makefile.am
hello-2.1.1/doc/Makefile.in
hello-2.1.1/doc/mdate-sh
hello-2.1.1/doc/stamp-vti
hello-2.1.1/doc/texinfo.tex
hello-2.1.1/doc/version.texi
hello-2.1.1/doc/hello.texi
hello-2.1.1/doc/hello.info
hello-2.1.1/src/
hello-2.1.1/src/ChangeLog
hello-2.1.1/src/Makefile.am
hello-2.1.1/src/Makefile.in
hello-2.1.1/src/alloca.c
hello-2.1.1/src/hello.c
hello-2.1.1/src/version.c
hello-2.1.1/src/getopt.c
hello-2.1.1/src/getopt1.c
hello-2.1.1/src/getopt.h
hello-2.1.1/src/system.h
hello-2.1.1/man/
hello-2.1.1/man/ChangeLog
hello-2.1.1/man/Makefile.am
hello-2.1.1/man/Makefile.in
hello-2.1.1/man/hello.1
hello-2.1.1/man/help2man
hello-2.1.1/m4/
hello-2.1.1/m4/README
hello-2.1.1/m4/ChangeLog
hello-2.1.1/m4/Makefile.am
hello-2.1.1/m4/Makefile.in
hello-2.1.1/m4/codeset.m4
hello-2.1.1/m4/gettext.m4
hello-2.1.1/m4/glibc21.m4
hello-2.1.1/m4/iconv.m4
hello-2.1.1/m4/isc-posix.m4
hello-2.1.1/m4/lcmessage.m4
hello-2.1.1/m4/lib-ld.m4
hello-2.1.1/m4/lib-link.m4
hello-2.1.1/m4/lib-prefix.m4
hello-2.1.1/m4/progtest.m4
hello-2.1.1/tests/
hello-2.1.1/tests/ChangeLog
hello-2.1.1/tests/Makefile.am
hello-2.1.1/tests/Makefile.in
hello-2.1.1/tests/hello-1
hello-2.1.1/tests/world-1
hello-2.1.1/tests/nothing-1

Changez de répertoire :

[root@centos7 ~]# cd hello-2.1.1/

A l'étude du fichier README, celui-ci nous renvoie vers le fichier INSTALL. Visualisez donc ce dernier :

[root@centos7 hello-2.1.1]# more INSTALL
Copyright 1994, 1995, 1996, 1999, 2000, 2001 Free Software Foundation,
Inc.

   This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.

Basic Installation
==================

   These are generic installation instructions.

   The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation.  It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions.  Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').

   It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring.  (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
--Plus--(11%)

La procédure expliquée est celle utilisée pour la plupart des installations manuelles, à savoir la saisie des quatre commandes suivantes.

./configure

Important : configure est un script chargé de créer les makefiles pour une architecture donnée. Les makefiles sont lus par la commande make.

[root@centos7 hello-2.1.1]# ./configure
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets ${MAKE}... yes
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for strerror in -lcposix... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for struct stat.st_blksize... yes
checking for msgfmt... /bin/msgfmt
checking for gmsgfmt... /bin/msgfmt
checking for xgettext... /bin/xgettext
checking for msgmerge... /bin/msgmerge
checking build system type... x86_64-unknown-linux
checking host system type... x86_64-unknown-linux
checking for ranlib... ranlib
checking for gcc option to accept ANSI C... none needed
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for off_t... yes
checking for size_t... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... yes
checking for working mmap... yes
checking whether we are using the GNU C Library 2.1 or newer... yes
checking for ld used by GCC... /bin/ld
checking if the linker (/bin/ld) is GNU ld... yes
checking for shared library run path origin... done
checking for iconv... yes
checking argz.h usability... yes
checking argz.h presence... yes
checking for argz.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking nl_types.h usability... yes
checking nl_types.h presence... yes
checking for nl_types.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... (cached) yes
checking for feof_unlocked... yes
checking for fgets_unlocked... yes
checking for getc_unlocked... yes
checking for getcwd... yes
checking for getegid... yes
checking for geteuid... yes
checking for getgid... yes
checking for getuid... yes
checking for mempcpy... yes
checking for munmap... yes
checking for putenv... yes
checking for setenv... yes
checking for setlocale... yes
checking for stpcpy... yes
checking for strcasecmp... yes
checking for strdup... yes
checking for strtoul... yes
checking for tsearch... yes
checking for __argz_count... yes
checking for __argz_stringify... yes
checking for __argz_next... yes
checking for iconv declaration... 
         extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for nl_langinfo and CODESET... yes
checking for LC_MESSAGES... yes
checking for bison... no
checking whether NLS is requested... yes
checking whether included gettext is requested... no
checking for GNU gettext in libc... yes
checking for perl... perl
configure: creating ./config.status
config.status: creating Makefile
config.status: creating contrib/Makefile
config.status: creating doc/Makefile
config.status: creating intl/Makefile
config.status: creating man/Makefile
config.status: creating po/Makefile.in
config.status: creating m4/Makefile
config.status: creating src/Makefile
config.status: creating tests/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
config.status: executing default commands

make

Important : make sert à appeler des commandes créant des fichiers nécessaires à l'installation du logiciel.

[root@centos7 hello-2.1.1]# make
make  all-recursive
make[1]: Entering directory `/root/hello-2.1.1'
Making all in contrib
make[2]: Entering directory `/root/hello-2.1.1/contrib'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/root/hello-2.1.1/contrib'
Making all in doc
make[2]: Entering directory `/root/hello-2.1.1/doc'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/root/hello-2.1.1/doc'
Making all in intl
make[2]: Entering directory `/root/hello-2.1.1/intl'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/root/hello-2.1.1/intl'
Making all in po
make[2]: Entering directory `/root/hello-2.1.1/po'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/root/hello-2.1.1/po'
Making all in src
make[2]: Entering directory `/root/hello-2.1.1/src'
source='hello.c' object='hello.o' libtool=no \
depfile='.deps/hello.Po' tmpdepfile='.deps/hello.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl    -g -O2 -c `test -f 'hello.c' || echo './'`hello.c
source='version.c' object='version.o' libtool=no \
depfile='.deps/version.Po' tmpdepfile='.deps/version.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl    -g -O2 -c `test -f 'version.c' || echo './'`version.c
source='getopt.c' object='getopt.o' libtool=no \
depfile='.deps/getopt.Po' tmpdepfile='.deps/getopt.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl    -g -O2 -c `test -f 'getopt.c' || echo './'`getopt.c
source='getopt1.c' object='getopt1.o' libtool=no \
depfile='.deps/getopt1.Po' tmpdepfile='.deps/getopt1.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl    -g -O2 -c `test -f 'getopt1.c' || echo './'`getopt1.c
gcc  -g -O2   -o hello  hello.o version.o getopt.o getopt1.o  
make[2]: Leaving directory `/root/hello-2.1.1/src'
Making all in man
make[2]: Entering directory `/root/hello-2.1.1/man'
perl help2man --name="Friendly Greeting Program" ../src/hello >hello.1
make[2]: Leaving directory `/root/hello-2.1.1/man'
Making all in m4
make[2]: Entering directory `/root/hello-2.1.1/m4'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/root/hello-2.1.1/m4'
Making all in tests
make[2]: Entering directory `/root/hello-2.1.1/tests'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/root/hello-2.1.1/tests'
make[2]: Entering directory `/root/hello-2.1.1'
make[2]: Leaving directory `/root/hello-2.1.1'
make[1]: Leaving directory `/root/hello-2.1.1'

make check

Important : make check permet de vérifier si la commande make a bien fonctionné.

[root@centos7 hello-2.1.1]# make check
Making check in contrib
make[1]: Entering directory `/root/hello-2.1.1/contrib'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/root/hello-2.1.1/contrib'
Making check in doc
make[1]: Entering directory `/root/hello-2.1.1/doc'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/root/hello-2.1.1/doc'
Making check in intl
make[1]: Entering directory `/root/hello-2.1.1/intl'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/root/hello-2.1.1/intl'
Making check in po
make[1]: Entering directory `/root/hello-2.1.1/po'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/root/hello-2.1.1/po'
Making check in src
make[1]: Entering directory `/root/hello-2.1.1/src'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/root/hello-2.1.1/src'
Making check in man
make[1]: Entering directory `/root/hello-2.1.1/man'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/root/hello-2.1.1/man'
Making check in m4
make[1]: Entering directory `/root/hello-2.1.1/m4'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/root/hello-2.1.1/m4'
Making check in tests
make[1]: Entering directory `/root/hello-2.1.1/tests'
make  check-TESTS
make[2]: Entering directory `/root/hello-2.1.1/tests'
PASS: hello-1
PASS: world-1
PASS: nothing-1
==================
All 3 tests passed
==================
make[2]: Leaving directory `/root/hello-2.1.1/tests'
make[1]: Leaving directory `/root/hello-2.1.1/tests'
make[1]: Entering directory `/root/hello-2.1.1'
make[1]: Leaving directory `/root/hello-2.1.1'

make install

Important : make install sert à installer le logiciel.

[root@centos7 hello-2.1.1]# make install
Making install in contrib
make[1]: Entering directory `/root/hello-2.1.1/contrib'
make[2]: Entering directory `/root/hello-2.1.1/contrib'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/hello-2.1.1/contrib'
make[1]: Leaving directory `/root/hello-2.1.1/contrib'
Making install in doc
make[1]: Entering directory `/root/hello-2.1.1/doc'
make[2]: Entering directory `/root/hello-2.1.1/doc'
make[2]: Nothing to be done for `install-exec-am'.
/bin/sh ../mkinstalldirs /usr/local/info
mkdir -p -- /usr/local/info
 /bin/install -c -m 644 ./hello.info /usr/local/info/hello.info
 install-info --info-dir=/usr/local/info /usr/local/info/hello.info
make[2]: Leaving directory `/root/hello-2.1.1/doc'
make[1]: Leaving directory `/root/hello-2.1.1/doc'
Making install in intl
make[1]: Entering directory `/root/hello-2.1.1/intl'
if test "hello" = "gettext" \
   && test '' = 'intl-compat.o'; then \
  /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/lib /usr/local/include; \
  /bin/install -c -m 644 libintl.h /usr/local/include/libintl.h; \
  @LIBTOOL@ --mode=install \
    /bin/install -c -m 644 libintl.a /usr/local/lib/libintl.a; \
else \
  : ; \
fi
if test 'no' = yes; then \
  test yes != no || /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/lib; \
  temp=/usr/local/lib/t-charset.alias; \
  dest=/usr/local/lib/charset.alias; \
  if test -f /usr/local/lib/charset.alias; then \
    orig=/usr/local/lib/charset.alias; \
    sed -f ref-add.sed $orig > $temp; \
    /bin/install -c -m 644 $temp $dest; \
    rm -f $temp; \
  else \
    if test yes = no; then \
      orig=charset.alias; \
      sed -f ref-add.sed $orig > $temp; \
      /bin/install -c -m 644 $temp $dest; \
      rm -f $temp; \
    fi; \
  fi; \
  /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share/locale; \
  test -f /usr/local/share/locale/locale.alias \
    && orig=/usr/local/share/locale/locale.alias \
    || orig=./locale.alias; \
  temp=/usr/local/share/locale/t-locale.alias; \
  dest=/usr/local/share/locale/locale.alias; \
  sed -f ref-add.sed $orig > $temp; \
  /bin/install -c -m 644 $temp $dest; \
  rm -f $temp; \
else \
  : ; \
fi
if test "hello" = "gettext"; then \
  /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share/gettext/intl; \
  /bin/install -c -m 644 VERSION /usr/local/share/gettext/intl/VERSION; \
  /bin/install -c -m 644 ChangeLog.inst /usr/local/share/gettext/intl/ChangeLog; \
  dists="COPYING.LIB-2.0 COPYING.LIB-2.1 Makefile.in config.charset locale.alias ref-add.sin ref-del.sin gmo.h gettextP.h hash-string.h plural-exp.h eval-plural.h os2compat.h libgnuintl.h loadinfo.h bindtextdom.c dcgettext.c dgettext.c gettext.c finddomain.c loadmsgcat.c localealias.c textdomain.c l10nflist.c explodename.c dcigettext.c dcngettext.c dngettext.c ngettext.c plural.y plural-exp.c localcharset.c localename.c osdep.c os2compat.c intl-compat.c"; \
  for file in $dists; do \
    /bin/install -c -m 644 ./$file \
		    /usr/local/share/gettext/intl/$file; \
  done; \
  chmod a+x /usr/local/share/gettext/intl/config.charset; \
  dists="plural.c"; \
  for file in $dists; do \
    if test -f $file; then dir=.; else dir=.; fi; \
    /bin/install -c -m 644 $dir/$file \
		    /usr/local/share/gettext/intl/$file; \
  done; \
  dists="xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c COPYING.LIB-2 gettext.h libgettext.h plural-eval.c"; \
  for file in $dists; do \
    rm -f /usr/local/share/gettext/intl/$file; \
  done; \
else \
  : ; \
fi
make[1]: Leaving directory `/root/hello-2.1.1/intl'
Making install in po
make[1]: Entering directory `/root/hello-2.1.1/po'
/bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share
mkdir -p -- /usr/local/share/locale/ca/LC_MESSAGES
installing ca.gmo as /usr/local/share/locale/ca/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/da/LC_MESSAGES
installing da.gmo as /usr/local/share/locale/da/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/de/LC_MESSAGES
installing de.gmo as /usr/local/share/locale/de/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/de_DE/LC_MESSAGES
installing de_DE.gmo as /usr/local/share/locale/de_DE/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/el/LC_MESSAGES
installing el.gmo as /usr/local/share/locale/el/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/eo/LC_MESSAGES
installing eo.gmo as /usr/local/share/locale/eo/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/es/LC_MESSAGES
installing es.gmo as /usr/local/share/locale/es/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/et/LC_MESSAGES
installing et.gmo as /usr/local/share/locale/et/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/fi/LC_MESSAGES
installing fi.gmo as /usr/local/share/locale/fi/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/fr/LC_MESSAGES
installing fr.gmo as /usr/local/share/locale/fr/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/gl/LC_MESSAGES
installing gl.gmo as /usr/local/share/locale/gl/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/he/LC_MESSAGES
installing he.gmo as /usr/local/share/locale/he/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/hr/LC_MESSAGES
installing hr.gmo as /usr/local/share/locale/hr/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/hu/LC_MESSAGES
installing hu.gmo as /usr/local/share/locale/hu/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/id/LC_MESSAGES
installing id.gmo as /usr/local/share/locale/id/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/it/LC_MESSAGES
installing it.gmo as /usr/local/share/locale/it/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/ja/LC_MESSAGES
installing ja.gmo as /usr/local/share/locale/ja/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/ko/LC_MESSAGES
installing ko.gmo as /usr/local/share/locale/ko/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/lv/LC_MESSAGES
installing lv.gmo as /usr/local/share/locale/lv/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/nb/LC_MESSAGES
installing nb.gmo as /usr/local/share/locale/nb/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/nl/LC_MESSAGES
installing nl.gmo as /usr/local/share/locale/nl/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/nn/LC_MESSAGES
installing nn.gmo as /usr/local/share/locale/nn/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/pl/LC_MESSAGES
installing pl.gmo as /usr/local/share/locale/pl/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/pt/LC_MESSAGES
installing pt.gmo as /usr/local/share/locale/pt/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/pt_BR/LC_MESSAGES
installing pt_BR.gmo as /usr/local/share/locale/pt_BR/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/ru/LC_MESSAGES
installing ru.gmo as /usr/local/share/locale/ru/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/sk/LC_MESSAGES
installing sk.gmo as /usr/local/share/locale/sk/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/sl/LC_MESSAGES
installing sl.gmo as /usr/local/share/locale/sl/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/sv/LC_MESSAGES
installing sv.gmo as /usr/local/share/locale/sv/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/tr/LC_MESSAGES
installing tr.gmo as /usr/local/share/locale/tr/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/uk/LC_MESSAGES
installing uk.gmo as /usr/local/share/locale/uk/LC_MESSAGES/hello.mo
if test "hello" = "gettext"; then \
  /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share/gettext/po; \
  for file in Makefile.in.in Makevars remove-potcdate.sin quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot  ; do \
    /bin/install -c -m 644 ./$file \
		    /usr/local/share/gettext/po/$file; \
  done; \
else \
  : ; \
fi
make[1]: Leaving directory `/root/hello-2.1.1/po'
Making install in src
make[1]: Entering directory `/root/hello-2.1.1/src'
make[2]: Entering directory `/root/hello-2.1.1/src'
/bin/sh ../mkinstalldirs /usr/local/bin
  /bin/install -c hello /usr/local/bin/hello
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/hello-2.1.1/src'
make[1]: Leaving directory `/root/hello-2.1.1/src'
Making install in man
make[1]: Entering directory `/root/hello-2.1.1/man'
make[2]: Entering directory `/root/hello-2.1.1/man'
make[2]: Nothing to be done for `install-exec-am'.
/bin/sh ../mkinstalldirs /usr/local/man/man1
mkdir -p -- /usr/local/man/man1
 /bin/install -c -m 644 ./hello.1 /usr/local/man/man1/hello.1
make[2]: Leaving directory `/root/hello-2.1.1/man'
make[1]: Leaving directory `/root/hello-2.1.1/man'
Making install in m4
make[1]: Entering directory `/root/hello-2.1.1/m4'
make[2]: Entering directory `/root/hello-2.1.1/m4'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/hello-2.1.1/m4'
make[1]: Leaving directory `/root/hello-2.1.1/m4'
Making install in tests
make[1]: Entering directory `/root/hello-2.1.1/tests'
make[2]: Entering directory `/root/hello-2.1.1/tests'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/hello-2.1.1/tests'
make[1]: Leaving directory `/root/hello-2.1.1/tests'
make[1]: Entering directory `/root/hello-2.1.1'
make[2]: Entering directory `/root/hello-2.1.1'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/hello-2.1.1'
make[1]: Leaving directory `/root/hello-2.1.1'

Il convient maintenant de tester le nouveau logiciel :

[root@centos7 hello-2.1.1]# hello
Hello, world!

Le logiciel hello a été correctement installé.

La commande rpm

A faire - Placez-vous dans le répertoire personnel de root grâce à la commande cd ~.

Afin de faciliter l'installation, la désinstallation et la gestion des logiciels (appelés paquets), CentOS et Red Hat utilisent un format de fichier de logiciels installables spécifique. Celui-ci s'appelle RPM pour Red Hat Package Manager. La commande utilisée pour manipuler ses paquets s'appelle aussi rpm.

Les options de la commande rpm sont :

[root@centos7 hello-2.1.1]# cd ~
[root@centos7 ~]# rpm --help
Usage: rpm [OPTION...]

Query/Verify package selection options:
  -a, --all                        query/verify all packages
  -f, --file                       query/verify package(s) owning file
  -g, --group                      query/verify package(s) in group
  -p, --package                    query/verify a package file
  --pkgid                          query/verify package(s) with package
                                   identifier
  --hdrid                          query/verify package(s) with header
                                   identifier
  --triggeredby                    query the package(s) triggered by the
                                   package
  --whatrequires                   query/verify the package(s) which require a
                                   dependency
  --whatprovides                   query/verify the package(s) which provide a
                                   dependency
  --nomanifest                     do not process non-package files as
                                   manifests

Query options (with -q or --query):
  -c, --configfiles                list all configuration files
  -d, --docfiles                   list all documentation files
  -L, --licensefiles               list all license files
  --dump                           dump basic file information
  -l, --list                       list files in package
  --queryformat=QUERYFORMAT        use the following query format
  -s, --state                      display the states of the listed files

Verify options (with -V or --verify):
  --nofiledigest                   don't verify digest of files
  --nofiles                        don't verify files in package
  --nodeps                         don't verify package dependencies
  --noscript                       don't execute verify script(s)

Install/Upgrade/Erase options:
  --allfiles                       install all files, even configurations
                                   which might otherwise be skipped
  --allmatches                     remove all packages which match <package>
                                   (normally an error is generated if
                                   <package> specified multiple packages)
  --badreloc                       relocate files in non-relocatable package
  -e, --erase=<package>+           erase (uninstall) package
  --excludedocs                    do not install documentation
  --excludepath=<path>             skip files with leading component <path> 
  --force                          short hand for --replacepkgs --replacefiles
  -F, --freshen=<packagefile>+     upgrade package(s) if already installed
  -h, --hash                       print hash marks as package installs (good
                                   with -v)
  --ignorearch                     don't verify package architecture
  --ignoreos                       don't verify package operating system
  --ignoresize                     don't check disk space before installing
  -i, --install                    install package(s)
  --justdb                         update the database, but do not modify the
                                   filesystem
  --nodeps                         do not verify package dependencies
  --nofiledigest                   don't verify digest of files
  --nocontexts                     don't install file security contexts
  --noorder                        do not reorder package installation to
                                   satisfy dependencies
  --noscripts                      do not execute package scriptlet(s)
  --notriggers                     do not execute any scriptlet(s) triggered
                                   by this package
  --nocollections                  do not perform any collection actions
  --oldpackage                     upgrade to an old version of the package
                                   (--force on upgrades does this
                                   automatically)
  --percent                        print percentages as package installs
  --prefix=<dir>                   relocate the package to <dir>, if
                                   relocatable
  --relocate=<old>=<new>           relocate files from path <old> to <new>
  --replacefiles                   ignore file conflicts between packages
  --replacepkgs                    reinstall if the package is already present
  --test                           don't install, but tell if it would work or
                                   not
  -U, --upgrade=<packagefile>+     upgrade package(s)

Common options for all rpm modes and executables:
  -D, --define='MACRO EXPR'        define MACRO with value EXPR
  --undefine=MACRO                 undefine MACRO
  -E, --eval='EXPR'                print macro expansion of EXPR
  --macros=<FILE:...>              read <FILE:...> instead of default file(s)
  --nodigest                       don't verify package digest(s)
  --nosignature                    don't verify package signature(s)
  --rcfile=<FILE:...>              read <FILE:...> instead of default file(s)
  -r, --root=ROOT                  use ROOT as top level directory (default:
                                   "/")
  --dbpath=DIRECTORY               use database in DIRECTORY
  --querytags                      display known query tags
  --showrc                         display final rpmrc and macro configuration
  --quiet                          provide less detailed output
  -v, --verbose                    provide more detailed output
  --version                        print the version of rpm being used

Options implemented via popt alias/exec:
  --scripts                        list install/erase scriptlets from
                                   package(s)
  --setperms                       set permissions of files in a package
  --setugids                       set user/group ownership of files in a
                                   package
  --conflicts                      list capabilities this package conflicts
                                   with
  --obsoletes                      list other packages removed by installing
                                   this package
  --provides                       list capabilities that this package provides
  --requires                       list capabilities required by package(s)
  --info                           list descriptive information from package(s)
  --changelog                      list change logs for this package
  --xml                            list metadata in xml
  --triggers                       list trigger scriptlets from package(s)
  --last                           list package(s) by install time, most
                                   recent first
  --dupes                          list duplicated packages
  --filesbypkg                     list all files from each package
  --fileclass                      list file names with classes
  --filecolor                      list file names with colors
  --fscontext                      list file names with security context from
                                   file system
  --fileprovide                    list file names with provides
  --filerequire                    list file names with requires
  --filecaps                       list file names with POSIX1.e capabilities

Help options:
  -?, --help                       Show this help message
  --usage                          Display brief usage message

Configuration

Le fichier de configuration principal de la commande rpm est /usr/lib/rpm/rpmrc :

[root@centos7 ~]# more /usr/lib/rpm/rpmrc
#/*! \page config_rpmrc Default configuration: /usr/lib/rpm/rpmrc
# \verbatim
#
# This is a global RPM configuration file. All changes made here will
# be lost when the rpm package is upgraded. Any per-system configuration
# should be added to /etc/rpmrc, while per-user configuration should
# be added to ~/.rpmrc.
#
#############################################################
# Values for RPM_OPT_FLAGS for various platforms

# "fat" binary with both archs, for Darwin
optflags: fat -O2 -g -arch i386 -arch ppc

optflags: i386 -O2 -g -march=i386 -mtune=i686
optflags: i486 -O2 -g -march=i486
optflags: i586 -O2 -g -march=i586
optflags: i686 -O2 -g -march=i686
optflags: pentium3 -O2 -g -march=pentium3
optflags: pentium4 -O2 -g -march=pentium4
optflags: athlon -O2 -g -march=athlon
optflags: geode -Os -g -m32 -march=geode
optflags: ia64 -O2 -g
--More--(5%)

Ces directives indiquent comment optimiser la construction d'un rpm en fonction du type de processeur retourné par la commande uname -p. Par exemple, la directive buildarchtranslate: athlon: i386 indique que le processus doit utiliser les optimisations i386 lors de la construction d'un src.rpm sur une architecture athlon. Si au contraire il est souhaité que les optimisations athlon soient utilisées, il convient d'inclure la ligne buildarchtranslate: athlon: athlon dans le fichier /etc/rpmrc. En effet lors de la mise à jour du paquet rpm, le fichier /usr/lib/rpm/rpmrc est écrasé. Toute modification des directives de ce fichier doivent être inscrites dans /etc/rpmrc ou dans un fichier ~/.rpmrc spécifique à un utilisateur.

LAB #2 - Utilisation

Afin de connaître la liste des paquets installés sur la machine, il convient de saisir la commande suivante dans une console en tant que root :

[root@centos7 ~]# rpm -qa | more
gjs-1.36.1-2.el7.x86_64
mesa-libxatracker-9.2.5-5.20131218.el7.x86_64
gvfs-mtp-1.16.4-7.el7.x86_64
policycoreutils-2.2.5-11.el7.x86_64
setup-2.8.71-4.el7.noarch
libXmu-1.1.1-5.1.el7.x86_64
gettext-libs-0.18.2.1-4.el7.x86_64
mousetweaks-3.8.0-3.el7.x86_64
libquvi-0.4.1-5.el7.x86_64
langtable-0.0.13-4.el7.noarch
jline-1.0-8.el7.noarch
perl-Encode-2.51-7.el7.x86_64
gnome-system-log-3.8.1-5.el7.x86_64
libreport-plugin-ureport-2.1.11-10.el7.centos.x86_64
basesystem-10.0-7.el7.centos.noarch
festvox-slt-arctic-hts-0.20061229-28.el7.noarch
perl-threads-shared-1.43-6.el7.x86_64
firefox-24.5.0-1.el7.centos.x86_64
sbc-1.0-5.el7.x86_64
tigervnc-license-1.2.80-0.30.20130314svn5065.el7.noarch
poppler-utils-0.22.5-6.el7.x86_64
perl-Pod-Simple-3.28-4.el7.noarch
systemtap-runtime-2.4-14.el7.x86_64
--More--

Afin de connaître le nombre total de paquets installés sur la machine, utilisez la commande suivante :

[root@centos7 ~]# rpm -qa | wc -l
1194

Imaginons maintenant que vous souhaitez vérifier si un paquet contenant la chaine de caractères setup soit déjà installé sur la machine. Dans ce cas, il convient d'utiliser une commande telle la suivante :

[root@centos7 ~]# rpm -qa | grep setup
setup-2.8.71-4.el7.noarch
cryptsetup-libs-1.6.3-2.el7.x86_64
cryptsetup-python-1.6.3-2.el7.x86_64
ibus-setup-1.5.3-11.el7.noarch
gnome-initial-setup-0.13.1-4.el7.x86_64
cryptsetup-1.6.3-2.el7.x86_64
initial-setup-0.3.9.12-1.el7.x86_64
setuptool-1.19.11-8.el7.x86_64
python-setuptools-0.9.8-3.el7.noarch

Afin de connaître les détails du paquet setup-2.8.71-4.el7.noarch, il convient de saisir la commande suivante :

[root@centos7 ~]# rpm -qi setup
Name        : setup
Version     : 2.8.71
Release     : 4.el7
Architecture: noarch
Install Date: Sun 08 Mar 2015 01:41:33 PM CET
Group       : System Environment/Base
Size        : 696310
License     : Public Domain
Signature   : RSA/SHA256, Fri 04 Jul 2014 06:59:13 AM CEST, Key ID 24c6a8a7f4a80eb5
Source RPM  : setup-2.8.71-4.el7.src.rpm
Build Date  : Tue 10 Jun 2014 04:04:36 AM CEST
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : https://fedorahosted.org/setup/
Summary     : A set of system configuration and setup files
Description :
The setup package contains a set of important system configuration and
setup files, such as passwd, group, and profile.

Afin de lister tous les fichiers installés par le paquet concerné, utilisez la commande suivante :

[root@centos7 ~]# rpm -ql setup
/etc/aliases
/etc/bashrc
/etc/csh.cshrc
/etc/csh.login
/etc/environment
/etc/exports
/etc/filesystems
/etc/fstab
/etc/group
/etc/gshadow
/etc/host.conf
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny
/etc/inputrc
/etc/motd
/etc/passwd
/etc/printcap
/etc/profile
/etc/profile.d
/etc/protocols
/etc/securetty
/etc/services
/etc/shadow
/etc/shells
/usr/share/doc/setup-2.8.71
/usr/share/doc/setup-2.8.71/COPYING
/usr/share/doc/setup-2.8.71/uidgid
/var/log/lastlog

A l'inverse, si vous connaissez le nom d'un fichier et vous souhaitez savoir quel paquet l'a installé, utilisez la commande suivante :

[root@centos7 ~]# rpm -qf /etc/exports
setup-2.8.71-4.el7.noarch

Pour connaître les fichiers modifiés depuis l'installation d'un paquet, utilisez la commande suivante :

# rpm -qV setup [Entrée]

Dans le cas où aucun fichier n'a été modifié, la console n'affiche rien. Dans le cas où les fichiers ont été modifiés, le système vous indique, fichier par fichier, les modifications apportées selon le tableau ci-dessous. Pour plus d'informations utilisez les commandes man et info :

Lettre ou mot Clé Description
5 Contrôle MD5
S Taille du fichier
L Lien symbolique
T Date de modification
D Périphérique
U Utilisateur propriétaire
G Groupe propriétaire
M Droits d'accès
? Fichier illisible
Manquant Fichier manquant

Important : Un paquet rpm est un fichier cpio modifié. Pour pouvoir extraire le contenu d'un src.rpm et explorer l'arborescence utilisé pour construire le paquet, utilisez la commande rpm2cpio paquet.src.rpm | cpio -i –make-directories

La commande yum

Yellow dog Updater, Modified (Yum) est le nom d'un programme utilitaire de gestion de paquets pour le système d'exploitation Linux, créé par Yellow Dog Linux et utilisé par CentOS, Redhat et Fedora. Il est à noter qu'il existe plusieurs interfaces graphiques pour yum, notamment yumex et kyum

Il permet de gérer l'installation et la mise à jour des logiciels installés. C'est une surcouche à RPM gérant les téléchargements et les dépendances, de la même manière que APT pour Debian, urpmi pour Mandriva et zypper pour SLES/openSUSE.

La commande yum prend la forme suivante :

# yum <options> <commande> <paquet(s)> [Entrée]

Les options et commandes de yum sont :

[root@centos7 ~]# yum --help
Loaded plugins: fastestmirror, langpacks
Usage: yum [options] COMMAND

List of Commands:

check          Check for problems in the rpmdb
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade      downgrade a package
erase          Remove a package or packages from your system
fs             Creates filesystem snapshots, or lists/deletes current snapshots.
fssnapshot     Creates filesystem snapshots, or lists/deletes current snapshots.
groups         Display, or use, the groups information
help           Display a helpful usage message
history        Display, or use, the transaction history
info           Display details about a package or group of packages
install        Install a package or packages on your system
langavailable  Check available languages
langinfo       List languages information
langinstall    Install appropriate language packs for a language
langlist       List installed languages
langremove     Remove installed language packs for a language
list           List a package or groups of packages
load-transaction load a saved transaction from filename
makecache      Generate the metadata cache
provides       Find what package provides the given value
reinstall      reinstall a package
repo-pkgs      Treat a repo. as a group of packages, so we can install/remove all of them
repolist       Display the configured software repositories
search         Search package details for the given string
shell          Run an interactive yum shell
swap           Simple way to swap packages, instead of using shell
update         Update a package or packages on your system
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo     Acts on repository update information
upgrade        Update packages taking obsoletes into account
version        Display a version for the machine and/or available repos.


Options:
  -h, --help            show this help message and exit
  -t, --tolerant        be tolerant of errors
  -C, --cacheonly       run entirely from system cache, don't update cache
  -c [config file], --config=[config file]
                        config file location
  -R [minutes], --randomwait=[minutes]
                        maximum command wait time
  -d [debug level], --debuglevel=[debug level]
                        debugging output level
  --showduplicates      show duplicates, in repos, in list/search commands
  -e [error level], --errorlevel=[error level]
                        error output level
  --rpmverbosity=[debug level name]
                        debugging output level for rpm
  -q, --quiet           quiet operation
  -v, --verbose         verbose operation
  -y, --assumeyes       answer yes for all questions
  --assumeno            answer no for all questions
  --version             show Yum version and exit
  --installroot=[path]  set install root
  --enablerepo=[repo]   enable one or more repositories (wildcards allowed)
  --disablerepo=[repo]  disable one or more repositories (wildcards allowed)
  -x [package], --exclude=[package]
                        exclude package(s) by name or glob
  --disableexcludes=[repo]
                        disable exclude from main, for a repo or for
                        everything
  --disableincludes=[repo]
                        disable includepkgs for a repo or for everything
  --obsoletes           enable obsoletes processing during updates
  --noplugins           disable Yum plugins
  --nogpgcheck          disable gpg signature checking
  --disableplugin=[plugin]
                        disable plugins by name
  --enableplugin=[plugin]
                        enable plugins by name
  --skip-broken         skip packages with depsolving problems
  --color=COLOR         control whether color is used
  --releasever=RELEASEVER
                        set value of $releasever in yum config and repo files
  --downloadonly        don't update, just download
  --downloaddir=DLDIR   specifies an alternate directory to store packages
  --setopt=SETOPTS      set arbitrary config and repo options
  --bugfix              Include bugfix relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory=ADVS, --advisories=ADVS
                        Include packages needed to fix the given advisory, in
                        updates
  --bzs=BZS             Include packages needed to fix the given BZ, in
                        updates
  --cves=CVES           Include packages needed to fix the given CVE, in
                        updates
  --sec-severity=SEVS, --secseverity=SEVS
                        Include security relevant packages matching the
                        severity, in updates

  Plugin Options:

Configuration

La configuration principale de yum est effectuée en éditant le fichier /etc/yum.conf :

[root@centos7 ~]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release


#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
# exclude=httpd php mysql

Dépôts

Important : Un dépôt est un lieu de stockage de paquets binaires prêts à installer. Un dépôt peut être le DVD d'installation de la distribution, un dossier sur disque dur ou bien des serveurs distants accessibles par Internet.

Les dépôts de paquets sont spécifiés soit dans le fichier /etc/yum.conf, soit dans un fichier par dépôt stocké dans le répertoire /etc/yum.repos.d :

[root@centos7 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-Vault.repo

Par exemple :

[root@centos7 ~]# cat /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Utilisation

Les options les plus utilisées de yum sont :

Option Description
-y Réponse automatique de oui à toute question posée par yum.
-t Rend yum tolérant de certaines erreurs. Par exemple si deux paquets sont installés en même temps, une erreur de l'installation du premier paquet ne va pas arrêter l'installation du deuxième.
- -exclude=<nom paquet> Exclue le paquet indiqué de la transaction en cours

Les commandes les plus utilisées de yum sont :

Commande Description
install Installer un ou plusieurs paquets.
update Mettre à jour un ou plusieurs paquets. Sans nom(s) de paquet(s), tous les paquets sont mis à jour.
check-update Visualiser une liste de mise à jour disponibles pour les paquets installés.
remove Supprimer un paquet
provides Visualiser une liste de paquets qui fournissent le fichier ou caractéristique spécifié.
search Trouver un paquet qui a la chaîne recherchée dans sa description.
list Trouver un paquet qui a la chaîne recherchée dans son nom.
localinstall Installer un ou plusieurs paquets stockés localement sur disque.

La Commande yumdownloader

La commande yumdownloader est utilisée pour télécharger un paquet à partir d'un dépôt sans l'installer.

Cette commande prend la forme :

# yumdownloader --destdir /chemin paquet

Options de la Commande

Les options de la commande sont :

[root@centos7 ~]# yumdownloader --help
Loaded plugins: fastestmirror, langpacks
Usage: "yumdownloader [options] package1 [package2] [package..]

Options:
  Plugin Options:

  Yum Base Options:
    -h, --help          show this help message and exit
    -t, --tolerant      be tolerant of errors
    -C, --cacheonly     run entirely from system cache, don't update cache
    -c [config file], --config=[config file]
                        config file location
    -R [minutes], --randomwait=[minutes]
                        maximum command wait time
    -d [debug level], --debuglevel=[debug level]
                        debugging output level
    --showduplicates    show duplicates, in repos, in list/search commands
    -e [error level], --errorlevel=[error level]
                        error output level
    --rpmverbosity=[debug level name]
                        debugging output level for rpm
    -q, --quiet         quiet operation
    -v, --verbose       verbose operation
    -y, --assumeyes     answer yes for all questions
    --assumeno          answer no for all questions
    --version           show Yum version and exit
    --installroot=[path]
                        set install root
    --enablerepo=[repo]
                        enable one or more repositories (wildcards allowed)
    --disablerepo=[repo]
                        disable one or more repositories (wildcards allowed)
    -x [package], --exclude=[package]
                        exclude package(s) by name or glob
    --disableexcludes=[repo]
                        disable exclude from main, for a repo or for
                        everything
    --disableincludes=[repo]
                        disable includepkgs for a repo or for everything
    --obsoletes         enable obsoletes processing during updates
    --noplugins         disable Yum plugins
    --nogpgcheck        disable gpg signature checking
    --disableplugin=[plugin]
                        disable plugins by name
    --enableplugin=[plugin]
                        enable plugins by name
    --skip-broken       skip packages with depsolving problems
    --color=COLOR       control whether color is used
    --releasever=RELEASEVER
                        set value of $releasever in yum config and repo files
    --downloadonly      don't update, just download
    --downloaddir=DLDIR
                        specifies an alternate directory to store packages
    --setopt=SETOPTS    set arbitrary config and repo options
    --bugfix            Include bugfix relevant packages, in updates
    --security          Include security relevant packages, in updates
    --advisory=ADVS, --advisories=ADVS
                        Include packages needed to fix the given advisory, in
                        updates
    --bzs=BZS           Include packages needed to fix the given BZ, in
                        updates
    --cves=CVES         Include packages needed to fix the given CVE, in
                        updates
    --sec-severity=SEVS, --secseverity=SEVS
                        Include security relevant packages matching the
                        severity, in updates

  yumdownloader options:
    --destdir=DESTDIR   destination directory (defaults to current directory)
    --urls              just list the urls it would download instead of
                        downloading
    --resolve           resolve dependencies and download required packages
    --source            operate on source packages
    --archlist=ARCHLIST
                        only download packages of certain architecture(s)

LAB #3 - Utiliser la commande yum

Commencer par installer le paquet mc :

[root@centos7 ~]# yum install mc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: fr2.rpmfind.net
 * extras: mirror.ibcp.fr
 * updates: mirror.ibcp.fr
Resolving Dependencies
--> Running transaction check
---> Package mc.x86_64 1:4.8.7-8.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package       Arch              Version                  Repository       Size
================================================================================
Installing:
 mc            x86_64            1:4.8.7-8.el7            base            1.7 M

Transaction Summary
================================================================================
Install  1 Package

Total download size: 1.7 M
Installed size: 5.6 M
Is this ok [y/d/N]: y
Downloading packages:
mc-4.8.7-8.el7.x86_64.rpm                                  | 1.7 MB   00:15     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:mc-4.8.7-8.el7.x86_64                                      1/1 
  Verifying  : 1:mc-4.8.7-8.el7.x86_64                                      1/1 

Installed:
  mc.x86_64 1:4.8.7-8.el7                                                       

Complete!

Important : mc est un gestionnaire de fichiers utile en mode ligne de commande. Tapez la commande mc et expérimentez avec l'interface.

Supprimez maintenant le paquet mc :

[root@centos7 ~]# yum remove mc
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package mc.x86_64 1:4.8.7-8.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package      Arch             Version                    Repository       Size
================================================================================
Removing:
 mc           x86_64           1:4.8.7-8.el7              @base           5.6 M

Transaction Summary
================================================================================
Remove  1 Package

Installed size: 5.6 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:mc-4.8.7-8.el7.x86_64                                      1/1 
  Verifying  : 1:mc-4.8.7-8.el7.x86_64                                      1/1 

Removed:
  mc.x86_64 1:4.8.7-8.el7                                                       

Complete!

Recherchez le paquet mc :

[root@centos7 ~]# yum list mc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: fr2.rpmfind.net
 * extras: mirror.ibcp.fr
 * updates: mirror.ibcp.fr
Available Packages
mc.x86_64                           1:4.8.7-8.el7                           base

Recherchez tout paquet commençant par kerne :

[root@centos7 ~]# yum list kerne\*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: fr2.rpmfind.net
 * extras: mirror.ibcp.fr
 * updates: mirror.ibcp.fr
Installed Packages
kernel.x86_64                            3.10.0-123.el7                @anaconda
kernel-devel.x86_64                      3.10.0-229.14.1.el7           @updates 
kernel-headers.x86_64                    3.10.0-229.14.1.el7           @updates 
kernel-tools.x86_64                      3.10.0-123.el7                @anaconda
kernel-tools-libs.x86_64                 3.10.0-123.el7                @anaconda
Available Packages
kernel.x86_64                            3.10.0-229.14.1.el7           updates  
kernel-abi-whitelists.noarch             3.10.0-229.14.1.el7           updates  
kernel-debug.x86_64                      3.10.0-229.14.1.el7           updates  
kernel-debug-devel.x86_64                3.10.0-229.14.1.el7           updates  
kernel-doc.noarch                        3.10.0-229.14.1.el7           updates  
kernel-tools.x86_64                      3.10.0-229.14.1.el7           updates  
kernel-tools-libs.x86_64                 3.10.0-229.14.1.el7           updates  
kernel-tools-libs-devel.x86_64           3.10.0-229.14.1.el7           updates 

Recherchez la chaîne mc :

[root@centos7 ~]# yum search mc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: fr2.rpmfind.net
 * extras: mirror.ibcp.fr
 * updates: mirror.ibcp.fr
=============================== N/S matched: mc ================================
abrt-addon-vmcore.x86_64 : abrt's vmcore addon
bmc-snmp-proxy.noarch : Reconfigure SNMP to include host SNMP agent within BMC
exchange-bmc-os-info.noarch : Let OS and BMC exchange info
freeipmi-bmc-watchdog.x86_64 : IPMI BMC watchdog
hamcrest-demo.noarch : Demos for hamcrest
hamcrest-javadoc.noarch : Javadoc for hamcrest
libXdmcp-devel.i686 : Development files for libXdmcp
libXdmcp-devel.x86_64 : Development files for libXdmcp
libXvMC.i686 : X.Org X11 libXvMC runtime library
libXvMC.x86_64 : X.Org X11 libXvMC runtime library
libXvMC-devel.i686 : X.Org X11 libXvMC development package
libXvMC-devel.x86_64 : X.Org X11 libXvMC development package
libmemcached.i686 : Client library and command line tools for memcached server
libmemcached.x86_64 : Client library and command line tools for memcached server
libmemcached-devel.i686 : Header files and development libraries for
                        : libmemcached
libmemcached-devel.x86_64 : Header files and development libraries for
                          : libmemcached
memcached-devel.i686 : Files needed for development using memcached protocol
memcached-devel.x86_64 : Files needed for development using memcached protocol
php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
python-memcached.noarch : A Python memcached client library
smc-fonts-common.noarch : Common files for smc-fonts
tomcat-admin-webapps.noarch : The host-manager and manager web applications for
                            : Apache Tomcat
tomcat-docs-webapp.noarch : The docs web application for Apache Tomcat
tomcat-javadoc.noarch : Javadoc generated documentation for Apache Tomcat
tomcat-jsp-2.2-api.noarch : Apache Tomcat JSP API implementation classes
tomcat-jsvc.noarch : Apache jsvc wrapper for Apache Tomcat as separate service
tomcat-lib.noarch : Libraries needed to run the Tomcat Web container
tomcat-servlet-3.0-api.noarch : Apache Tomcat Servlet API implementation classes
tomcat-webapps.noarch : The ROOT and examples web applications for Apache Tomcat
tomcatjss.noarch : JSSE implementation using JSS for Tomcat
crash.x86_64 : Kernel analysis utility for live systems, netdump, diskdump,
             : kdump, LKCD or mcore dumpfiles
crash-devel.i686 : kernel crash analysis utility for live systems, netdump,
                 : diskdump, kdump, LKCD or mcore dumpfiles
crash-devel.x86_64 : kernel crash analysis utility for live systems, netdump,
                   : diskdump, kdump, LKCD or mcore dumpfiles
fence-virtd-serial.x86_64 : Serial VMChannel listener for fence-virtd
hamcrest.noarch : Library of matchers for building test expressions
libXdmcp.i686 : X Display Manager Control Protocol library
libXdmcp.x86_64 : X Display Manager Control Protocol library
mc.x86_64 : User-friendly text console file manager and visual shell
mcelog.x86_64 : Tool to translate x86-64 CPU Machine Check Exception data
mcstrans.x86_64 : SELinux Translation Daemon
memcached.x86_64 : High Performance, Distributed Memory Object Cache
pki-tps-tomcat.noarch : Certificate System - Token Processing Service
sblim-wbemcli.x86_64 : SBLIM WBEM Command Line Interface
smc-anjalioldlipi-fonts.noarch : Open Type Fonts for Malayalam script
smc-dyuthi-fonts.noarch : Open Type Fonts for Malayalam script
smc-kalyani-fonts.noarch : Open Type Fonts for Malayalam script
smc-meera-fonts.noarch : Open Type Fonts for Malayalam script
smc-rachana-fonts.noarch : Open Type Fonts for Malayalam script
smc-raghumalayalam-fonts.noarch : Open Type Fonts for Malayalam script
smc-suruma-fonts.noarch : Open Type Fonts for Malayalam script
strongimcv.i686 : Trusted Network Connect (TNC) Architecture
strongimcv.x86_64 : Trusted Network Connect (TNC) Architecture
tncfhh-examples.i686 : Example IMC/IMV implementations
tncfhh-examples.x86_64 : Example IMC/IMV implementations
tomcat.noarch : Apache Servlet/JSP Engine, RI for Servlet 3.0/JSP 2.2 API
tomcat-el-2.2-api.noarch : Expression Language v2.2 API
xorg-x11-drv-openchrome-devel.i686 : Xorg X11 openchrome video driver XvMC
                                   : development package
xorg-x11-drv-openchrome-devel.x86_64 : Xorg X11 openchrome video driver XvMC
                                     : development package

  Name and summary matches only, use "search all" for everything.

Recherchez quel paquet fournit mc :

[root@centos7 ~]# yum provides mc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: fr2.rpmfind.net
 * extras: mirror.ibcp.fr
 * updates: mirror.ibcp.fr
1:mc-4.8.7-8.el7.x86_64 : User-friendly text console file manager and visual
                        : shell
Repo        : base

Contrôlez maintenant les dépôts configurés dans votre système :

[root@centos7 ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: fr2.rpmfind.net
 * extras: mirror.ibcp.fr
 * updates: mirror.ibcp.fr
repo id                             repo name                             status
base/7/x86_64                       CentOS-7 - Base                       8,652
extras/7/x86_64                     CentOS-7 - Extras                       214
updates/7/x86_64                    CentOS-7 - Updates                    1,505
repolist: 10,371

Vérifiez la disponibilité de mises à jour :

[root@centos7 ~]# yum check-update
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: fr2.rpmfind.net
 * extras: mirror.ibcp.fr
 * updates: mirror.ibcp.fr

NetworkManager.x86_64              1:1.0.0-16.git20150121.b4ea599c.el7_1 updates
NetworkManager-glib.x86_64         1:1.0.0-16.git20150121.b4ea599c.el7_1 updates
NetworkManager-tui.x86_64          1:1.0.0-16.git20150121.b4ea599c.el7_1 updates
abrt.x86_64                        2.1.11-22.el7.centos.0.1              updates
abrt-addon-ccpp.x86_64             2.1.11-22.el7.centos.0.1              updates
abrt-addon-kerneloops.x86_64       2.1.11-22.el7.centos.0.1              updates
abrt-addon-pstoreoops.x86_64       2.1.11-22.el7.centos.0.1              updates
abrt-addon-python.x86_64           2.1.11-22.el7.centos.0.1              updates
abrt-addon-vmcore.x86_64           2.1.11-22.el7.centos.0.1              updates
abrt-addon-xorg.x86_64             2.1.11-22.el7.centos.0.1              updates
abrt-cli.x86_64                    2.1.11-22.el7.centos.0.1              updates
abrt-console-notification.x86_64   2.1.11-22.el7.centos.0.1              updates
abrt-dbus.x86_64                   2.1.11-22.el7.centos.0.1              updates
abrt-desktop.x86_64                2.1.11-22.el7.centos.0.1              updates
abrt-gui.x86_64                    2.1.11-22.el7.centos.0.1              updates
abrt-gui-libs.x86_64               2.1.11-22.el7.centos.0.1              updates
abrt-libs.x86_64                   2.1.11-22.el7.centos.0.1              updates
abrt-python.x86_64                 2.1.11-22.el7.centos.0.1              updates
abrt-tui.x86_64                    2.1.11-22.el7.centos.0.1              updates
alsa-firmware.noarch               1.0.28-2.el7                          base   
alsa-lib.x86_64                    1.0.28-2.el7                          base   
alsa-utils.x86_64                  1.0.28-4.el7                          base   
anaconda.x86_64                    19.31.123-1.el7.centos.2              base   
anaconda-widgets.x86_64            19.31.123-1.el7.centos.2              base   
at.x86_64                          3.1.13-17.el7_0.1                     base   
audit.x86_64                       2.4.1-5.el7                           base   
audit-libs.x86_64                  2.4.1-5.el7                           base   
audit-libs-python.x86_64           2.4.1-5.el7                           base   
...

Appliquez les mises-à-jour :

[root@centos7 ~]# yum update
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: fr2.rpmfind.net
 * extras: mirror.ibcp.fr
 * updates: mirror.ibcp.fr
Resolving Dependencies
...
Dependencies Resolved

======================================================================================================================================================
 Package                                               Arch               Version                                           Repository           Size
======================================================================================================================================================
Installing:
 NetworkManager                                        x86_64             1:1.0.0-16.git20150121.b4ea599c.el7_1             updates             1.9 M
     replacing  NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7
 NetworkManager-adsl                                   x86_64             1:1.0.0-16.git20150121.b4ea599c.el7_1             updates             122 k
     replacing  NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7
 NetworkManager-bluetooth                              x86_64             1:1.0.0-16.git20150121.b4ea599c.el7_1             updates             141 k
     replacing  NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7
 NetworkManager-team                                   x86_64             1:1.0.0-16.git20150121.b4ea599c.el7_1             updates             122 k
     replacing  NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7
 NetworkManager-wifi                                   x86_64             1:1.0.0-16.git20150121.b4ea599c.el7_1             updates             151 k
     replacing  NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7
 NetworkManager-wwan                                   x86_64             1:1.0.0-16.git20150121.b4ea599c.el7_1             updates             142 k
     replacing  NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7
 kernel                                                x86_64             3.10.0-229.14.1.el7                               updates              31 M
Updating:
 NetworkManager-glib                                   x86_64             1:1.0.0-16.git20150121.b4ea599c.el7_1             updates             376 k
 NetworkManager-tui                                    x86_64             1:1.0.0-16.git20150121.b4ea599c.el7_1             updates             203 k
 abrt                                                  x86_64             2.1.11-22.el7.centos.0.1                          updates             511 k
 abrt-addon-ccpp                                       x86_64             2.1.11-22.el7.centos.0.1                          updates             183 k
 abrt-addon-kerneloops                                 x86_64             2.1.11-22.el7.centos.0.1                          updates             100 k
 abrt-addon-pstoreoops                                 x86_64             2.1.11-22.el7.centos.0.1                          updates              91 k
 abrt-addon-python                                     x86_64             2.1.11-22.el7.centos.0.1                          updates              97 k
 abrt-addon-vmcore                                     x86_64             2.1.11-22.el7.centos.0.1                          updates             101 k
 abrt-addon-xorg                                       x86_64             2.1.11-22.el7.centos.0.1                          updates              92 k
 abrt-cli                                              x86_64             2.1.11-22.el7.centos.0.1                          updates              82 k
 abrt-console-notification                             x86_64             2.1.11-22.el7.centos.0.1                          updates              83 k
 abrt-dbus                                             x86_64             2.1.11-22.el7.centos.0.1                          updates             115 k
...
 python-dmidecode                                      x86_64             3.10.13-11.el7                                    base                 82 k
 python-ethtool                                        x86_64             0.8-5.el7                                         base                 33 k
 python-meh-gui                                        noarch             0.25.2-1.el7                                      base                 15 k
 python-six                                            noarch             1.3.0-4.el7                                       base                 18 k
 rdma                                                  noarch             7.1_3.17-5.el7                                    base                 28 k
 tagsoup                                               noarch             1.2.1-8.el7                                       base                112 k
 trousers                                              x86_64             0.3.11.2-4.el7_1                                  updates             286 k

Transaction Summary
======================================================================================================================================================
Install    7 Packages (+37 Dependent packages)
Upgrade  462 Packages

Total size: 510 M
Is this ok [y/d/N]: y

A faire - Répondez y à la question Is this ok [y/d/N]: y. Pendant la mise à jour de votre système, consultez le manuel de yum pour vous renseigner sur les autres commandes et options.

Les Bibliothèques Partagées

Présentation

Introduction

Les bibliothèques partagées sont des fonctions communes à plusieurs programmes différents d'un même domaine (son, base de données, vidéo etc.). Les fonctions proposées par une ou plusieurs bibliothèques forment un API (Application Programming Interface). Sous Linux les bibliothèques se nomment Shared Objects et portent le suffixe .so.

Stockage

Les bibliothèques partagées sont stockées par convention dans des répertoires lib, par exemple :

Répertoire Contenu
/lib Bibliothèques du système de base
/usr/lib Bibliothèques utilisateurs
/usr/local/lib Bibliothèques locales
/usr/X11R6/lib Bibliothèques de l'environnement X
/opt/kde4/lib Bibliothèques de KDE

Important : La bibliothèque la plus importante est libc. Sans elle, le système Linux ne peut pas fonctionner.

ld-linux.so.2

La bibliothèque ld-linux.so.2 est utilisée par le système pour créer un lien avec une bibliothèque partagée au moment de l'exécution d'un programme et s'appelle le chargeur de liens. Ce dernier recherche des bibliothèques partagées dans un ordre précis :

  • dans les chemins précisés par la variable système LD_LIBRARY_PATH,
  • dans les chemins précisés dans le contenu compilé du fichier /etc/ld.so.cache,
  • dans /lib et /usr/lib.

Il est à noter que le contenu du cache ld.so.cache est construit à partir des informations contenus dans le fichier de configuration /etc/ld.so.conf.

Afin d'étudier les bibliothèques liées à une application, nous allons d'abord installer l'application mc :

[root@centos7 ~]# yum install mc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: fr2.rpmfind.net
 * extras: mirror.ibcp.fr
 * updates: mirror.ibcp.fr
Resolving Dependencies
--> Running transaction check
---> Package mc.x86_64 1:4.8.7-8.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                        Arch                               Version                                     Repository                        Size
======================================================================================================================================================
Installing:
 mc                             x86_64                             1:4.8.7-8.el7                               base                             1.7 M

Transaction Summary
======================================================================================================================================================
Install  1 Package

Total download size: 1.7 M
Installed size: 5.6 M
Is this ok [y/d/N]: y

La Commande ldd

Pour déterminer quelles sont les bibliothèques liées à une application, il convient d'utiliser la commande ldd :

[root@centos7 ~]# ldd /usr/bin/mc
	linux-vdso.so.1 =>  (0x00007fff0fdfe000)
	libslang.so.2 => /lib64/libslang.so.2 (0x00007f8896ae0000)
	libgpm.so.2 => /lib64/libgpm.so.2 (0x00007f88968d9000)
	libssh2.so.1 => /lib64/libssh2.so.1 (0x00007f88966ae000)
	libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f88964aa000)
	libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f8896181000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8895f64000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f8895ba3000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f889599f000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f889569c000)
	libncurses.so.5 => /lib64/libncurses.so.5 (0x00007f8895475000)
	libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f889524b000)
	libssl.so.10 => /lib64/libssl.so.10 (0x00007f8894fde000)
	libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f8894bf9000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f88949e3000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f8896e6b000)
	libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f8894798000)
	libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f88944b8000)
	libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f88942b4000)
	libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f889407e000)
	libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f8893e70000)
	libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f8893c6c000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f8893a51000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f889382c000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f88935ca000)
	liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f88933a5000)

Afin de comprendre ce qui se passe dans le cas où une bibliothèque est manquante, renommez la bibliothèque /usr/lib/libslang.so.2 en /usr/lib/libslang.so.2.old :

[root@centos7 ~]# mv /lib64/libslang.so.2 /lib64/libslang.so.2.old

Exécutez de nouveau la commande ldd. Vous obtiendrez un résultat similaire à celui-ci :

[root@centos7 ~]# ldd /usr/bin/mc
	linux-vdso.so.1 =>  (0x00007fffe31f9000)
	libslang.so.2 => not found
	libgpm.so.2 => /lib64/libgpm.so.2 (0x00007f7b54e49000)
	libssh2.so.1 => /lib64/libssh2.so.1 (0x00007f7b54c1f000)
	libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f7b54a1b000)
	libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f7b546f1000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7b544d5000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f7b54114000)
	libncurses.so.5 => /lib64/libncurses.so.5 (0x00007f7b53eec000)
	libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f7b53cc2000)
	libssl.so.10 => /lib64/libssl.so.10 (0x00007f7b53a56000)
	libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f7b53670000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f7b5345a000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f7b53256000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f7b55064000)
	libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f7b5300b000)
	libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f7b52d2b000)
	libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f7b52b27000)
	libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f7b528f1000)
	libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f7b526e3000)
	libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f7b524df000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f7b522c4000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f7b5209f000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f7b51e3d000)
	liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f7b51c18000)

Notez la présence de la ligne libslang.so.2 ⇒ not found. Compte tenu de la bibliothèque partagée manquante, le programme mc ne peut plus être lancé :

[root@centos7 ~]# mc
mc: error while loading shared libraries: libslang.so.2: cannot open shared object file: No such file or directory

Renommez la bibliothèque correctement et vérifiez la résolution de l'erreur précédente avec la commande ldd :

[root@centos7 ~]# mv /lib64/libslang.so.2.old /lib64/libslang.so.2
[root@centos7 ~]# ldd /usr/bin/mc
	linux-vdso.so.1 =>  (0x00007fff541fe000)
	libslang.so.2 => /lib64/libslang.so.2 (0x00007fcb40b0a000)
	libgpm.so.2 => /lib64/libgpm.so.2 (0x00007fcb40903000)
	libssh2.so.1 => /lib64/libssh2.so.1 (0x00007fcb406d8000)
	libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007fcb404d4000)
	libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007fcb401ab000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fcb3ff8e000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fcb3fbcd000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fcb3f9c9000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fcb3f6c6000)
	libncurses.so.5 => /lib64/libncurses.so.5 (0x00007fcb3f49f000)
	libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007fcb3f275000)
	libssl.so.10 => /lib64/libssl.so.10 (0x00007fcb3f008000)
	libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007fcb3ec23000)
	libz.so.1 => /lib64/libz.so.1 (0x00007fcb3ea0d000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fcb40e95000)
	libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007fcb3e7c2000)
	libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007fcb3e4e2000)
	libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fcb3e2de000)
	libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007fcb3e0a8000)
	libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007fcb3de9a000)
	libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fcb3dc96000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fcb3da7b000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fcb3d856000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fcb3d5f4000)
	liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fcb3d3cf000)

Le fichier /etc/ld.so.conf

Le fichier /etc/ld.so.conf est utilisé pour configurer le cache /etc/ld.so.cache :

[root@centos7 ~]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf

Dans ce cas, le fichier ne contient qu'une directive include qui renvoie vers le contenu du répertoire /etc/ld.so.conf.d/ :

[root@centos7 ~]# ls -l /etc/ld.so.conf.d/
total 20
-rw-r--r--. 1 root root 19 Jun  9  2014 dyninst-x86_64.conf
-r--r--r--. 1 root root 63 Jun 30  2014 kernel-3.10.0-123.el7.x86_64.conf
-rw-r--r--. 1 root root 17 Jun 10  2014 libiscsi-x86_64.conf
-rw-r--r--. 1 root root 17 Jun 10  2014 mariadb-x86_64.conf
-rw-r--r--. 1 root root 24 Jun  9  2014 tracker-x86_64.conf

Par exemple, le contenu du fichier mariadb-x86_64.conf est :

[root@centos7 ~]# cat /etc/ld.so.conf.d/mariadb-x86_64.conf
/usr/lib64/mysql

La Commande ldconfig

La commande ldconfig est utilisée pour :

  • mettre à jour le cache pour les chemins inclus dans le fichier /etc/ld.so.conf ainsi que pour les répertoires /lib et /usr/lib. L'option -N de la commande ldconfig empêche la mise à jour des chemins dans le fichier,
  • mettre à jour les liens symboliques sur les bibliothèques. L'option -X de la commande ldconfig empêche la mise à jour des liens symboliques.

Les liens symboliques sont utilisés pour gérer les versions de bibliothèques.

La commande ldconfig peut être utilisée avec l'option -p pour visualiser le contenu du cache :

[root@centos7 ~]# ldconfig -p | more
889 libs found in cache `/etc/ld.so.cache'
	p11-kit-trust.so (libc6,x86-64) => /lib64/p11-kit-trust.so
	libzapojit-0.0.so.0 (libc6,x86-64) => /lib64/libzapojit-0.0.so.0
	libz.so.1 (libc6,x86-64) => /lib64/libz.so.1
	libyelp.so.0 (libc6,x86-64) => /lib64/libyelp.so.0
	libyajl.so.2 (libc6,x86-64) => /lib64/libyajl.so.2
	libxtables.so.10 (libc6,x86-64) => /lib64/libxtables.so.10
	libxslt.so.1 (libc6,x86-64) => /lib64/libxslt.so.1
	libxml2.so.2 (libc6,x86-64) => /lib64/libxml2.so.2
	libxmlrpc_util.so.3 (libc6,x86-64) => /lib64/libxmlrpc_util.so.3
	libxmlrpc_server_cgi.so.3 (libc6,x86-64) => /lib64/libxmlrpc_server_cgi.so.3
	libxmlrpc_server_abyss.so.3 (libc6,x86-64) => /lib64/libxmlrpc_server_abyss.so.3
	libxmlrpc_server.so.3 (libc6,x86-64) => /lib64/libxmlrpc_server.so.3
	libxmlrpc_client.so.3 (libc6,x86-64) => /lib64/libxmlrpc_client.so.3
	libxmlrpc_abyss.so.3 (libc6,x86-64) => /lib64/libxmlrpc_abyss.so.3
	libxmlrpc.so.3 (libc6,x86-64) => /lib64/libxmlrpc.so.3
	libxklavier.so.16 (libc6,x86-64) => /lib64/libxklavier.so.16
	libxkbfile.so.1 (libc6,x86-64) => /lib64/libxkbfile.so.1
	libxcb.so.1 (libc6,x86-64) => /lib64/libxcb.so.1
	libxcb-xvmc.so.0 (libc6,x86-64) => /lib64/libxcb-xvmc.so.0
	libxcb-xv.so.0 (libc6,x86-64) => /lib64/libxcb-xv.so.0
	libxcb-xtest.so.0 (libc6,x86-64) => /lib64/libxcb-xtest.so.0
	libxcb-xselinux.so.0 (libc6,x86-64) => /lib64/libxcb-xselinux.so.0
	libxcb-xkb.so.0 (libc6,x86-64) => /lib64/libxcb-xkb.so.0
	libxcb-xinerama.so.0 (libc6,x86-64) => /lib64/libxcb-xinerama.so.0
	libxcb-xf86dri.so.0 (libc6,x86-64) => /lib64/libxcb-xf86dri.so.0
	libxcb-xfixes.so.0 (libc6,x86-64) => /lib64/libxcb-xfixes.so.0
	libxcb-xevie.so.0 (libc6,x86-64) => /lib64/libxcb-xevie.so.0
--More--

Pour ajouter des bibliothèques partagées, il convient de :

  • créer un fichier dans le répertoire /etc/ld.so.conf.d/ et d'y inscrire le ou les chemins vers le lieu de stockage des bibliothèques partagées à ajouter,
  • exécuter la commande ldconfig -v, où v implique verbose, afin de reconstruire le cache.

<html> <div align=“center”> Copyright © 2019 Hugh Norris. </html>

Menu