如何知道系统当前正在安装ISO
我正在创建一个 RPM。该 RPM 将与 CentOS ISO 一起打包,并在安装 CentOs 时安装。也可以使用正常的 rpm 安装方法进行安装。但是,如果从 ISO 安装和通过 rpm 正常安装方法安装,rpm 安装的行为会有所不同。那么,问题是我如何知道系统当前是否正在安装ISO。
提前致谢。
I am creating an RPM. This RPM will be packed with the CentOS ISO and will install when CentOs is installed. This can also be installed using normal rpm installation method. But rpm installation need to behave differently if it is installed from ISO and installed by rpm normal installation method. So, the question is how do I know whether the system is currently installing the ISO.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在 %pre /%post 脚本中检查 /dev/cdrom 是否已挂载以及 /mnt/cdrom 是否包含安装光盘。
严格来说,RPM 应该与它们的安装方式无关,因此如果您在 RPM 中需要此功能,则很可能是一个有缺陷的设计,并且您尝试做的事情可以通过其他方式完成。
我建议查看 anaconda / kickstart 脚本。
You could check if /dev/cdrom is mounted and if the /mnt/cdrom contains the installation disc in the %pre /%post scripts.
Strictly speaking, RPMs should be agnostic to how they are installed, so the chances are if you need this in the RPM it's probably a flawed design and what you are trying to do can be done in some other way.
I would suggest looking at anaconda / kickstart scripts.
绝对是一个有缺陷的设计。
永远不应该与 RPM 安装进行任何用户交互,这就是我打赌您正在尝试做的事情。
Definitely a flawed design.
There should never be any user interaction with an RPM install which is what I bet you are trying to do.
如果您从 live 操作系统安装,您可以在内核命令行中检查 /dev/live 或 liveimg 是否存在,
IE
[[ $(grep -c liveimg /proc/cmdline) != 0 ]] || [ -b
readlink -f /dev/live
]If you are installing from a live OS, you can check the existence of /dev/live or liveimg in kernel command line,
i.e.
[[ $(grep -c liveimg /proc/cmdline) != 0 ]] || [ -b
readlink -f /dev/live
]