One of the non-OS packages that I need to install via kickstart config requires a pre-existing (non-standard) directory, is there a way to create arbitrary directory before %post in kickstart? Modifying the rpm to remove this requirement is not an option but I'd like to get the package installed as part of kickstart. Thanks.

  • When do you install the package? When does it need the directory to exist? Can't you just create the directory using mkdir -p ... in the %post section? – Mikel Oct 30 '15 at 6:16
  • I'm installing the packages as part of %packages in the kickstart config, so the directory needs to exists before this stage but after all the partitions are created. – Hendra Oct 30 '15 at 7:44

kickstart allows you to have a %pre-install script, which is further on than %pre, and has the root of the filesystem ready and mounted at /mnt/sysimage. So to create dir /abc/def you should try

mkdir -p /mnt/sysimage/abc/def

If your anaconda doesnt support this yet, you could try this hack: create a user whose home directory is the directory you need. Eg

user --name=hackforrpm --shell=/sbin/nologin --homedir=/abc/def 
  • Adding %pre-install section to my kickstart script makes it bombed out, looks like that option is not recognized. I also couldn't find any reference to it in RHEL guide access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/… – Hendra Oct 30 '15 at 8:09
  • I'm running anaconda 13.21.215. The error is: There was a problem reading from line line number where %pre-install is inserted of the kickstart file install exited abnormally [1/1] The system will be rebooted when you press Ctrl-C or Ctrl-Alt-Delete – Hendra Oct 30 '15 at 8:27
  • ok. I added a possible hack using the user option to my answer. – meuh Oct 30 '15 at 8:29
  • Unfortunately that hack won't work since the user creation only happens AFTER package installation (i.e at post-install). Looks like the option that works is to create a dummy package that does nothing but create the required directories and put it before the packages that needs it in the %packages section. – Hendra Nov 3 '15 at 3:05
  • I suppose that makes sense. Your mini rpm is a good clean solution. – meuh Nov 3 '15 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.