Working of Package Manager in Linux
Working of Package Manager in Linux
Here's a tutorial that explains the utility of using package managers with Linux and demonstrates the way they work.
Join the DZone community and get the full member experience.Join For Free
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 a 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)
As shown in the figure, a user requests the program using package managers which are present in the system. Then package managers find out the program on the centralized location and advises user the 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 a makefile we had to create the makefile on our own so this was also a laborious task.
The main problems with make files are
- The specified package is not present on the location.
- The package depends 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 a version of the problem that the downloaded package version is different than we required or does not support.
This is called a “Dependency Hell” which is solved by the package manager. How exactly the package manager works and solves this problem, we discuss in the following section.
Package Manager Architecture
User request the package using the package manager present on the 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.
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 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 different PM for different Linux distributions as shown in the figure below.
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 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.
Published at DZone with permission of sakshi gawande . See the original article here.
Opinions expressed by DZone contributors are their own.