Article title: key to creating an RPM Package in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
With the popularity of RedHat Linux around the world, its software package management tools and format RPM have also been promoted. Based on the features of open RPM source code, simple installation and uninstallation, easy upgrade and maintenance, and powerful query functions, more and more developers prefer to release their own software packages in RPM format. more users will benefit from this. How is the RPM software package made?
Actually, creating an RPM package is not a complicated task. The key is to compile the SPEC package description file. The following uses the software package (lze-6.0-1.i386.rpm) that I made the small Zhao editor LZE as an example to describe the software package production process in detail.
1. mkdir-p/usr/src/dist/{BUILD, RPMS/i386}
The preceding command is used to create two directories:/usr/src/dist/BUILD and/usr/src/dist/RPMS/i386. The previous directory is the directory used when RPM creates the software package, the last one is the RPM output package directory, where the lze-6.0-1.i386.rpm of my LZE package is stored. If the two directories are not created, an error is returned when you run the rpm command to create the package.
Note: The output directory name i386 indicates that this is an X86 machine. If your machine is different from this system, change the directory name accordingly.
2. Compile the software package description file lze-6.0-1.spec
To create a software package, you must write a software package description file (SPEC ). This file contains a lot of information about the software package, such as the package name, version, category, description summary, instructions to be executed during creation, and operations to be performed during installation, and the list of files to be included in the software package.
The LZE package description file lze-6.0-1.spec is simple and is only used to create binary packages. The description file content is as follows: (the number starting with each line is the row number in the file)
1 Summary: Xiao Zhao full-screen multi-window multi-functional editor in Chinese and English (applicable to Linux/UNIX systems)
2 Name: lze
3 Version: 6.0
4 Release: 1
5 Vendor: Software Production Center (Email: zhsoft@etang.com)
6 Copyright: Share
7 Group: Applications/Editors
8 Source: http://zhsoft.myetang.com/lze-6.0.tar.gz
9% description
Editor: 10 Xiao Zhao is a full-screen, multi-window, dedicated design for users using sco unix and Linux multi-user systems
11 multi-functional editors in Chinese and English.
12 It mainly has the following ten features: 1. Full screen menu operations. 2. Diverse Display methods. 3. rich block operations. 4. 10
The tabulation function is powerful. 5. flexible multi-window operations. 6. complete file operations. 7. explain that the output function is unique
14 colors. 8. built-in Chinese input method (enhanced five strokes and enhanced pinyin), practical and convenient. 9. hexadecimal editing, such as Tiger
15 wings. 10. instant translation.
16 in short, Xiao Zhao editor will be a good helper for programming and writing general documents on UNIX and Linux systems.
17. it will help you at work, so you can easily get involved!
18
19% prep
20 # prep start.
21
22% build
23 # build start.
24 cp/root/{read me, copyright }.
25
26% install
27 # install start.
28
29% files
30% defattr (-, root, root)
31% doc read me
32% doc copyright notice
33% config/etc/funkey. def
34% config/etc/inputme. def
35
36/usr/bin/lze
37/usr/bin/lzeime. py
38/usr/bin/lzeime. wb
39
40% changelogs
41
42 * Fri May 1 1998 rain Yiqi
43-added multi-window operations
44
45 * Mon Mar 24 1997 Yu Yiqi
46-added block Operation Commands
47
The description file is described as follows:
(1) file header
It contains the following domains:
* Summary:
One statement of the software package indicates that one line is valid.
* Name:
The name of the software package. RPM uses the name and version number, release number and system number to name the software package. For example, the package name output in this example is lze-6.0-1.i386.rpm.
* Version:
The software version. The version number is added only when the software changes significantly.
* Release:
The software release number. If the software changes little than before, only the release number is added without changing the version number.
* Vendor:
The name of the software developer.
* Copyright:
The copyright rules used by the software package. Specifically, GPL, BSD, MIT, Public Domain, Distributable, commercial, and Share.
* Group:
The category of the software package. the specific categories include:
Amusements/Games (Entertainment/Games)
Amusements/Graphics (Entertainment/Graphics)
Applications/Archiving (Applications/Archives)
Applications/Communications (Applications/Communications)
Applications/Databases (application/database)
Applications/Editors (application/editor)
Applications/Emulators (application/simulator)
Applications/Engineering (application/Engineering)
Applications/File (application/File)
Applications/Internet (Applications/Internet)
Applications/Multimedia (application/Multimedia)
Applications/productiinstances (Applications/products)
Applications/Publishing (application/printing)
Applications/System (application/System)
Applications/Text (application/Text)
Development/Debuggers (Development/debugger)
Development/Languages)
Development/Libraries (Development/function Library)
Development/System (Development/System)
Development/Tools (Development/Tools)
Documentation (document)
System Environment/Base (System Environment/basics)
System Environment/Daemons (System Environment/Daemons)
System Environment/Kernel (System Environment/Kernel)
System Environment/Libraries (System Environment/function Library)
System Environment/Shells (System Environment/interface)
User Interface/desktop tops (User Interface/Desktop)
User Interface/X (User Interface/X Window)
User Interface/X Hardware Support (User Interface/X Hardware Support)
* Source:
The name of the source program package.
* % Description:
The software package description can be written on multiple rows. The 10-18 rows in the example are descriptions.
(2) % prep segment
This section is a pre-processing section, which is usually used to execute some commands to unbind the source program package and prepare for the next compilation and installation. The % prep is the same as the % build and % install segments below. in addition to executing the macro commands defined by RPM (starting with %), you can also execute SHELL commands, which can contain many lines. In the example, this section contains only one line of comments (starting with #) and does not perform any operations.
(3) build section
This section is the creation section, and the command executed is the software package generation service.
Line 3 of this section is the comment line, and Line 3 executes the copy command to copy two files under the/root directory (read me, copyright notice) copy to the package creation Directory (/usr/src/dist/BUILD ).
(4) % install segment
This section is the installation section, where the command will be executed when installing the software package. In the example, this section contains only one line of comments (starting with #) and does not perform any operations.
(5) % files section
This section is a file segment used to define the files contained in a software package. it can be divided into three types: Description Documents (doc), configuration files (config) and execution programs, and file access permissions, owner and group. In this section:
Row 30th-% defattr macro: defines that the file access permission is the default value ("-" indicates the default value, you can also select the octal value, such as 0777), defines the owner as root, and defines the group as root.
Row 31,32-% doc macro: Use this macro to define the instruction document contained in the software package. If no directory is specified, the directory is/usr/src/dist/BUILD. Each macro can define only one description document. This document is generally installed in the "/usr/doc/software package name-version number-release number" directory.
Row 33,34-% config macro: defines the configuration file of the software package application, such as sendmail. cf and passwd. When you uninstall a software package that contains a configuration file, any configuration file that has not been modified will be deleted, the modified configuration file will be automatically renamed, and the suffix will be added. rpmsave so that the software package can be quickly restored when it is re-installed.
Lines 36-38-a list of file names included in the software package. you can write many lines. If the file name indicates a directory, all files in the directory will be included in the software package. Be sure not to make a mistake.
(6) % changelog
This section is to modify the log segment. You can record each software modification here and save it to the released software package for query.
Each modification log has the following format: the first line is * the email address of the modifier on the day of the week, month, and year.
The week and month are both in English, and errors may occur in Chinese.
The next line should be where the changes are made, and multiple lines can be written. Generally, it starts with a minus sign for easy access.
3. rpm-bb lze-6.0-1.spec.
Use this command to generate a software package. after the package is executed, the screen displays the following information: (each line starts with a line number)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service