Kickstart技术咨询:如何通过%pre逻辑确定%packages的包选择?
Conditional Package Selection in Kickstart's %packages Section
I've done extensive digging and haven't come across any existing examples of using logical conditions to select packages or package groups directly in the %packages section of a Kickstart file.
My goal is to make Kickstart install packages based on criteria I gather in the %pre section, but since conditional logic in %packages seems to be uncharted territory, I thought I could generate a dynamic package list file in %pre and pull it into %packages using %include. Unfortunately, this approach hits snags when using %include inside %packages on Red Hat-based systems.
Potential Workarounds to Explore
- Modify the Kickstart file directly in
%pre: Instead of relying on%include, write a%prescript that appends or edits the package list in the active Kickstart file (usually located at/root/anaconda-ks.cfgduring installation). When the installer reaches the%packagessection, it will process the updated list automatically. - Use custom package groups with conditional flags: If your selection criteria map to specific system roles, define custom package groups in a local file or repository. Then use
%preto set environment variables that tell the installer to enable or disable these groups during the package selection phase. - Defer conditional installs to
%post: If the packages don't need to be part of the initial system image, handle conditional installations in the%postsection usingdnforyumcommands. This method is simpler but adds a post-installation step rather than integrating with the core package selection process.
内容的提问来源于stack exchange,提问作者Michael Moser
相关产品推荐
相关产品推荐

