Installation and management of source package

In a previous blog I've covered the installation and management of the rpm package, today we talk about the source package installation and management.

First, select the package

  • If the package is to provide access to a large number of customers, it is recommended to use source packages installed, such as LAMP environment to build, because of the higher source package efficiency.
  • If the package is to use the underlying Linux, or only a small number of customers access to recommended rpm package is installed, the rpm package because simple.
  • In today's constantly improving hardware level, these two software packages installed effect of the gap getting smaller and smaller, or look at their choice, the pursuit of speed, then you can select the rpm package, more features and extensions can choose to install the source package.

Second, the installation process

(1) download package.
(2) decompression.
(3) into the extracted directory.
(4) ./ configure before compiling prepare this step has three main roles:

  • Before installing the system needs to detect environmental installation requirements.
  • Defined options need. "./Configure" supported more options, you can do "./configure --help" command to query its support functions. Usually the installation path specified by "./configure --prefix = install path."
  • The test results and options defined system environment to write the Makefile, compile and install the subsequent need to rely on the contents of this document. Note that, configure the system not command, but the source package software comes with a script, it must be executed "./configure" mode ( "./" stands in the current directory).

(5) make compile make calls gcc compiler and read the information Makefile file system software to compile. The purpose is to compile the source code into an executable program file can be recognized by Linux, the executable file is saved in the current directory. Compilation process is more time-consuming, need to have enough patience.
(6) make clean: Empty contents compiled (step nonessential). If the error in the "./configure" or "make" to compile, then re-execute the command before we must remember to execute make clean command, it will clear the Makefile or compile ".o" header files generated.
(7) make install: compile and install This is the real installation process usually write clearly installation location of the program. If you forget to specify the installation directory, it can be saved during the execution of this command to delete prepare for future use.

Third, delete

Source package does not delete the command, if you want to delete, you can delete the installation directory

Fourth, patching

We can take to turn over the file has been modified compared to the files have not been modified to generate patch files, if you do not accidentally accidentally deleted files, you can use the patch file to restore.

4.1 diff command Introduction
[root@localhost ~]# diff 选项 old new # 比较 old 和 new 文件的不同 
选项:  
-a  将任何文档当做文本文档处理  
-b  忽略空格造成的不同  
-B  忽略空白行造成的不同  
-I  忽略大小写造成的不同  
-N  当比较两个目录时,如果某个文件只在一个目录中,则在另一个目录中视作空文件  
-r  当比较目录时,递归比较子目录  
-u  使用同一的输出格式

For example:

#创建测试目录
mkdir /test

#生成两个文件,new.txt 比 old.txt 多一行内容。
echo  "123" > old.txt
cat old.txt > new.txt
echo "456" >> new.txt

#使用diff命令生成补丁文件 
diff -auNr old.txt new.txt > txt.patch
   
#查看txt.patch,如下
cat txt.patch 
--- old.txt 2019-11-30 09:40:57.191124425 +0800
+++ new.txt 2019-11-30 09:41:11.814004591 +0800
@@ -1 +1,2 @@
 123
+456

At this point we have generated a patch file, if if we accidentally deleted files new.txt, we can restore order with the patch, since we are using a relative path generated patch file, so we need to perform in the test directory just patch command.

#切换目录
cd /text
#打补丁,此时将old.txt文件内容恢复到与new.txt一样
patch  < txt.patch 

#查看old.txt内容
[root@love2 test]# cat old.txt 
123
456

Guess you like

Origin www.cnblogs.com/hjnzs/p/11961335.html