Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make commonly used scripts into RPM packages

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

How to make common scripts into RPM packages? To solve this problem, today the editor summarizes this article about the production of RPM packages, hoping to help more friends who want to solve this problem to find a more simple and easy way.

Redhat series of linux use RPM to manage the installation software is very convenient, after turning their commonly used scripts into RPM packages, it is convenient to use.

To make a RPM package, first look at the contents of the RPM package (which can be ignored)

.... I still don't read it. I can't understand it.

two。 Environmental preparation:

Package dependency: rpm-build rpmdevtools

3. Set up the environment for making RPM packages

Execute the command directly: rpmdev-setuptree can generate the following directory structure in the current user's home directory

4. Copy your own script to the appropriate directory

(briefly introduce the functions of my three scripts:

CustomOS.sh: set history command format, terminal (PS1) display and so on

Scanport.sh: scan the available TCP ports of the target host

SetRM.sh: when the target size deleted by rm-rf is less than 10m, put the target in the / tmp directory

)

5. Configure the SPCE file (focus)

In the SPEC directory, compile ddcw.spec

The reference for ddcw.spec content is as follows:

Name: ddcw # name

Version: version 2019 #

Release: 1125

Summary: this is test RPM

Group: Applications/System

License: ddcw

URL: https://blog.51cto.com/10888845

# Requires:

Requires:grep # dependencies, that is, other RPM packages required to install this software

% description # description

This is set ddcw some habit

% prep # what needs to be done before installation

Echo-e "\ 033 [1 * * 41 * 33m pre install NOTHING\ 033 [0mprep"

% build # I don't know about that either

Echo-e "\ 033 [1 * * 41 * 33m build NOTHING\ 033 [0mprep"

% install # installation, that is, put your own script in that location

# echo-e "\ 033 [1Tracter41ter33m install NOTHING\ 033 [0mprep"

Mkdir-p% {buildroot} / tmp/ddcw

Install-m 744 scanport.sh% {buildroot} / tmp/ddcw/scanport.sh

Install-m 744 setRM.sh% {buildroot} / tmp/ddcw/setRM.sh

Install-m 744 customOS.sh% {buildroot} / tmp/ddcw/customOS.sh

% post # work after installation (because my script has its own installation function, that is, executing the script, he will install it automatically)

Sh / tmp/ddcw/scanport.sh

Sh / tmp/ddcw/setRM.sh

Sh / tmp/ddcw/customOS.sh

% files # file

/ tmp/ddcw/scanport.sh

/ tmp/ddcw/setRM.sh

/ tmp/ddcw/customOS.sh

% postun # uninstall operation, that is, the command executed when running the rpm-e software package

Mv / usr/bin/scanportDDCW / tmp

Sed-I "/ alias rm='\ / bin\ / rms'/d" / etc/profile > / dev/null

Sed-I "/ export HISTTIMEFORMAT=/d" / etc/profile > / dev/null

Sed-I "/ export DISPLAY=/d" / etc/profile > / dev/null

Sed-I "/ export PS1=/d" / etc/profile > / dev/null

% changelog # is of no use to me

6. Execute the packaging command

Rpmbuild-bb SPECS/ddcw.spec

7. Check and test

After the package is successfully packaged, the modified RPM package will be generated in the RPMS/x86_64/ directory

I'll test the RPM package on another machine:

Verify the function again (according to my own script test, my test is OK):

Uninstall it and try it (it's also a wooden problem)

This is the end of the method of making commonly used scripts into RPM packages. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report