Working of Package Manager in Linux
Package Manager is used to automating the process of installing, upgrading, configuring, and removing programs. There are many Package Manager today for Unix/Linux-based systems. Package Managers are available in different languages like python, ruby, etc.
What is package
A package is simply an archive that combines all the libraries and binaries ,configuration and all the dependencies required to install the programs (i.e application, software or languages)
General Workflow
As shown in the fig user request the program using PM(Package Managers) which is present in the system. Then Package Managers find out the program on the centralized location and advises user the MA(manual action) if required and downloads the program on the system.
Why Package Managers
Histrionically in UNIX, every program had to write compiled linked and run. Then UNIX got the ability to use libraries (“shared objects”), ELF executables, etc. To solve the task of building more complicated software easily, make was developed. Make uses an makefile we had to create the makefile on our own so this was also a laborious task.
The main problems with make file’s are
- The specified package is not present on the location.
- Package is depend on another package.
- If the downloaded package is not working properly.
The above problem can be solved by manually downloading the package. But there may be an version problem that downloaded package version is differant than we required or does not support.
This is called an “Dependency Hell” which is solved by package manager. How exactly the package manger works and solve all this problem, we discuss in following section.
Package Manager Architecture
User System:
User request the package using the package manager present on them system.
Package manager conf file:
Each PM has its own conf file associated with it which contains the location of all repos i.e repositories that contain the packages. The conf file contains the location of all official repos . Packages are also present on third parties repos so you can edit the location of these packages in the conf file. But you have to take care of the security issue. The default conf file present on the ubuntu system is “/etc/apt/sources”. So using this conf file PM knows where exactly the packages are present.
Repository:
These repos are available online at well-defined locations and they serve as a central distribution point for packages. We can call them sources and feeds for the packages.
Package:
Package includes the dependencies, application, software as well, and shared libraries that required to install or build your software. A package include metadata as well. This will include a summary, description, list of files, version, authorship, targeted architecture, file checksums, licensing, and dependent packages. This metadata is essential for the package manager to do its job correctly.
Types of PM
There are differant PM for differant linux distribution as shown in the below fig
High-Level PM:
high-level tools (which are in charge of ensuring that the tasks of a dependency resolution and metadata searching -” data about the data”- are performed).
Low-Level PM:
low-level tools (which handle in the backend the actual installation, upgrade, and removal of package files)
If you want to know the use cases of low-level and high-level PM you can click here