Package Management for Linux

Posted by dc519 on Mon, 01 Jul 2019 18:40:24 +0200

The environment of this blog is arbitrary.

 

 

 

Subject Linux Package Management

 

 

 

A software management tool

 

 

1 Compile and Install 2 rpm Package Management 3yum Management
 

 

 

2. Software Running and Compiling

 

Binary interface for 1ABI applications

 

Binary interface for ABI:Application Binary Interface application.

A binary program is programmed to run on the operating system, it must meet the interface standards.

Windows is not compatible with Linux.Because binaries are in different formats.

The ELF(Executable and Linkable Format) is a linux.PE (Portable Executable) is windows.

 

 

Note that I'm using a virtual machine with a graphical interface

[root@centos71 ~]# ll
total 8
-rw-------. 1 root root 1922 Jan 10 12:15 anaconda-ks.cfg
drwxr-xr-x. 2 root root    6 Jan 10 14:19 Desktop
drwxr-xr-x. 2 root root    6 Jan 10 14:19 Documents
drwxr-xr-x. 2 root root    6 Jan 10 14:19 Downloads
-rw-r--r--. 1 root root 1953 Jan 10 12:45 initial-setup-ks.cfg
drwxr-xr-x. 2 root root    6 Jan 10 14:19 Music
drwxr-xr-x. 2 root root    6 Jan 10 14:19 Pictures
drwxr-xr-x. 2 root root    6 Jan 10 14:19 Public
drwxr-xr-x. 2 root root    6 Jan 10 14:19 Templates
drwxr-xr-x. 2 root root    6 Jan 10 14:19 Videos
[root@centos71 ~]# ls
anaconda-ks.cfg  Desktop  Documents  Downloads  initial-setup-ks.cfg  Music  Pictures  Public  Templates  Videos

 

 

 

 

Binary Interface for Linux Applications

 

ELF(Executable and Linkable Format) is a Linux format

[root@centos71 ~]# file    /bin/cat
/bin/cat: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), 
dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=797f79d6d2dc5a84cdc3c21df400f65569ce9a92, stripped

 

 

 

 

Binary Interface for windows Applications

 

Copy ocam software from windows to virtual machine

Virtualization is used if you want to run Linux programs in windows or windows programs in linux.
Library-level virtualization: Linux: WINE, Windows: Cywin

[root@centos71 ~]# rz

[root@centos71 ~]# ls
anaconda-ks.cfg  Desktop  Documents  Downloads  initial-setup-ks.cfg  Music  oCam.exe  Pictures  Public  Templates  Videos
[root@centos71 ~]# file   *.exe
oCam.exe: PE32 executable (GUI) Intel 80386, for MS Windows

 

 

 

 

 

   2API: Application Programming Interface

 

In Linux, operating system programs are written in C.Written text must be parsed into binary to run on the operating system.


POSIX: Portable OS


Processing: Program Source Code-->Preprocessing-->Compilation-->Assembly-->Links

 

Static compilation:.a


Dynamic compilation:.so

 

Commands such as those often used are actually binary programs.They are all generated by the above process.

[root@centos71 ~]# file    /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), 
for GNU/Linux 2.6.32, BuildID[sha1]=c5ad78cfc1de12b9bb6829207cececb990b3e987, stripped [root@centos71 ~]# file /bin/mv /bin/mv: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs),
for GNU/Linux 2.6.32, BuildID[sha1]=68e3aede2af1dadfbfddc9c44bb6b73e9f53dbfb, stripped [root@centos71 ~]# file /bin/rmdir /bin/rmdir: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs),
for GNU/Linux 2.6.32, BuildID[sha1]=1c559c20eca21dfc2ec31fffbdf6c5700b29911e, stripped

 

 

 

 

 

Triple Binary Application

1 Components of a binary application

 

 

Components of a binary application: binary files, library files, configuration files, help files

 

Note that libraries cannot be run without programs.Large software has special profiles.Configuration files are equivalent to the option capabilities of commands.

 

For example, bash has configuration files, which are in your home directory.

[root@centos71 ~]# ls  -a
.   anaconda-ks.cfg  .bash_logout   .bashrc  .config  .dbus    Documents  .esd_auth    
initial-setup-ks.cfg Music Pictures .tcshrc Videos .Xauthority .. .bash_history .bash_profile .cache .cshrc Desktop Downloads .ICEauthority .local
oCam.exe Public Templates .viminfo

 

 

 

Help files are available, even on ls.

 

There are other files, such as data files.For example, if you install web server software, you need to provide files such as web pages to provide external web services.Log file to record the occurrence of events.

 

 

Installing software on Linux starts with source code compilation.The c language script needs to be compiled into binary using the gcc tool to run.

 

To reduce the difficulty of ordinary users using the software, each distribution has issued a package manager that manages the software without compiling it.

 

It's like opening the installation software on windows and installing it all the time.Inside Linux, these software are organized with a uniform file suffix.

 

 

 

 

 

2 The library files on which the binary program depends

 

Binary programs run on Libraries

 

Library files are automatically loaded into memory when the system uses them normally.

 

ldd    /PATH/TO/BINARY_FILE

[root@centos71 ~]# ldd   /bin/cat
    linux-vdso.so.1 =>  (0x00007ffc7b2b6000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f0a60de1000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f0a611ae000)
[root@centos71 ~]# ll    /lib64/libc.so.6 
lrwxrwxrwx. 1 root root 12 Jan 10 11:45 /lib64/libc.so.6 -> libc-2.17.so

 

 

 

3 Manage and view locally loaded library files

 

Notice this subdirectory for the next blog, here you go.


ldconfig load library file


/sbin/ldconfig-p: Displays all available library file names and file path mappings cached locally

 

 

ldconfig-v Views all library files being used to load into memory.

[root@centos71 ~]# ldconfig   -v   |   wc 
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
ldconfig: Path `/usr/lib64' given more than once
ldconfig: Can't stat /usr/libx32: No such file or directory
    959    2867   41578
[root@centos71 ~]# ldconfig   -v   |   head   
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
ldconfig: Path `/usr/lib64' given more than once
ldconfig: Can't stat /usr/libx32: No such file or directory
/usr/lib64/dyninst:
    libsymtabAPI.so.9.3 -> libsymtabAPI.so.9.3.1
    libsymLite.so.9.3 -> libsymLite.so.9.3.1
    libstackwalk.so.9.3 -> libstackwalk.so.9.3.1
    libpcontrol.so.9.3 -> libpcontrol.so.9.3.1
    libpatchAPI.so.9.3 -> libpatchAPI.so.9.3.1
    libparseAPI.so.9.3 -> libparseAPI.so.9.3.1
    libinstructionAPI.so.9.3 -> libinstructionAPI.so.9.3.1
    libdyninstAPI_RT.so.9.3 -> libdyninstAPI_RT.so.9.3.1
    libdyninstAPI.so.9.3 -> libdyninstAPI.so.9.3.1

 

 

 

 

Configuration files: /etc/ld.so.conf, /etc/ld.so.conf.d/*.conf


Cache file: /etc/ld.so.cache

 

 

If a third-party module file is made, it is a file with the suffix so.To be used by others, load into memory for others to call.

You can create a file that ends with conf under the configuration file/etc/ld.so.conf.d.

You can refer to the files already in it.

I made my own software and put it in the prescribed file path, then build a file at the end of conf at / etc/ld.so.conf.d. Write the path in this file, and the system will find it.

These library files can be found by generating separate configuration files.

[root@centos71 app]# cd  /etc/ld.so.conf.d/
[root@centos71 ld.so.conf.d]# ls
dyninst-x86_64.conf  kernel-3.10.0-862.el7.x86_64.conf  libiscsi-x86_64.conf  mariadb-x86_64.conf
[root@centos71 ld.so.conf.d]# cat mariadb-x86_64.conf writes the path.
/usr/lib64/mysql
[root@centos71 ld.so.conf.d]# Ls/usr/lib64/mysql display path actually shows the file
libmysqlclient.so.18  libmysqlclient.so.18.0.0  plugin
[root@centos71 ld.so.conf.d]# ll   /usr/lib64/mysql
total 3064
lrwxrwxrwx. 1 root root      24 Jan 10 11:48 libmysqlclient.so.18 -> libmysqlclient.so.18.0.0
-rwxr-xr-x. 1 root root 3135672 Aug  5  2017 libmysqlclient.so.18.0.0
drwxr-xr-x. 2 root root      54 Jan 10 11:48 plugin

 

 

 

Open the main profile, which contains the following profile.

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

[root@centos71 ld.so.conf.d]# cat   /etc/ld.so.conf.d/*
/usr/lib64/dyninst
# Placeholder file, no vDSO hwcap entries used in this kernel.
/usr/lib64/iscsi
/usr/lib64/mysql

 

 

 

 

 

Four Package Managers

 

 

1 Type of Package Manager

 

 

 

Functions: Package the components of a compiled application into one or more package files to facilitate and quickly manage the installation, uninstallation, query, upgrade, and validation of packages

 

 

debian:deb file, dpkg package manager.redhat: rpm file, RPM package manager



rpm: This is the earlier name Redhat Package Manager.

 

It contains a lot of files, so we just need to remember the command rpm to install the software.

 

Apart from Red Hat, many other distributions support software with the rpm suffix.


Because many distributions are used, becoming a standard means RPM Package Manager.

 

 

 

2 Packages Naming Specification

 

 

 

 

Source code: name-VERSION.tar.gz|bz2|xz


VERSION: major.minor.release

 

 

Manage packages using rpm

 

rpm package naming:
name-VERSION-release.arch.rpm
Example: bash-4.2.46-19.el7.x86_64.rpm
VERSION: major.minor.release
release: release.OS
Common arch s:
x86: i386, i486, i586, i686
x86_64: x64, x86_64, amd64
powerpc: ppc
Platform independent: noarch

 

 

 

 

Classification and unpacking of 3 packages

 

 

In cases where there are many packages, it is possible to unpack, that is, to split the package.In the future, you can simply install the package you want to use without taking up so much space.

There may be dependencies or even circular dependencies between packages.For example, to install package A, you will be prompted to install package B.

 


Application-VERSION-ARCH.rpm: Main Package


Application-devel-VERSION-ARCH.rpm Development Subpackage


Application-utils-VERSION-ARHC.rpm Other Subpackages


Application-libs-VERSION-ARHC.rpm Other Subpackages

 

 

 


 

4 Resolve Dependent Package Management Tools

 


Front-end tool for the yum:rpm package manager.Dependent packages are automatically installed once they are found.This solves the problem of circular dependency.


apt-get:deb Package Manager Front End Tool


rpm Front End Management Tool on zypper: suse


dnf: Fedora 18+ rpm Package Manager Front End Management Tool.This may be used in the future.

Topics: PHP Linux RPM Windows Anaconda