22.1 introduction to software administrator
In the previous chapter, we mentioned installing the software in the way of source code, that is, using the Tarball released by the manufacturer to install the software. However, you should easily find that every time you install the software, you need to detect the operating system and environment, set compilation parameters, actual compilation, and finally install the software according to your personal preferences. This process is really troublesome, and it is really tiring for friends who are not familiar with the whole system!
Manufacturers first compile the software required by our users on their system, and then release the compiled executable software directly to users for installation
Then, if you can add some information related to these programs during installation and build them into a database, can you perform the related functions of installation, de installation, upgrade and verification (similar to the "add and remove programs" under Windows)? Indeed, there are at least two common software administrators on Linux, RPM and Debian dpkg. Our CentOS is mainly based on RPM, but we have to know dpkg! So let's briefly introduce these two things.
22.1. 1. Two main streams in Linux: RPM and DPKG
Due to the vigorous development of free software and the powerful performance of large UNIX like hosts, many software developers use tarball to release their software. Later, after the development of Linux, some enterprises or communities collected these software and made them into distributions to release this useful Linux operating system. However, it was later found that the software management of these distributions is really troublesome. If there are loopholes in the software, how to repair them? Is it managed by tarball? And often don't know what programs we have installed? Therefore, some communities and enterprises began to think about the software management mode of Linux.
As just mentioned, Linux developers first compile the software to be installed or upgraded on the fixed hardware platform and operating system platform, and then package all relevant files of the software into a special format file. The software file also contains scripts for Pre Detecting the system and dependent software, And provide all document information provided by the software. Finally release the software file.
After the client obtains this file, as long as it is installed through specific instructions, the software file will detect the existence of dependent precursor software according to the internal script. If the installation environment meets the requirements, the installation will begin. After the installation, the information of the software will be written into the software management mechanism to achieve the actions of upgrading and removal in the future.
At present, there are two most common software installation methods in the Linux community, namely:
- dpkg:
This mechanism was first developed by the Debian Linux community. Through the dpkg mechanism, the software provided by Debian can be easily installed and the installed software information can be provided. It is really very good. As long as other Linux distributions derived from Debian mostly use dpkg this mechanism to manage software, including B2D, Ubuntu and so on. - RPM:
This mechanism was first developed by Red Hat, and later it is very easy to use. Therefore, many distributions use this mechanism as a management method for software installation. Including Fedora, CentOS, SuSE and other well-known developers use this Dongdong.
As mentioned earlier, no matter dpkg/rpm, these mechanisms will more or less have the problem of software attribute dependency. How to solve it? In fact, didn't we mention that each software file provides dependency property checking? So if we make the data of dependent attributes into columns
Table. When the actual software is installed, if A software condition with dependent attributes occurs, for example, when installing A requires installing B and C first, and installing B requires installing D and E, when you want to install A, the management mechanism automatically obtains B, C, D and e through the dependent attribute list to install at the same time, doesn't it solve the problem of attribute dependency?
you 're right! You are so clever! At present, new Linux developers provide such an "online upgrade" mechanism. Through this mechanism, the original CD is only needed for the first installation. At other times, as long as there is a network, you can obtain any software provided by the original developer! In terms of dpkg management mechanism, APT's online upgrade mechanism is developed. RPM has Yum of Red Hat system, Yast Online Update (YOU) of SUSE system, etc. according to different developers.
distribution representative | Software management mechanism | Use instruction | Online upgrade mechanism (instruction) |
---|---|---|---|
Red Hat/Fedora | RPM | rpm, rpmbuild | YUM (yum) |
Debian/Ubuntu | DPKG | dpkg APT | (apt-get) |
22.1. 2 what are RPM and SRPM
The full name of RPM is "RedHat Package Manager", and the short name is RPM! As the name suggests, the original software management mechanism was developed by Red Hat. Rpm is a set of management mechanism that installs the software you need to your Linux system in a way of database recording.
Its biggest feature is to compile the software you want to install and package it into a packaging file of RPM mechanism. Through the default database record in the packaged software, it records the dependent attribute software that the software must have when it is to be installed. When installed on your Linux host, RPM will first query the dependency properties of the Linux host according to the data in the software to see if the software meets the requirements. If it meets the requirements, it will be installed. If not, it will not be installed. Then when installing, write the entire information of the software into the RPM database for future query, verification and anti installation! The advantages of this are:
- Because it has been compiled and packaged, it is very convenient for software transmission and installation (there is no need to recompile);
- Since the software information has been recorded in the database of the Linux host, it is convenient to query, upgrade and reinstall
The software file can only be installed in the original default hardware and operating system versions
Usually, RPM files released by different distributions cannot be used in other distributions. What's more, different versions of the same distribution cannot be interconnected, such as CentOS 6 X RPM files cannot be directly applied to CentOS 7 x ! Therefore, it can be found that the problems of these software management mechanisms are:
- The environment in which the software files are installed must be consistent with or equivalent to the environmental requirements at the time of packaging;
- It needs to meet the dependent attribute requirements of software;
- Special care should be taken during Anti installation. The bottom software cannot be removed first, otherwise it may cause problems in the whole system!
What can we do? If I really want to install the useful RPM software files provided by other distributions? ha-ha! Fortunately, there is SRPM! What is SRPM? As the name suggests, it means Source RPM, that is, the RPM file contains the source code! In particular, the software content provided by SRPM is "not compiled", and it provides the original code!
Generally, the extension of SRPM is * * * src.rpm is named in this format.
If we download SRPM, you must:
- First compile the software in the way of RPM management, and SRPM will be compiled into RPM file;
- Then install the compiled RPM file into the Linux system
Strange, why SRPM is so troublesome! We have to compile again, so let's use rpm to install it directly? Usually, when a software is released, the rpm and SRPM of the software will be released at the same time. We now know that RPM files must be installed in the same linux environment. Since SRPM is in the original code format, naturally, we can modify the parameter configuration file in SRPM and recompile to generate RPM files suitable for our linux environment. In this way, we can not install the software into our system, Instead of having to be the same as the Linux environment packaged by the original author? This is the use of SRPM!
file format | File name format | Direct installation or not | Embedded program type | Can I modify parameters and compile |
---|---|---|---|---|
RPM | xxx.rpm | can | Compiled | must not |
SRPM | xxx.src.rpm | must not | Uncompiled source code | can |
22.1. 3 what is i386, i586, i686, noarch, x86_ sixty-four
From the above description, we now know that the formats of RPM and SRPM are:
xxxxxxxxx.rpm <==RPM Format of,Compiled and packaged rpm file; xxxxx.src.rpm <==SRPM Format of,Contains uncompiled source code information.
So how do we know the software version, applicable platform, compilation and release times? As long as you can know through the file name!
For example, rp-pppoe-3.11-5 el7. x86_ The meaning of the 64.rpm file is:
rp-pppoe -3.11 - 5 .el7.x86_64 .rpm Software name - The number of times the software version information is released is suitable for the hardware platform extension
Software name:
Of course, it is the name of each software! The above example is RP PPPoE.
- Version information:
Each updated version requires a version information. Otherwise, how do you know whether this version is new or old? It is usually divided into primary version and secondary version. Take the above example. The main version is 3. Under the architecture of the main version, some original code contents are changed, and a new version is released, which is the secondary version! Take the above as an example, it's 11! So the version name is 3.11 - Release version times:
It is usually the number of compilations! So why do you need to compile repeatedly? This is because there may be some bug s or security concerns in the same version of software, so it is necessary to make a small patch or reset some compilation parameters. After setting, recompile and package it into RPM file! Therefore, there are different packing numbers! - Operating hardware platform:
This is a fun place, because RPM can be applied to different operating platforms, but the parameters set by different platforms are still different! Moreover, we can set the optimization parameters for higher-order CPUs, so that we can use the hardware acceleration function brought by higher-order CPUs. So there are the so-called i386, i586, i686, x86_64 and noarch file names appear!
Platform name | Description of suitable platform |
---|---|
i386 | It is applicable to almost all x86 platforms. Whether it is the old Pentium or the new Intel Core 2 and K8 series CPUs, it can work normally! That i refers to Intel compatible CPU. As for 386, needless to say, it is the level of CPU! |
i586 | It is optimized and compiled for 586 level computers. Which CPUs are they? CPUs including Pentium's first generation MMXCPU, AMD's K5 and K6 series CPUs (socket 7 pins) are all of this level; i686 Intel series CPUs after pentun II and CPUs after K7 belong to this 686 level! Since there are almost only hardware platforms after P-II on the market, many distributions directly release RPM files of this level. |
x86_64 | Optimized compilation settings for 64 bit CPUs, including Intel's Core 2 or higher CPUs and AMD's Athlon64 or later CPUs, all belong to this type of hardware platform. |
noarch | There are no hardware level restrictions. Generally speaking, there should be no binaryprogram in this type of RPM file. The most common software is shell script. |
Up to now (2015), even for the old personal computer system, the usable and usable devices are probably at least Intel Core 2 or above computer hosts, and most of them are 64 bit systems! Therefore, at present, CentOS 7 only introduces x86_64 software version does not provide software below i686 level! If your system is still a very old machine, it may not support 64 bit Linux system. In addition, the only remaining software versions are probably i686 and x86_ There are no versions of noarch. i386 can only be seen on some very special software!
Benefiting from the support of the current x86 system, the new CPU can execute the software supported by the old CPU, that is, the hardware can be downward compatible. Therefore, the lowest level i386 software can be installed on all x86 hardware platforms, whether 32-bit or 64 bit. But on the contrary, it won't work. For example, the current hardware is mostly 64 bit, so you can install x86 on the hardware_ 64 or i386 RPM software. However, x86 cannot be installed on your old host, such as P-III/P-4 32-bit machines_ 64 software!
22.1. Advantages of 4 rpm
Because rpm is a way of pre compiling and packaging into RPM file format and then installing it, and it can also record the database. Therefore, RPM has the following advantages:
- RPM contains compiled programs, configuration files and other data, which can help users avoid the trouble of recompilation;
- Before RPM is installed, it will check the hard disk capacity and operating system version of the system to avoid wrong installation of files;
- The RPM file itself provides software version information, dependent attributes, software name, software purpose description, files contained in the software and other information to facilitate understanding of the software;
- RPM management uses the database to record the relevant parameters of RPM files, which is easy to upgrade, remove, query and verify.
But have you ever thought that we mentioned in the previous chapter that some software is relevant. For example, to install the network card driver, you must have kernel source, gcc, make and other software. Can our RPM software be installed? as
If you can't find the relevant precursor software after the software is installed, isn't it very troublesome? Because the installed software can't be used!
In order to solve this problem between related software (the so-called software dependency attribute), RPM adds some message login functions when providing packaged software, including software version, packager, other software with dependency attribute, function description of the software, all file records of the software, etc, Then, an RPM software database is also established on the Linux system. In this way, when you want to install a software provided in RPM mode, RPM will check whether the relevant software already exists in the database during the installation process. If the database shows that it does not exist, the RPM file "default" cannot be installed. ha-ha! No mistake, this is the most criticized problem of "software attribute dependency" for RPM files!
22.1. 5. Overcoming the dependency of RPM attributes: YUM online upgrade
In order to reuse the existing software functions, many software will release some functions in the form of function library to facilitate the call application of other software, such as the verification function of PAM module. In addition, in order to save users' data, when releasing the software, the current distributions will divide the content of the software into two categories: general use and development. That's why you often see file names like pam-x.x.rpm and pam-devel-x.x.rpm! By default, most software-devel-x.x.rpm will not be installed, because most end users will not develop software!
Because of the above phenomena, RPM software files will have the so-called attribute dependency problem (in fact, almost all software management have this problem). Is there a way to solve it? Didn't I mention that the data of dependent attributes will be recorded inside the RPM software file? Think about it. If I list the software with dependent properties first, go to this list first when there is a need to install software, and compare with the installed software in the system, the dependent software that is not installed will be installed at the same time, won't it solve the problem of dependent properties? Is there such a mechanism? Yes! That is the origin of YUM mechanism!
CentOS (1) first places the released software in the yum server, and then (2) analyzes the dependency properties of these software and writes down the recorded information in the software (header). Then, the information is analyzed and recorded into a list of software relevance. The local or network location of these list data and software can be called container or software warehouse or repository. When the client has software installation requirements, the client host will actively download the list from the software library website of Yum server on the network, and then compare the data in the list with the existing software data in the local RPM database to install all the required dependent software at one go.
22.2 RPM software management program: rpm
22.2.1 RPM default installation path
Generally speaking, when installing RPM files, first read the setting parameters recorded in the file, and then use the data to compare the Linux system environment to find out whether there is a problem that attribute dependent software has not been installed. For example, openssh, an online software, needs the help of openssl, an encryption software, so you have to install openssl before installing openssh. If your environment doesn't have openssl, you can't install openssh.
If the environment check passes, the RPM file will begin to be installed on your Linux system. After installation, the software related information will be written to the database file in the / var/lib/rpm / directory. The data in the above directory is very important! Because if we need any software upgrade in the future, the comparison between versions comes from this database. If you want to query the installed software of the system, you can also query from here! At the same time, the current rpm also provides digital signature information. These digital signatures are also recorded in this directory! Therefore, this directory should not be deleted!
/etc | The directory where some configuration files are placed, such as / etc/crontab |
---|---|
/usr/bin | Some executable cases |
/usr/lib | Dynamic function libraries used by some programs |
/usr/share/doc | Some basic software manuals and instruction documents |
/usr/share/man | Some man page files |
22.2.2 RPM installation
[root@study ~]# rpm -ivh package_name Options and parameters: -i :install The meaning of -v :View the more detailed installation information screen -h :The installation progress is displayed in the installation information column
Example 1:Install the on the original CD rp-pppoe Software [root@study ~]# rpm -ivh /mnt/Packages/rp-pppoe-3.11-5.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:rp-pppoe-3.11-5.el7 ################################# [100%] Example 2: when installing more than two software at one time: [root@study ~]# rpm -ivh a.i386.rpm b.i386.rpm *.rpm # Directly followed by a lot of software files! Example 3: install directly from a file on the network,Install with web address: [root@study ~]# rpm -ivh http://website.name/path/pkgname.rpm
Description of common options and parameters during rpm installation
The releasable options represent meaning
- –nodeps
When to use: when the software cannot be installed due to the dependency of software properties, but you insist on installing
Danger: the reason why the software is dependent is that they will use each other's mechanisms or functions. If forced installation does not consider the dependency of software properties, the software may not be used normally|\ - –replacefiles
Usage timing: if the message "a file has been installed on your system" appears during the installation process, or the message "confirming files" appears, you can use this parameter to directly overwrite the file.
Danger: the action of covering cannot be recovered! Therefore, you must clearly know that the overwritten file can be overwritten! Otherwise, you will want to cry without tears! - –replacepkgs
Time to use: reinstall an already installed software! If you want to install a bunch of RPM software files, you can use RPM - IVH * RPM, but if some software has been installed, the system will display the message "a software has been installed", so that the installation cannot continue. At this time, you can use this option to repeat the installation! - –force
Usage timing: this parameter is actually a combination of -- replacefiles and -- replacepkgs! - –test
Timing of use: if you want to test whether the software can be installed into the user's Linux environment, you can find out whether there is attribute dependency. Examples are:
rpm -ivh pkgname.i386.rpm --test – justdb usage timing: when the RPM database is damaged or an error occurs for some reason, you can use this option to update the relevant information of the software in the database. - –nosignature
When to use: you can use this option when you want to skip the check of digital signature. - – prefix new path
Use timing: when you want to install the software to other informal directories. For example, if you want to install some software in / usr/local instead of the formal / bin, /etc directories, you can use 「 prefix /usr/local 」. - –noscripts
Use timing: do not want the software to execute some system instructions during installation.
Note: the advantage of RPM is that it can not only place files in the location, but also automatically execute some pre job instructions, such as database initialization. If you don't want rpm to automatically execute this type of instruction for you, add it!
Example:
Without a network, if you want to install a software called PAM devel, you only have the original CD-ROM on hand. What should you do?
Answer:
You can query and install the data by mounting the original CD. Please put the original disc into the CD-ROM drive. Next, we will try to mount the disc to
/mnt, which handles software downloads:
- Mount the disc using: mount /dev/sr0 /mnt
- Find the actual path of the file: find /mnt -name 'PAM devel *'
- test whether the software has dependencies: RPM - IVH PAM devel... -- test
- Direct installation: RPM - IVH PAM devel
- Removing a disc: umount /mnt
In brother bird's system, the software happens to have no attribute dependency, so the last step can be carried out smoothly!
22.2.3 RPM upgrades and updates (upgrade / refresh)
Using RPM to upgrade is too simple! Upgrade with - Uvh or - Fvh, and the options and parameters available for - Uvh and - Fvh are the same as install. However, - U and - F have different meanings. The basic difference is as follows:
-Uvh | Even if the following software has not been installed, the system will be installed directly; If the following software has an old version installed, the system will automatically update to the new version; |
---|---|
-Fvh | If the following software is not installed on your Linux system, the software will not be installed; That is, only the software installed in your Linux system will be "upgraded"! |
In the early days when there was no yum and the network bandwidth was very poor, some friends usually like this when patching the old software of the whole operating system:
- First go to the errata website of each developer or the domestic FTP image station to catch the latest RPM file;
- Use - Fvh to patch and upgrade the software installed in your system! (what a convenience!)
Therefore, without knowing the function of yum, you can still download updates data from CentOS's mapping platform, and then use the above methods to upgrade at one go! Of course, you can also use -- nodeps / – force and other parameters for upgrading! However, now that there is a Yum mechanism, this stupid method is certainly no longer needed!
22.2.4 RPM query
When RPM queries, it actually queries the database files in the directory / var/lib/rpm /! In addition, RPM can also query the information in the uninstalled RPM file! How to query? Let's talk about the available options first?
[root@study ~]# rpm -qa <== Installed software [root@study ~]# rpm -q[licdR] name of installed software <== Installed software [root@study ~]# rpm -qf exists in a file name on the system <== Installed software [root@study ~]# rpm -qp[licdR] a file name that is not installed <== Review RPM files
Options and parameters: Query information about installed software: -q :query only,Is the software name followed by installed; -qa :List all,Already installed on this machine Linux All software names on the system; -qi :List the details of the software (information),Including developer, version and description, etc; -ql :List the full file names of all files and directories of the software (list); -qc :Lists all configuration files for the software (Find out in /etc/ It's just the file name at the bottom) -qd :List all documentation for the software (Find and man Just the relevant documents) -qR :List the files contained in the dependent software related to the software (Required The meaning of) -qf :File name followed by,Find out which installed software the file belongs to; -q --scripts:Lists whether there are script files that need to be executed after installation,Available for debug oh! Query a RPM Information contained in the document: -qp[icdlR]:be careful -qp All subsequent parameters are consistent with the above description. But the purpose is only to find out Some RPM Information in the file,Instead of installed software information!be careful!
In the query part, all parameters need to be preceded by - q, which is the so-called query! The query is mainly divided into two parts. One is to query the software information installed on the system. This part of the information is provided by / var/lib/rpm /. The other is to check the contents of an RPM file, which means to find out some information to be written into the database from the RPM file. For this part, you have to use - qp (p means package). Let's take a look at some simple examples!
Example 1:Find your Linux Is it installed logrotate This software? [root@study ~]# rpm -q logrotate logrotate-3.8.6-4.el7.x86_64 [root@study ~]# rpm -q logrotating package logrotating is not installed # Note that the system will look for the software name followed by the installation. Note that there is no need to add a version! # As for the displayed results, you can see if they are installed Example 2:List the questions above,It belongs to all directories and files provided by the software: [root@study ~]# rpm -ql logrotate /etc/cron.daily/logrotate /etc/logrotate.conf ....(Omitted below).... # You can see how many files and directories the software provides, and you can also track the data of the software. Example 3:list logrotate Relevant description data of this software: [root@study ~]# rpm -qi logrotate Name : logrotate # Software name Version : 3.8.6 # Software version Release : 4.el7 # Released version ------- Example 4:Find only logrotate Configuration files and description files for [root@study ~]# rpm -qc logrotate [root@study ~]# rpm -qd logrotate Example 5:To install successfully logrotate ,What other documents does he need? [root@study ~]# rpm -qR logrotate [root@study ~]# rpm -qR logrotate /bin/sh config(logrotate) = 3.8.6-4.el7 coreutils >= 5.92 ....(Omitted below).... # From here, it seems that ha ha ~ you still need a lot of file support! Example 6:From example 5 above,find /bin/sh It's provided by that software? [root@study ~]# rpm -qf /bin/sh bash-4.2.46-12.el7.x86_64 # This parameter is followed by "file"! Not like the software in front! # This function is used to query which software owns a file in the system. Example 7:Suppose I download one RPM file,Want to know the requirements document of this document,How? [root@study ~]# rpm -qpR filename.i386.rpm # Add - qpR to find out the data required by the file!
Examples: 1. I want to know what's in my system,with c How many software are there at the beginning,How to do it? 2. my WWW Server is Apache ,I know what he uses RPM The software file name is httpd . Now?,I want to know this Where are all configuration files for a software,What can I do? 3. Carry on the above question,If the configuration file found has been changed by me,But I forgot what I had changed,So I want to be straight Then reinstall the software,What should I do? 4. If I cut an important document by mistake,for example /etc/crontab,But I don't know which software he belongs to,What should I do? answer: 1. rpm -qa | grep ^c | wc -l 2. rpm -qc httpd 3. Suppose the web address of the software on the network is: http://web.site.name/path/httpd-x.x.xx.i386.rpm Then I can do it:rpm -ivh http://web.site.name/path/httpd-x.x.xx.i386.rpm --replacepkgs 4. Although there is no such file,But it doesn't matter,because RPM There are records in /var/lib/rpm The database!place Direct release: rpm -qf /etc/crontab You can know it's the software!Reinstall the software once!
22.2.5 RPM verification and digital signature (Verify/signature)
The main function of verify is to provide a useful management mechanism for system administrators! The function is "use the database content under / var/lib/rpm to compare all software files in the current Linux system environment", that is, when you accidentally lose data, or because you accidentally kill a software file, or accidentally know the file content of a software, Use this simple method to verify the original file system! So that you can understand what file data has been modified for a while! The verification method is simple:
[root@study ~]# rpm -Va [root@study ~]# rpm -V Name of installed software [root@study ~]# rpm -Vp the file name of an RPM file [root@study ~]# rpm -Vf is a file on the system Options and parameters: -V :Followed by the software name,If the files contained in the software have been changed,Will be listed; -Va :List all files that may have been changed on the current system; -Vp :Followed by the file name,List the files that may have been changed in the software; -Vf :Lists whether a file has been changed~ Example 1:List your Linux Internal logrotate Has the software been changed? [root@study ~]# rpm -V logrotate # If no message appears, Congratulations, the files provided by the software have not been changed. # If there is any message, there is a situation! Example 2:Check it out,Yours /etc/crontab Has it been changed? [root@study ~]# rpm -Vf /etc/crontab .......T. c /etc/crontab # Look! Because there are changed information types, the changed information types will be listed!
Well, how do I know what my file has been changed? For example, example 2 above. ha-ha! Simply explain it! For example, let's check the logrotate software:
[root@study ~]# rpm -ql logrotate /etc/cron.daily/logrotate /etc/logrotate.conf /etc/logrotate.d/usr/sbin/logrotate /usr/share/doc/logrotate-3.8.6 /usr/share/doc/logrotate-3.8.6/CHANGES /usr/share/doc/logrotate-3.8.6/COPYING /usr/share/man/man5/logrotate.conf.5.gz /usr/share/man/man8/logrotate.8.gz /var/lib/logrotate.status # ha-ha! There are 10 files in total! Please modify / etc / logrotate The rotate in conf becomes 5 [root@study ~]# rpm -V logrotate ..5....T. c /etc/logrotate.conf
You will find a c before the file name, and then a bunch of strange words. That c stands for configuration, which means configuration file.
The first few messages are:
- S: (file size differences) whether the file size has been changed
- M: (mode differences) is the file type or file attribute (rwx) changed? Parameters such as executable have been changed
- 5: (MD5 sum differences) the content of MD5 fingerprint code is different
- D: (device major / minor number MIS match) the primary / secondary code of the device has changed
- L: (readlink (2) path MIS match) the link path has been changed
- U: (user ownership differences) the owner of the file has been changed
- G: (group ownership differences) the group to which the file belongs has been changed
- T: (mtime differences) the creation time of the file has been changed
- P: (capabilities difference) function has been changed
Therefore, if all the information in a configuration file has been changed, its display will be:
SM5DLUGTP c filename
As for that c, it means "Config file", that is, the file type. The file types include the following categories:
- c: config file
- d: documentation
- g: Ghost file ~ usually this file is not included by a software, which rarely occurs! (ghost file)
- l: license file
- r: read me
Digital signature
After talking about software verification, I don't know if you have found a problem, that is, verification can only verify the information in the software and the database information in / var/lib/rpm /. If the data provided by the software file itself has a problem, you can't determine the correctness of the software by using the verification method! So how to solve it? In the verification of Tarball and files, we can use
Check the md5 fingerprint code mentioned in the previous chapter, but even the fingerprint code may be tampered with! So what? Never mind, we can verify the source of the software through digital signature!
Just like your own signature, the software launched by our software developer's original factory will also have a manufacturer's own signature system! It's just that the signature has been digitized. The manufacturer can generate a signature dedicated to the software through the digital signature system and release the public key of the signature. When you want to install an RPM file:
- First, you must install the public key file released by the original factory;
- When the original rpm software is actually installed, the rpm command will read the signature information of the rpm file and compare it with the signature information in the local system,
- If the signature is the same, install it. If the relevant signature information is not found, give a warning and stop the installation.
[root@study ~]# ll /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 -rw-r--r--. 1 root root 1690 Apr 1 06:27 /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [root@study ~]# cat /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.4.5 (GNU/Linux) mQINBFOn/0sBEADLDyZ+DQHkcTHDQSE0a0B2iYAEXwpPvs67cJ4tmhe/iMOyVMh9 ....(Middle ellipsis).... -----END PGP PUBLIC KEY BLOCK-----
From the above output, you will know that the digital signature code is actually only a random number. This random number is meaningful for digital signature. We can't understand it! How to install this file? Just install it in the following way!
[root@study ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
The location of GPG key files in different versions may be different, but the file names are mostly described by GPG-KEY. Therefore, you can simply use locate or find to search, as shown in the following way:
[root@study ~]# locate GPG-KEY [root@study ~]# find /etc -name '*GPG-KEY*'
After the installation, how will the contents of this key be presented? Basically, pubkey is used as the name of the software! Let's first list the name of the key software, and then query it in the form of -qi to see what the information of the software is:
[root@study ~]# rpm -qa | grep pubkey gpg-pubkey-f4a80eb5-53a7ff4b [root@study ~]# rpm -qi gpg-pubkey-f4a80eb5-53a7ff4b Name : gpg-pubkey Version : f4a80eb5 ....(Omit below)....
22.2.6 RPM reverse installation and database reconstruction (erase/rebuilddb)
Anti installation is to uninstall the software! It should be noted that "the uninstallation process must be uninstalled from the top to the bottom". Take RP PPPoE as an example. This software is mainly installed according to ppp, so when you want to uninstall ppp, you must uninstall it first
RP PPPoE!
The option to remove is very simple. You can remove it through - e. However, it often happens that some software cannot be removed due to the dependency of software properties! Let's illustrate with the following example:
# 1. Find out the software name related to pam and try to remove pam: [root@study ~]# rpm -qa | grep pam fprintd-pam-0.5.0-4.0.el7_0.x86_64 pam-1.1.8-12.el7.x86_64 gnome-keyring-pam-3.8.2-10.el7.x86_64 pam-devel-1.1.8-12.el7.x86_64 pam_krb5-2.4.8-4.el7.x86_64 [root@study ~]# rpm -e pam error: Failed dependencies:<==The problem of dependency is mentioned here libpam.so.0()(64bit) is needed by (installed) systemd-libs-208-20.el7.x86_64 libpam.so.0()(64bit) is needed by (installed) libpwquality-1.2.3-4.el7.x86_64 ....(Omitted below).... # 2. What if you only remove the software installed on PAM devel? [root@study ~]# rpm -e pam-devel <== No message will appear! [root@study ~]# rpm -q pam-devel package pam-devel is not installed
From example 1, we know that the function library provided by pam is used by many other software, so you can't remove pam unless you remove all other dependent software at one go! Of course, you can add nodeps to force removal, but in this way, all software that will use pam function library will become inoperable programs. I think your host will have to prepare for downtime and vacation! to
In example 2, since pam devel is a development tool attached to pam, you can install and remove it separately!
Because RPM files are often installed / removed / upgraded, some actions may lead to file corruption in RPM database / var/lib/rpm /. If so, what should you do? Don't worry, we can use the -- rebuild DB option to rebuild a database
Download the database! The method is as follows:
[root@study ~]# rpm --rebuilddb <== Rebuild database
22.3 YUM online upgrade mechanism
We talked about Yum at the beginning of this chapter. After analyzing the header data of RPM, yum creates a solution for attribute dependency according to the correlation of various software, and then automatically handles the problem of software dependency to solve the problem of software installation, removal and upgrade. For the detailed communication between Yum server and client, you can go back to the previous section and see Figure 22.1 below 1.
Because distribution must release the software first, and then place the software on the yum server to provide the client for installation and upgrade. Therefore, when we want to use the function of yum, we must first find a suitable Yum server! Each Yum server may provide many different software functions, that is, the "software library" we talked about before! Therefore, you must go to Yum server to query the relevant software library website, and then continue to deal with the subsequent settings. In fact, when CentOS released the software, it has produced several mirror sites to provide software updates all over the world. Therefore, in theory, we don't need to deal with any settings. As long as we can connect to the Internet, we can use Yum! Let's go down
Let's play!
22.3. 1. Use yum to query, install, upgrade and remove functions
Query function: yum [list|info|search|provides|whatprovides] parameter
[root@study ~]# yum [option] [query work items] [related parameters] Options and parameters: [option]:Main options,Including: -y :When yum Waiting for user input,This option can be provided automatically yes Response of; --installroot=/some/path :Install the software on /some/path Instead of using the default path [Query work item] [Related parameters]:The parameters in this regard are: search :Search for a software name or description (description) Key words for; list :List current yum Name and version of all software managed,A little similar rpm -qa; info :ditto,But it's a little similar rpm -qai Implementation results of; provides:Search for software from files!similar rpm -qf Function of! Example 1:Discover disk arrays (raid) What are the relevant software? [root@study ~]# yum search raid Loaded plugins: fastestmirror, langpacks # Find the latest yum server using yum system Loading mirror speeds from cached hostfile # Find the fastest yum server # The following three software libraries are from this server! * base: ftp.twaren.net * extras: ftp.twaren.net * updates: ftp.twaren.net ....(Omit before).... dmraid-events-logwatch.x86_64 : dmraid logwatch-based email reporting dmraid-events.x86_64 : dmevent_tool (Device-mapper event tool) and DSO iprutils.x86_64 : Utilities for the IBM Power Linux RAID adapters mdadm.x86_64 : The mdadm program controls Linux md devices (software RAID arrays) ....(Omitted later).... # In colon (:) On the left is the software name,The one on the right is in RPM Internal name set up (Software name) # Look! As a result of the above, isn't this the software related to RAID? What if you want to know the software content of mdadm? Example 2:find mdadm What is the function of this software [root@study ~]# yum info mdadm Installed Packages <==This indicates that the software has been installed Name : mdadm <==The name of this software Arch : x86_64 <==The compilation architecture of this software Version : 3.3.2 <==Version of this software Release : 2.el7 <==Released version Size : 920 k <==Total file capacity for this software Repo : installed <==The software library reported that it was installed From repo : anaconda Summary : The mdadm program controls Linux md devices (software RAID arrays) URL : http://www.kernel.org/pub/linux/utils/raid/mdadm/ License : GPLv2+ Description : The mdadm program is used to create, manage, and monitor Linux MD (software : RAID) devices. As such, it provides similar functionality to the raidtools : package. However, mdadm is a single program, and it can perform : almost all functions without a configuration file, though a configuration : file can be used to help with some common tasks. # Don't tell me. What does it say? Look in the dictionary yourself! Please. Example 3:list yum All software names provided on the server [root@study ~]# yum list Installed Packages <==Installed software GConf2.x86_64 3.2.6-8.el7 @anaconda LibRaw.x86_64 0.14.8-5.el7.20120830git98d925 @base ModemManager.x86_64 1.1.0-6.git20130913.el7 @anaconda ....(Middle ellipsis).... Available Packages <==Other software that can be installed 389-ds-base.x86_64 1.3.3.1-20.el7_1 updates 389-ds-base-devel.x86_64 1.3.3.1-20.el7_1 updates 389-ds-base-libs.x86_64 1.3.3.1-20.el7_1 updates ....(Omit below).... # The meaning provided above is: "software name" edition In that software library 』 Example 4:List the software that can be upgraded on the server at present? [root@study ~]# yum list updates <==Must be updates oh! Updated Packages NetworkManager.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates NetworkManager-adsl.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates ....(Omit below).... # The software and versions that can be upgraded in that software library are listed above! Example 5:List offers passwd What is the software for this file [root@study ~]# yum provides passwd passwd-0.79-4.el7.x86_64 : An utility for setting or changing passwords using PAM Repo : basepasswd-0.79-4.el7.x86_64 : An utility for setting or changing passwords using PAM Repo : @anaconda # Found it! It is the software above that provides the passwd program!
Examples: utilize yum Function of,Find out to pam What are the software names that begin with?Which ones have not been installed yet? answer: You can query through the following methods: [root@study ~]# yum list pam* Installed Packages pam.x86_64 1.1.8-12.el7 @anaconda pam_krb5.x86_64 2.4.8-4.el7 @base Available Packages <==The bottom is『Upgradeable』Or『Not installed』of pam.i686 1.1.8-12.el7_1.1 updates pam.x86_64 1.1.8-12.el7_1.1 updates pam-devel.i686 1.1.8-12.el7_1.1 updates pam-devel.x86_64 1.1.8-12.el7_1.1 updates pam_krb5.i686 2.4.8-4.el7 base pam_pkcs11.i686 0.6.2-18.el7 base pam_pkcs11.x86_64 0.6.2-18.el7 base As shown above,So the upgraders have pam These two software,What is not installed at all is pam-devel Wait for some other software!
Install / upgrade functions: yum [install|update] software
[root@study ~]# yum [option] [work items for installing and upgrading] [related parameters] Options and parameters: install :Followed by the software to be installed! update :Followed by the software to be upgraded,To upgrade the entire system,Just direct update that will do Example 1:Replace the uninstalled found in the previous exercise pam-devel Install [root@study ~]# yum install pam-devel Loaded plugins: fastestmirror, langpacks # The first five lines are to find the fastest yum server Loading mirror speeds from cached hostfile * base: ftp.twaren.net * extras: ftp.twaren.net * updates: ftp.twaren.net Resolving Dependencies --> Running transaction check # Next, deal with the software problem of "attribute dependency" ---> Package pam-devel.x86_64 0:1.1.8-12.el7_1.1 will be installed --> Processing Dependency: pam(x86-64) = 1.1.8-12.el7_1.1 for package: pam-devel- 1.1.8-12.el7_1.1.x86_64 --> Running transaction check ---> Package pam.x86_64 0:1.1.8-12.el7 will be updated ---> Package pam.x86_64 0:1.1.8-12.el7_1.1 will be an update --> Finished Dependency Resolution Dependencies Resolved # From the above inspection, it is found that the pam software also needs to be upgraded synchronously, so that the new version of pam devel can be installed! # As for the following is a summary table! ========================================================================================== Package Arch Version Repository Size ========================================================================================== Installing: pam-devel x86_64 1.1.8-12.el7_1.1 updates 183 k 1.1.8-12.el7_1.1 updates 714 k Updating for dependencies: pam x86_64 Transaction Summary ========================================================================================== Install # A software is to be installed 1 Package Upgrade ( 1 Dependent package) # Because of the dependency problem, you need to add an additional software! Total size: 897 k Total download size: 183 k Is this ok [y/d/N]: y # Total download capacity required! # You have to decide whether you want to download and install! Of course y! # Start downloading! Downloading packages: warning: /var/cache/yum/x86_64/7/updates/packages/pam-devel-1.1.8-12.el7_1.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Public key for pam-devel-1.1.8-12.el7_1.1.x86_64.rpm is not installed pam-devel-1.1.8-12.el7_1.1.x86_64.rpm | 183 kB 00:00:00 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-1.1503.el7.centos.2.8.x86_64 (@anaconda) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Is this ok [y/N]: y # This item will only appear in the first installation, and "are you sure you want to install digital signature" can continue! Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum.Updating : pam-1.1.8-12.el7_1.1.x86_64 1/3 Installing : pam-devel-1.1.8-12.el7_1.1.x86_64 2/3 Cleanup : pam-1.1.8-12.el7.x86_64 3/3 Verifying : pam-1.1.8-12.el7_1.1.x86_64 1/3 Verifying : pam-devel-1.1.8-12.el7_1.1.x86_64 2/3 Verifying : pam-1.1.8-12.el7.x86_64 3/3 Installed: pam-devel.x86_64 0:1.1.8-12.el7_1.1 Dependency Updated: pam.x86_64 0:1.1.8-12.el7_1.1 Complete!
Remove feature: yum [remove] software
[root@study ~]# yum remove pam-devel Loaded plugins: fastestmirror, langpacks Resolving Dependencies <==alike,Solve the problem of attribute dependency first --> Running transaction check ---> Package pam-devel.x86_64 0:1.1.8-12.el7_1.1 will be erased --> Finished Dependency Resolution Dependencies Resolved ========================================================================================== Package Arch Version Repository Size ========================================================================================== Removing: pam-devel x86_64 1.1.8-12.el7_1.1 @updates 528 k Transaction Summary ========================================================================================== Remove 1 Package Installed size: 528 k # not so bad! There is no problem with dependent attributes. Only one software is removed! Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : pam-devel-1.1.8-12.el7_1.1.x86_64 1/1 Verifying : pam-devel-1.1.8-12.el7_1.1.x86_64 1/1 Removed: pam-devel.x86_64 0:1.1.8-12.el7_1.1 Complete!
22.3. Configuration file for Yum 2
Although yum can be used directly when your host is online on the Internet, because the mapping platform of CentOS may be selected incorrectly, for example, we are in Taiwan, but the mapping platform of CentOS has chosen to go to the mainland, Beijing or Japan. Is it possible to happen! Yes! Such problems often occur in brother bird's teaching. You know, we go online to the mainland or Japan
The speed is very slow! So what? Of course, just manually modify the yum configuration file!
If you connect to the above website, you will find a pile of links. Those links are the software library provided by the yum server! Therefore, the high-speed network center also provides CentOS plus, cloud, extras, FastTrack, os, updates and other software libraries. The best recognized software libraries are os (system default software) and updates (software upgrade version)!
What are the characteristics! The most important feature is the "repodata" directory! This directory is
Place the software attribute dependent data generated after analyzing the RPM software! Therefore, when you want to find the website where the software library is located, the most important thing is that there must be a directory named repodata under the website! That's the website of the software library! Please look for the correct website of other software libraries by yourself! Now let's modify the configuration file!
[root@study ~]# vim /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
- [base]:
Represents the name of the software library! Brackets must exist, and the names inside can be taken at will. However, there cannot be two same software library names, otherwise yum will not know where to find the software list files related to the software library. - name:
Just to explain the significance of this software library, the importance is not high! - mirrorlist=:
List the mapping sites that can be used by this software library. If you don't want to use it, you can annotate it in this line; - baseurl=:
This is the most important, because it is followed by the actual website of the software library! mirrorlist is the image capturing platform by yum program, and baseurl is a fixed software library website! The website we just found is here! - enable=1:
Is to let the software library be started. If you don't want to start, you can use enable=0! - gpgcheck=1:
Remember rpm's digital signature? This specifies whether to check the digital signature in the RPM file! - gpgkey=:
Is the location of the public key file of the digital signature! Just use the default value
After understanding the configuration file, let's modify the contents of the whole file so that our host can directly use the resources of the high-speed network center! Modification method: brother bird only lists the base software library project. Please handle other projects according to the above methods!
[root@study ~]# vim /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base baseurl=http://ftp.ksu.edu.tw/FTP/CentOS/7/os/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [updates] name=CentOS-$releasever - Updates baseurl=http://ftp.ksu.edu.tw/FTP/CentOS/7/updates/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [extras] name=CentOS-$releasever - Extrasbaseurl=http://ftp.ksu.edu.tw/FTP/CentOS/7/extras/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 # By default, only these three software warehouses are enabled! So brother bird only modifies the baseurl of the three software libraries!
The next step, of course, is to test whether these software libraries are working normally! How to test? Use yum again!
Example 1:List current yum server What software libraries are used? [root@study ~]# yum repolist all repo id repo name status C7.0.1406-base/x86_64 CentOS-7.0.1406 - Base disabled C7.0.1406-centosplus/x86_64 CentOS-7.0.1406 - CentOSPlus disabled C7.0.1406-extras/x86_64 CentOS-7.0.1406 - Extras disabled C7.0.1406-fasttrack/x86_64 CentOS-7.0.1406 - CentOSPlus disabled C7.0.1406-updates/x86_64 CentOS-7.0.1406 - Updates disabled base CentOS-7 - Base enabled: 8,652 base-debuginfo/x86_64 CentOS-7 - Debuginfo disabled base-source/7 CentOS-7 - Base Sources disabled centosplus/7/x86_64 CentOS-7 - Plus disabled centosplus-source/7 CentOS-7 - Plus Sources disabled cr/7/x86_64 CentOS-7 - cr disabled extras CentOS-7 - Extras enabled: extras-source/7 CentOS-7 - Extras Sources disabled fasttrack/7/x86_64 CentOS-7 - fasttrack disabled updates CentOS-7 - Updates enabled: 1,302 updates-source/7 CentOS-7 - Updates Sources disabled 181 repolist: 10,135 # It is activated only when it is written enabled on the far right! Due to / etc / yum repos. d/ # There are multiple profiles, so you will find other software inventory.
Problems caused by modifying software library and Solutions
Since we are modifying the system default configuration file, in fact, we should be in / etc / yum repos. Create a new file under D / and the extension must be repo! However, because we use the specified image site instead of the software library provided by other software developers, we modify the system default configuration file. However, the version of the software library used may be old or new. You should know that Yum will download the list of the software library to / var/cache/yum on the local machine first! Then we modified the website but not the software
The library name (text in brackets) may cause the local list to be out of sync with the list of yum server. At this time, there will be a problem that it cannot be updated!
So what? Very simple, just clear the old data on the machine! Need manual processing? You don't need it. You can handle it through the clean item in yum!
[root@study ~]# yum clean [packages|headers|all] options and parameters: packages:Delete the downloaded software files headers :Delete the header of the downloaded software file all :Delete all software library data! Example 1:Delete the relevant data of all downloaded software libraries (Including software itself and list) [root@study ~]# yum clean all
22.3. 3. Software group function of Yum
Installing a software online through yum is very simple, but what if you want to install a large project? For example, brother bird installed the test machine in the way of preset installation. This host only has the window administrator GNOME. What if I want to install KDE? Do you need to reinstall? Of course not, just use the software group function of yum! Let's look at the instructions first:
[root@study ~]# yum [group features] [software groups] Options and parameters: grouplist :List all available『Software Group』,for example Development Tools Something like that; groupinfo :Followed by group_name,Then you can understand the group All software names included; groupinstall:This works well!A whole set of software groups can be installed,Quite good use! groupremove :Remove a software group; Example 1:Check the current software library and the available and installed software groups on this computer? [root@study ~]# yum grouplist Installed environment groups: # Installed system environment software group Development and Creative Workstation Available environment groups: # System environment software groups that can also be installed Minimal Install Compute Node Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Installed groups: # Installed software group! Development Tools Available Groups: Compatibility Libraries Console Internet Tools Graphical Administration Tools Legacy UNIX Compatibility # Additional software groups can be installed! Scientific Support Security Tools Smart Card Support System Administration Tools System Management Done
You will find that the software on the system is mostly installed in groups! Remember, when you newly install CentOS, you can choose the required software? And don't those software use names such as GNOME/KDE/X Window... Exist?
In fact, that is the software group! If you execute the above instructions, you should see a "Scientific Support" software group under "Available Groups". Do you want to know what it is? Do this:
[root@study ~]# yum groupinfo "Scientific Support" Group: Scientific Support Group-Id: scientific Description: Tools for mathematical and scientific computations, and parallel computing. Optional Packages: atlas fftw fftw-devel fftw-static gnuplot gsl-devel lapack mpich ....(Omitted below)....
You will find that it is a variety of tools used in scientific operation and parallel operation! The following is a list of many software that should be downloaded and installed during the installation of the group! Let's install it directly!
[root@study ~]# yum groupinstall "Scientific Support"
Under normal circumstances, the system will help you install various software. The only trouble is that the software in Scientific Support is "optional"! Instead of "mandatory", so by default, the above software will not help you install!! If you want to install the above software, you can use yum install atlas fftw... Write in and install one by one ~ what if you want groupinstall to install all the optional software by default? Then you have to modify the configuration file! Change the software project selected by groupinstall! As follows:
[root@study ~]# vim /etc/yum.conf .....(Omit before)..... distroverpkg=centos-release # Find this line and add a new line at the bottom! group_package_types=default, mandatory, optional.....(Omit below)..... [root@study ~]# yum groupinstall "Scientific Support"
You will find that the system has started a lot of software installation! That's it! This group function is really very convenient! Please note down this function, which is very helpful for you to install software in the future_
22.3.4 EPEL/ELRepo plug-in software and user-defined configuration files
Because of his work, brother bird often needs to install third-party cooperation software on Linux, including NetCDF, MPICH and so on. Now, due to the increasing demand for parallel processing function libraries, MPICH has been included in the preset CentOS 7 software library. But the software NetCDF is not included in it ~ at the same time, there is a great statistical software on Linux, which is called "R"! The default is not in the CentOS software library. Alas, what should I do?
Do you want to use Tarball described in the previous chapter to compile and install? This is not necessary ~ because many of our great netizens provide pre compiled versions
An extra packages for Enterprise Linux (EPEL) has been developed in Fedora foundation. This plan is mainly developed for the version of Red Hat Enterprise Linux. Just right, CentOS is also for RHEL
To deal with it! Therefore, it can support the related software dependent environment of the software library. The main website of the project is on the following page:
https://fedoraproject.org/wiki/EPEL
The main software warehouse websites that can be used by our CentOS 7 are:
https://dl.fedoraproject.org/pub/epel/7/x86_64/
In addition to the additional software libraries provided by the Fedora plan mentioned above, in fact, there are many software warehouses provided by friends in the community for the shortcomings of CentOS and EPEL! The following is a list of the ELRepo software warehouse used by the bird to handle PCI passthrough virtualization. If there are other requirements, you have to search by yourself! This ELRepo software warehouse is available to CentOS 7 X's website is as follows:
http://elrepo.org/tiki/tiki-index.php
http://elrepo.org/linux/elrepo/el7/x86_64
http://elrepo.org/linux/kernel/el7/x86_64
The difference between this ELRepo software library and other software libraries is that most of the data provided by this software library is related to the core, core modules and virtualization related software,
For example, NVidia's driver is also in it! In particular, it provides the latest core (take
The name of the software named kernel ml is actually the latest Linux core, If your system is like some development servers of brother bird, you may use this software library!
okay! According to the above description, let's play the following simulation case:
Q:
My system wants to install netcdf and R through the above EPEL plan of CentOS 7. What should I do?
Answer:
First, your system should process the yum configuration file for epel as follows:
[root@study ~]# vim /etc/yum.repos.d/epel.repo [epel] name = epel packages baseurl = https://dl.fedoraproject.org/pub/epel/7/x86_64/ gpgcheck = 0 enabled = 0
Brother bird deliberately doesn't start this software warehouse. It will only be installed when necessary in the future. By default, don't go to this software library!
Next, use this software library to install netcdf and R!
[root@study ~]# yum --enablerepo=epel install netcdf R So you can install it!You didn't add it in the future --enablerepo=epel Time,this EPEL Your software will not be updated!
Use the original disc of this machine
If your host does not have a network, but you have a lot of software installation needs ~ assuming that your system has not been upgraded, can I use the local CD as the main software source at this time? Of course the answer is yes! So what do we do? Very simple. Mount your CD to a directory. Let's continue to assume that it is in / mnt, and then set the following yum configuration file
[root@study ~]# vim /etc/yum.repos.d/cdrom.repo [mycdrom] name = mycdrom baseurl = file:///mnt gpgcheck = 0 enabled = 0 [root@study ~]# yum --enablerepo=mycdrom install software_name
This setting function is very easy to use when you do not have a network but need to solve many software dependencies!
22.3. 5 automatic system upgrade
We can manually choose whether to upgrade. Can we make the system upgrade automatically and keep our system up to date at any time? Of course! Upgrade automatically through yum -y update. That - y is very important because you can automatically answer yes to start downloading and installing! Then process it through the function of crontab! Suppose I upgrade at 3:00am Taiwan time every day when the network bandwidth is relatively easy. You can do this:
[root@study ~]# echo '10 1 * * * root /usr/bin/yum -y --enablerepo=epel update' > /etc/cron.d/yumupdate [root@study ~]# vim /etc/crontab
From then on, your system will be upgraded automatically! Great! In addition, you still have to analyze the login file and collect root letters, because if you upgrade the core software (kernel), you still have to restart to make the installed software work smoothly! Therefore, you still have to analyze the login file. If there is a new core installation, restart it. Otherwise, let the system automatically maintain the latest and safer environment! What a relaxed and pleasant management!
22.3. 6 management choice: RPM or Tarball
This has always been an interesting question: "if I want to upgrade or install a new software, should I choose RPM or Tarball?", In fact, there are many factors to consider, but brother bird usually suggests this:
- The original RPM function is preferred:
Since the software released from the original factory usually has a maintenance period of a period of time, for example, each version of RHEL and CentOS provides an update period of at least five years. This is a very good option for our system security! What's the solution? Since yum can be upgraded automatically and the original factory will continue to maintain software updates, our system can keep the software up-to-date. Of course, it will be better for Zian! In addition, because RPM and yum are easy to install / remove / upgrade, and also provide the function of query and verification, they are more protected by digital signature during installation, making your software management easier! Therefore, of course, the first choice is to use RPM to handle it! - Select the RPM released from the official software website or the website of the software library provided:
However, the original factory will not pack mountains and seas, so some special software will not be provided by your original manufacturer! For example, CentOS does not provide NTFS related modules. At this time, you can go to the official website to check whether the RPM file relative to your system is provided. If the software library website is provided, it will be better! You can modify the yum configuration file to join the software library, and you can automatically install and upgrade the software! You say it's inconvenient! - Using Tarball to install special software:
Some special-purpose software won't help you create RPM files. At this time, I suggest you don't want to make SRPM to convert it into RPM! Because you only have one host, if you want to manage the same 100 hosts, it is valuable to convert the original code into RPM! Special stand-alone software, such as MPICH/PVM and other parallel operation function libraries often used in academic networks. It is recommended to use tarball to install this software. There is no need to search RPM! - Test the new software with Tarball:
At some time, you may need to use a new version of software, but the original manufacturer only provides the old version of software. For example, our CentOS is mainly located in the enterprise version, so many software requirements are "stable" rather than "new", but you just need new software! Then worry about problems after the new software is installed, and if you can't get back to the old software, it's terrible! At this point, you can use tarball to install the new software under / usr/local, so that the software can install two versions on the system at the same time! And most software will not interfere with each other when installing several versions! hey! It's good to test new software! You just have to know whether the instructions you use are new software or old software! Therefore, RPM and tarball have their own advantages and disadvantages. However, if rpm is available, the priority lies in the installation of RPM. After all, the management is convenient. However, if the software architecture is too different or the problem of dependent attributes cannot be solved, it is better to install it directly with tarball instead of spending a lot of time and energy on solving the problem of attribute dependency, Relaxed and comfortable!
22.3. 7 basic service management: Taking Apache as an example
In Chapter 17, we talked about the service management of systemd. At that time, we only used vsftpd, a relatively simple service, for explanation, because we haven't talked about yum yet. Now, we have handled the network problem (the content of Chapter 20), and this yum can also be used smoothly! Is there any other service that can be tested? Yes, let's take the website server as an example!
Generally speaking, the WWW website server needs WWW server software + web page program language + database system + program language and database link software, etc. on CentOS, the software we need includes "httpd + PHP + MariaDB server + PHP MySQL". However, we only need to enable httpd by default, so wait a minute. Although the above software needs to be installed, only httpd by default needs to be started!
In addition, by default, you do not need to modify the service configuration file. You can process your service through the system default value! Then there is a Jianghu formula that you can memorize ~ so that you won't lose paint when handling services~
- Install: yum install (your software)
- Start: systemctl start (your software)
- Boot: systemctl enable (your software)
- Firewall: firewall CMD -- add service = "(your service)"; Firewall CMD -- permanent -- add service = "(your service)"
- Test: use software to check whether your service is normal or not~
Let's experiment step by step!
# 0. First check which software is not installed or has been installed ~ this doesn't need to be carried out ~ it's just that brother bird is more hairy, you have to check it first! [root@study ~]# rpm -q httpd php mariadb-server php-mysql httpd-2.4.6-31.el7.centos.1.x86_64 # Only this one is installed, and the bottom three are not installed! package php is not installed package mariadb-server is not installed package php-mysql is not installed # 1. Install the required software! [root@study ~]# yum install httpd php mariadb-server php-mysql # Of course, the premise is that your network is OK! In this way, you can install or upgrade directly online! # 2. 3. Start and start, these two steps must be carried out! [root@study ~]# systemctl daemon-reload [root@study ~]# systemctl start httpd [root@study ~]# systemctl enable httpd [root@study ~]# systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled) Active: active (running) since Wed 2015-09-09 16:52:04 CST; 9s ago Main PID: 8837 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─8837 /usr/sbin/httpd -DFOREGROUND # 4. Firewall [root@study ~]# firewall-cmd --add-service="http" [root@study ~]# firewall-cmd --permanent --add-service="http" [root@study ~]# firewall-cmd --list-all public (default, active) interfaces: eth0 sources: services: dhcpv6-client ftp http https ssh # Whether this is started is the key! ports: 222/tcp 555/tcp masquerade: no forward-ports: icmp-blocks: rich rules: rule family="ipv4" source address="192.168.1.0/24" accept
The version update PHP MySQL is gone
22.4 use of SRPM: rpmbuild (Optional)
After talking about RPM type software, let's talk about how to use SRPM with Source code? If we downloaded an SRPM file from the network today, how to install it? In addition, if I want to modify the relevant settings of the Source code in the SRPM, how can I revise and recompile it? In addition, the most important thing to note is that the new version of RPM has separated RPM from SRPM instructions. SRPM uses rpmbuild instead of RPM!
22.4. 1 install SRPM files with default values (– rebuid / – recompile)
Suppose I download an SRPM file and don't want to revise the source code and related settings in this file, can I compile and install it directly? Certainly. Use the rpmbuild fit option. There are two main options:
- –rebuild
This option will "compile" and "package" the following SRPM, and finally generate RPM files, but the generated RPM files are not installed on the system. When you use -- rebuild, you usually find a line of font at the end:
Wrote: /root/rpmbuild/RPMS/x86_64/pkgname.x86_64.rpm
This is the compiled RPM file! This file can be used to install it! Please add an absolute path to install
Just install it! - –recompile
This action will directly "compile", "package" and "Install"! Please note that rebuild only compiles and packs, while recompile not only compiles and packs, but also installs at the same time!
However, it should be noted that neither of these options has modified the setting value in SRPM, but only generates RPM installable software files through recompilation. Generally speaking, if the compilation is successful, the intermediate temporary storage disk generated during the compilation process will be automatically deleted. If any error occurs, the intermediate file will be retained on the system and wait for the user's debugging action!
Q:
Please by http://vault.centos.org/ Download the correct CentOS version and the ntp software SRPM in the updates software library. Please download the latest version and then compile.
Answer:
At present (2015 / 09), the latest version is ntp-4.2 6p5-19. el7. centos. 1.src. RPM this one, so I do this:
-
Download the software first:
wget http://vault.centos.org/7.1.1503/updates/Source/SPackages/ntp-4.2.6p5-19.el7.centos.1.src.rpm -
Try compiling directly again:
rpmbuild --rebuild ntp-4.2.6p5-19.el7.centos.1.src.rpm
The above action will tell me that there are a lot of dependent software not installed ~ so I have to install it:
yum install libcap-devel openssl-devel libedit-devel pps-tools-devel autogen autogen-libopts-devel
-
The behavior of trying to compile again:
rpmbuild --rebuild ntp-4.2.6p5-19.el7.centos.1.src.rpm -
The final software will be placed in:
/root/rpmbuild/RPMS/x86_64/ntp-4.2.6p5-19.el7.centos.1.x86_64.rpm
The above test case is to grab an SRPM file and recompile it according to your system. Generally speaking, because the compilation may be optimized according to your system hardware, the performance may be better, but... Humans can't feel the effect of performance optimization ~ so it's not recommended. In addition, this situation can also happen when you download SRPM from different Linux distribution s and want to install it on your system. This makes sense.
Generally speaking, if you need to use SRPM files, most of the reasons are... You need to modify some settings, let the software add some special functions, and so on. Therefore, at this time, you have to disassemble SRPM, edit the compilation configuration file, and then recompile it! In the next section, let's play with the way to modify the settings!
22.4.2 SRPM used path and required software
Since SRPM contains source code, there must be configuration files in it, so first we need to know which directories will be used when compiling this SRPM? Only in this way can we modify it! But from CentOS 6 Start with X (including our CentOS 7.x of course), because each user should be able to install their own software, the directories used for SRPM installation, setting, compilation and final results are related to the operator's home directory ~ brother bird, if you use the root identity to operate SRPM, you should use the following directories:
/root/rpmbuild/SPECS | The configuration files of the software are placed in this directory. For example, the information parameters and setting items of the software are placed here; |
---|---|
/root/rpmbuild/SOURCES | In this directory are the original files (*. tar.gz files) of the software and the config configuration file; |
/root/rpmbuild/BUILD | During compilation, some temporary data will be placed in this directory; |
/root/rpmbuild/RPMS | After compilation and successful compilation, place the packaged files in this directory. It contains x86_64, noarch... Etc. |
/root/rpmbuild/SRPMS | Similar to that in RPMS, the files encapsulated by SRPM are placed here! Sometimes when you want to release your software in the form of SRPM, your SRPM files will be placed in this directory. |
In the early days when SRPM was used, the compilation behavior could only be used as root, and the source code would be placed in the / usr/src/redhat / directory! It is different from the current situation of placing it in / ~ username/rpmbuild /!
In addition, unknown errors or setting errors may occur during compilation. At this time, a corresponding error file will be generated under / tmp. You can debug according to the error file! When all the problems are solved and the compilation is successful, the files just decompressed, that is, the files in / root/rpmbild/{SPECS, SOURCES, BUILD}, will be killed, and only the files placed under / root / rpmbild / RPMs will be left!
SRPM needs to be recompiled, and during the compilation process, we need at least make and its related programs, as well as gcc, c,c + + and other programming languages for compilation. For more instructions, please refer to Chapter 21 basic software required for source code. Therefore, if you do not select software such as software Development Tools in the installation process, you have to use yum introduced in the previous section to install it! Of course, please don't forget to install the "Development Tools" software group
ask: Try downloading from the last exercise ntp of SRPM The software is installed directly into the system (Do not compile),Then check all the directories used? answer: # 1. Brother bird, suppose you install as root! [root@study ~]# rpm -ivh ntp-4.2.6p5-19.el7.centos.1.src.rpm Updating / installing... 1:ntp-4.2.6p5-19.el7.centos.1 ################################# [100%] warning: user mockbuild does not exist - using root warning: group mockbuild does not exist - using root # There will be a lot of warning problems, so ignore it! Can be ignored, no problem! # 2. Check the contents of / root/rpmbuild directory! [root@study ~]# ll -l /root/rpmbuild drwxr-xr-x. 3 root root 39 Sep drwxr-xr-x. 2 root root 6 Sep drwxr-xr-x. 4 root root 32 Sep 8 16:16 BUILD 8 16:16 BUILDROOT 8 16:16 RPMSdrwxr-xr-x. 2 root root 4096 Sep 9 09:43 SOURCES drwxr-xr-x. 2 root root 39 Sep 9 09:43 SPECS drwxr-xr-x. 2 root root 6 Sep 8 14:51 SRPMS # This guy is the most important! [root@study ~]# ll -l /root/rpmbuild/{SOURCES,SPECS} /root/rpmbuild/SOURCES: -rw-rw-r--. 1 root root 559 Jun 24 07:44 ntp-4.2.4p7-getprecision.patch -rw-rw-r--. 1 root root 661 Jun 24 07:44 ntp-4.2.6p1-cmsgalign.patch .....(Middle ellipsis)..... /root/rpmbuild/SPECS: -rw-rw-r--. 1 root root 41422 Jun 24 07:44 ntp.spec # That's the point!
22.4. 3 main contents of configuration file (*. spec)
As in the exercise in the previous section, we know that the original file (tarball) and related patch file will be placed in / root/rpmbuild/SOURCES, and we also know that the steps required for compilation are mostly/ configure, make, make check, make install, etc. where are these actions written? It's in the SPECS directory! Let's take a look at what the documents in SPECS say!
[root@study ~]# cd /root/rpmbuild/SPECS [root@study SPECS]# vim ntp.spec # 1. First of all, this part introduces the basic relevant information of the whole software! Whether it's version or release times, etc. Summary: The NTP daemon and utilities # Simple description of the function of this software Name: ntp # Name of the software Version: 4.2.6p5 # Software version Release: 19%{?dist}.1 # Interpretation and publication of software # primary license (COPYRIGHT) : MIT # There are many at the bottom # Comment description! .....(Middle ellipsis)..... License: (MIT and BSD and BSD with advertising) and GPLv2 Group: System Environment/Daemons Source0: http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-%{version}.tar.gz Source1: ntp.conf # Write SourceN is the source code! Source2: ntp.keys # There can be many source codes! .....(Middle ellipsis)..... Patch1: ntp-4.2.6p1-sleep.patch # Next is the patch file, which is the purpose of PatchN! Patch2: ntp-4.2.6p4-droproot.patch .....(Middle ellipsis)..... # 2. This part is where dependency attribute requirements are set! URL: http://www.ntp.org # shows the dependency of the software, Requires(post): systemd-units # And what software is needed in the compilation process, and so on! Requires(preun): systemd-units Requires(postun): systemd-units Requires: ntpdate = %{version}-%{release} BuildRequires: libcap-devel openssl-devel libedit-devel perl-HTML-Parser BuildRequires: pps-tools-devel autogen autogen-libopts-devel systemd-units .....(Middle ellipsis)..... %package -n ntpdate # In fact, this software contains software many times! Summary: Utility to set the date and time via NTP Group: Applications/System Requires(pre): shadow-utils Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units .....(Middle ellipsis)..... # 3. The preprocessing before compilation and the instructions required during compilation are written here # especially %build Bottom data,Almost makefile The information inside! # This part is mostly dealing with patch action! %prep %setup -q -a 5 %patch1 -p1 -b .sleep # Of course, these patches are related to the previous PatchN! %patch2 -p1 -b .droproot .....(Middle ellipsis)..... # Actually/ configure, make and other actions! %build sed -i 's|$CFLAGS -Wstrict-overflow|$CFLAGS|' configure sntp/configure export CFLAGS="$RPM_OPT_FLAGS -fPIE -fno-strict-aliasing -fno-strict-overflow" export LDFLAGS="-pie -Wl,-z,relro,-z,now" %configure \ # No, it is/ What does configure mean! --sysconfdir=%{_sysconfdir}/ntp/crypto \ --with-openssl-libdir=%{_libdir} \ --without-ntpsnmpd \ --enable-all-clocks --enable-parse-clocks \ --enable-ntp-signd=%{_localstatedir}/run/ntp_signd \ --disable-local-libopts echo '#define KEYFILE "%{_sysconfdir}/ntp/keys"' >> ntpdate/ntpdate.h echo '#define NTP_VAR "%{_localstatedir}/log/ntpstats/"' >> config.h make %{?_smp_mflags} # It's just make! .....(Middle ellipsis)..... %install # This is all the actions in the installation process! make DESTDIR=$RPM_BUILD_ROOT bindir=%{_sbindir} install mkdir -p $RPM_BUILD_ROOT%{_mandir}/man{5,8} sed -i 's/sntp\.1/sntp\.8/' $RPM_BUILD_ROOT%{_mandir}/man1/sntp.1mv $RPM_BUILD_ROOT%{_mandir}/man{1/sntp.1,8/sntp.8} rm -rf $RPM_BUILD_ROOT%{_mandir}/man1 .....(Middle ellipsis)..... # 4. Here are the meanings of the files released by this software! # What is the meaning of the file to which this software belongs! %files %dir %{ntpdocdir} %{ntpdocdir}/COPYRIGHT %{ntpdocdir}/ChangeLog .....(Middle ellipsis)..... # 5. List the change history files of this software! %changelog * Tue Jun 23 2015 CentOS Sources <bugs@centos.org> - 4.2.6p5-19.el7.centos.1 - rebrand vendorzone * Thu Apr 23 2015 Miroslav Lichvar <mlichvar@redhat.com> 4.2.6p5-19.el7_1.1 - don't step clock for leap second with -x option (#1191122) .....(Omitted later).....
Note that NTP SEPC is a configuration file that mainly compiles SRPM into RPM. Its basic rules can be seen as follows:
- The beginning of the whole document starts with Summary, and the settings in this part are the most basic instructions;
- Then, each different paragraph starts with%, such as% prep and% install;
Let's talk about some common SRPM setting paragraphs:
Overall information of the system:
parameter | Parameter meaning |
---|---|
Summary | The main description of the software. For example, the table above shows that the software is aimed at NTP software functions and tools, etc! |
Name | The software name of the software (which will eventually be one of the file names of the RPM file) |
Version | The version of the software (which will also be part of the RPM file name) |
Release | This is a description of the number of times the version is packaged (it will also be one of the components of the RPM file name). Since we want to do something, please change "19% {dist}. 1" to "20.vbird" |
License | The licensing mode of this software seems to cover all well-known Open source licensing!! When installing the software Group, which software Group is it mainly placed in (features of yum grouplist!); |
URL | The main official website of this source code; |
SourceN | The source of this software. If the software is downloaded from the network, there is usually this information to tell you the source of this original file! In addition, if there are multiple software sources, the source code will be processed with Source0, Source1... Oh! |
PatchN | It's the patch file as a patch! There can be many! |
BuildRoot | Set which directory should be used to temporarily store intermediate files (such as target files / link files in the compilation process) when compiling. The above items must exist, and the following additional settings can be used |
Requires | If your software needs the support of other software, it must be written here. When you make it into RPM, the system will automatically check it! This is the main source of dependency attributes! |
BuildRequires | Software required during compilation. Requirements refers to the items that need to be checked during installation, because it is related to the actual operation. BuildRequires refers to the software required during compilation, which can only be checked when SRPM is compiled into RPM. |
%description:
Make a brief description of your software! This is also necessary. Remember that some problems will appear when using "rpm -qi software name"
Basic instructions? The above things, including Description, are displaying these important information! So, remember to
Explain in detail!
%prep:
The keyword "pre" originally means "before", so this item here refers to "not set or installed yet"
Before, you need to compile the RPM to help you do things in advance ", which is the abbreviation of prepare! So what's his job
There should be:
- Carry out software patch and other related work;
- Does the directory needed to find the software already exist? For confirmation!
- Establish the directory required by your software in advance, or the tasks required in advance;
- If there are files in the Linux system to be installed that may be overwritten during installation, backup is necessary
Work!
In this case, you will find that the program will use patch to patch! So the original code of the program will be updated to the latest
Ah!
%build:build is to build! So of course, this paragraph is about how to compile make into an executable program! Will you send
Now this part of the program code is/ configure, make and other projects! Generally speaking, if you will use SRPM to
The act of recompiling is usually to recompile/ configure and give new parameter settings! So this part may be modified
Here!
%install:
After compiling (build), it is time to install! Installation is written here, which is similar to make install in Tarball
What do you mean!
%files:
The software installation files need to be written here, including the "directory" of course! So please write this paragraph together with the table of contents
among! For inspection! In addition, you can specify the type of each file, including the file file (% followed by doc) and
Configuration file (% config followed) and so on.
%changelog:
This project is mainly to record the update record of the software! Asterisk (*) should be followed by time, modifier and email
With the software version as the description, the minus sign (-) is followed by the detailed description you want to make! In this part, brother bird has added two lines
The contents are as follows:
%changelog * Wed Sep 09 2015 VBird Tsai <vbird@mail.vbird.idv.tw>- 4.2.6p5-20.vbird - only rbuild this SRPM to RPM * Tue Jun 23 2015 CentOS Sources <bugs@centos.org> - 4.2.6p5-19.el7.centos.1 - rebrand vendorzone ....(Omit below)....
You should also know about NTP How important spec is! When we use rpm -q to query a pile of information, they are actually written here! Do you understand this? Next, let's learn how to compile SRPM into rpm!
22.4. 4 compilation instruction of SRPM (- ba/-bb)
To compile the data under / root/rpmbuild or simply package it into RPM or SRPM, you need the help of rpmbuild instructions and related options! We only introduce two common options for you:
[root@study ~]# rpmbuild -ba ntp. Spec < = = compile and generate RPM and SRPM files at the same time [root@study ~]# rpmbuild -bb ntp. Spec < = = compile to RPM file only
At this time, the system will do this:
- Enter the BUILD directory first, that is: / root/rpmbuild/BUILD;
- Per * The Name and Version in the spec file define the Name of the working directory. Take our example above as an example, then the system will delete ntp-4.2.0 in the BUILD directory first 6p5 directory, and then re-establish an ntp-4.2 6p5 and enter the directory;
- In the new directory, for the Source files in the SOURCES directory, that is The file set by the Source in the spec is decompressed in tar. In our example, it will be in / root / rpmbuild / build / ntp-4.2 Among 6p5, the
/root/rpmbuild/SOURCES/ntp - extract multiple source code files! - Start setting and compiling% build and% install again!
- Finally, put the packaged files to the place where they should be placed, if your system is x86_64, then the * x86_ The 64.rpm file will be placed in / root/rpmbuild/RPMS/x86_64 inside! If it is noarch, it will naturally be in the / root/rpmbuild/RPMS/noarch directory!
The whole step is probably like this! The final result data will be placed under the RPMS directory! In this case, we want to package RPM and SRPM at the same time, so please handle "rpmbuild -ba ntp.spec" yourself!
[root@study ~]# cd /root/rpmbuild/SPECS [root@study SPECS]# rpmbuild -ba ntp.spec .....(Omit before)..... Wrote: /root/rpmbuild/SRPMS/ntp-4.2.6p5-20.vbird.src.rpm Wrote: /root/rpmbuild/RPMS/x86_64/ntp-4.2.6p5-20.vbird.x86_64.rpm Wrote: /root/rpmbuild/RPMS/noarch/ntp-perl-4.2.6p5-20.vbird.noarch.rpm Wrote: /root/rpmbuild/RPMS/x86_64/ntpdate-4.2.6p5-20.vbird.x86_64.rpm Wrote: /root/rpmbuild/RPMS/x86_64/sntp-4.2.6p5-20.vbird.x86_64.rpm Wrote: /root/rpmbuild/RPMS/noarch/ntp-doc-4.2.6p5-20.vbird.noarch.rpm Wrote: /root/rpmbuild/RPMS/x86_64/ntp-debuginfo-4.2.6p5-20.vbird.x86_64.rpm Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.xZh6yz + umask 022 + cd /root/rpmbuild/BUILD + cd ntp-4.2.6p5 + /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/ntp-4.2.6p5-20.vbird.x86_64 + exit 0 [root@study SPECS]# find /root/rpmbuild -name 'ntp*rpm' /root/rpmbuild/RPMS/x86_64/ntp-4.2.6p5-20.vbird.x86_64.rpm /root/rpmbuild/RPMS/x86_64/ntpdate-4.2.6p5-20.vbird.x86_64.rpm /root/rpmbuild/RPMS/x86_64/ntp-debuginfo-4.2.6p5-20.vbird.x86_64.rpm /root/rpmbuild/RPMS/noarch/ntp-perl-4.2.6p5-20.vbird.noarch.rpm /root/rpmbuild/RPMS/noarch/ntp-doc-4.2.6p5-20.vbird.noarch.rpm /root/rpmbuild/SRPMS/ntp-4.2.6p5-20.vbird.src.rpm # The above are the file names of RPM and SRPM respectively!
Look! Hey, hey, there's vbird software! Quite interesting! In addition, some file software has nothing to do with the hardware level (because of simple files!), So as shown in the table above, you will find ntp-doc-4.2 6p5-20. vbird. noarch. Rpm is noarch!
Interesting!
22.4. 5 an example of packaging your own software
This is interesting! How about editing our own RPM? Will it be difficult? Not at all! Let's take an example here to play! Remember the main program we talked about when we talked about Tarball and make in the previous chapter?
Now we add Makefile to this program and make it main-0.1-1 x86_ 64.rpm, okay? So how? Let's deal with it!
Create the original code file tarball to generate:
Because bird brother's website does not directly release main-0.2, it is assumed that the official website provides main-0.2 In addition to the L version, a patch file is also provided ~ then we have to do this:
main-0.1.tar.gz in / root/rpmbuild/SOURCES/
main_ 0.1_ to_ 0.2_ The patch is placed in / root/rpmbuild/SOURCES/
main. The spec is written by yourself and placed in / root/rpmbuild/SPECS/
# 1. First deal with the source code, assuming that your / root/rpmbuild/SOURCES already exists! [root@study ~]# cd /root/rpmbuild/SOURCES [root@study SOURCES]# wget http://linux.vbird.org/linux_basic/0520source/main-0.1.tgz [root@study SOURCES]# wget http://linux.vbird.org/linux_basic/0520source/main_0.1_to_0.2.patch [root@study SOURCES]# ll main* -rw-r--r--. 1 root root 703 Sep -rw-r--r--. 1 root root 1538 Sep 4 14:47 main-0.1.tgz 4 14:51 main_0.1_to_0.2.patch
Create * Configuration files for spec s
The construction of this file is the most important topic in all RPM production! You must set him carefully and don't deal with it casually! Take a closer look! Interestingly, CentOS 7 X will actively list the necessary setting parameters! Quite interesting_
[root@study ~]# cd /root/rpmbuild/SPECS [root@study SPECS]# vim main.spec Name: main Version: 0.1 Release: 1%{?dist} Summary: Shows sin and cos value. Group: Scientific Support License: GPLv2 URL: http://linux.vbird.org/ Source0: main-0.1.tgz Patch0: main_0.1_to_0.2.patch %description # These two file names should be correct! This package will let you input your name and calculate sin cos value. %prep %setup -q # The action to be used as a patch! %patch0 -p1 %build # Just compile! Do not install! make clean main %install mkdir -p %{buildroot}/usr/local/bin install -m 755 main %{buildroot}/usr/local/bin # This is the smooth installation behavior! %files /usr/local/bin/main %changelog * Wed Sep 09 2015 VBird Tsai <vbird@mail.vbird.idv.tw> 0.2 - build the program
Compiled into RPM and SRPM
To be honest, after the spec file is built properly, the subsequent actions are very simple! Start compiling!
[root@study SPECS]# rpmbuild -ba main.spec .....(Omit before)..... Wrote: /root/rpmbuild/SRPMS/main-0.1-1.el7.centos.src.rpm Wrote: /root/rpmbuild/RPMS/x86_64/main-0.1-1.el7.centos.x86_64.rpm Wrote: /root/rpmbuild/RPMS/x86_64/main-debuginfo-0.1-1.el7.centos.x86_64.rpm
Soon, we have created several RPM files! Next, let's test the packaged results
Installation / test / actual query
[root@study ~]# yum install /root/rpmbuild/RPMS/x86_64/main-0.1-1.el7.centos.x86_64.rpm [root@study ~]# rpm -ql main /usr/local/bin/main <==Try to do it yourself main have a look! [root@study ~]# rpm -qi main Name : main Version : 0.1 Release : 1.el7.centos Architecture: x86_64Install Date: Wed 09 Sep 2015 04:29:08 PM CST Group : Scientific Support Size : 7200 License : GPLv2 Signature : (none) Source RPM : main-0.1-1.el7.centos.src.rpm Build Date : Wed 09 Sep 2015 04:27:29 PM CST Build Host : study.centos.vbird Relocations : (not relocatable) URL : http://linux.vbird.org/ Summary : Shows sin and cos value. Description : This package will let you input your name and calculate sin cos value. # See? Your own software! What a pleasure!
In a very simple way, you can modify and set your own software or program for him! After that, you can set your RPM by yourself! Of course, you can also manually modify the source file content of your SRPM!
22.5 key review
- In order to avoid the trouble of users compiling by themselves, the developer compiles the software in advance on the specific hardware and operating system platform, packages the software into files in a special format, provides end users with direct installation on the fixed operating system, and provides simple query / installation / removal streams
Cheng. This is called a software administrator. Common software administrators include RPM and DPKG. - The full name of RPM is RedHat Package Manager, which was originally developed by Red Hat company and spread widely;
- The software contained in RPM type software is a compiled binary program, so it can be directly installed on the client system. However, due to this, RPM has very strict requirements for the installer's environment;
- In addition to installing the software on the user's system, RPM will also record the version, name, file and directory configuration, system requirements, etc. of the software in the database (/ var/lib/rpm) for future query, upgrade and removal;
- RPM can be compiled for different hardware levels, and the produced files can be distinguished by the extensions (i386, i586, i686, x86_64, noarch);
- The biggest problem of RPM is the dependency between software;
- SRPM is Source RPM, and the contained file is Source code instead of binary file, so it needs to be compile d when installing SRPM. However, the biggest advantage of SRPM is that users can modify the setting parameters (makefile/configure parameters) to meet their own Linux environment;
- The attribute dependency problem of RPM software can be overcome by Yum or APT. CentOS uses the yum mechanism.
- yum server provides multiple different software libraries to place individual software to provide clients to manage software categories respectively.