简体   繁体   English

RPM +在规范文件中编写脚本

[英]RPM + writing script in the spec file

is it possible to write ksh script in the spec file? 是否可以在规范文件中编写ksh脚本?

the target is during rpm -i my_rpm.rpm 目标是在rpm -i my_rpm.rpm期间

according to the spec file , ksh script will do some installation & configuration 根据spec文件,ksh脚本将进行一些安装和配置

for example run other script and edit some files 例如运行其他脚本并编辑一些文件

THX 谢谢

You can specify the shell to use in the script with -p I believe. 我相信您可以使用-p指定要在脚本中使用的shell。

So it would look like: 因此,它看起来像:

%post -p /sbin/ldconfig

Or: 要么:

%post -p /bin/ksh
do_stuff_here

Scriptlets in a spec file are normally executed by bash; spec文件中的小脚本通常由bash执行; however, if you need to use a different shell you could of course do that. 但是,如果您需要使用其他外壳,则可以这样做。 Just write something like this: 只需这样写:

cat > /tmp/script <<EOF
# write script here

EOF

ksh /tmp/script

OK, that is not very secure but you get the idea. 好的,这不是很安全,但是您知道了。 This would be more secure, but I'm not sure if it would work: 这样会更安全,但是我不确定是否可行:

ksh <<EOF
# write script here

EOF

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM