Friday, November 21, 2008

error: install: %pre scriptlet failed (2), skipping coreutils

I've been working lately on OS installation into image files, along the lines of the process here.

The "/usr/bin/yum -c yum.conf --installroot=/mnt/foo.img -y groupinstall Base" step for me kept producing significant errors of the form: "error: install: %pre scriptlet failed (2), skipping coreutils-x.y.z". This occurred for 16 packages in my case.

Several google hits suggested problems with selinux, but that wasn't the source of the problems in my case. After much troubleshooting I finally discovered that an RPM macro was the culprit.

In my ~/.rpmmacros file I had this entry:

%_tmppath %(echo $HOME)/rpmbuild/tmp

That's because on some hosts the default %_tmppath of /var/tmp has insufficient space, but my home directory generally has plenty. During install, yum/rpm writes out rpm scriptlets to %_tmppath. Using --installroot with yum causes a chroot(), so that path is invalid within the chroot() environment, and for some reason a number of %pre scriptlets fail in a way that causes yum to not install the package.

I did look through the Base package group, and it wasn't just the rpms that happen to have a %pre scriptlet that failed. It was a subset of them, and I haven't had the time to determine what it is about those particular %pre scriptlets that invoked the error. Regardless, removing the %_tmppath macro from my ~/.rpmmacros eliminated the error and let the yum install work properly.

(Use the "rpm --showrc" command to see your current value for %_tmppath.)

2 comments:

enginaar said...

Thank you.

Bill said...

What a life saver! I have RPM files I built for AIX 5.3 and 6.1, and they would install on some boxes and not others.

I came to find out with the help of your article that it wasn't an issue with _tmppath not having any space, but it did not even exist! I created the directory and suddenly my rpm installs worked.

I did not have a ~/.rpmmacros file on the server in question.

Thanks again