On 11/12/2013 06:30 PM, Karthik Ram wrote:
I am trying to use the yum api to patch a package. It works in most cases but in some cases it does fails and gives strange errors. When I look at the yum cli source code, it appears that it uses the rpmtrans directly and not the yum api to perform updates. here's a test code: #cat test.py import yum; updates = ['initscripts'] yumb = yum.YumBase() pl = yumb.doPackageLists('updates') exactmatch, matched, unmatched = yum.packages.parsePackages(pl.updates, updates) yb = yum.YumBase() yb.doUnlock() yb.conf.assumeyes = True for po in exactmatch: yb.update(po) yb.buildTransaction() yb.processTransaction() #omitting callbacks for illustration yb.closeRpmDB() and here's the error: # python test.py Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.mirror.ndchost.com <http://centos.mirror.ndchost.com> * extras: mirrors.easynews.com <http://mirrors.easynews.com> * updates: mirror.rackspace.com <http://mirror.rackspace.com> Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.mirror.ndchost.com <http://centos.mirror.ndchost.com> * extras: mirrors.easynews.com <http://mirrors.easynews.com> * updates: mirror.rackspace.com <http://mirror.rackspace.com> Running rpm_check_debug Error in PREIN scriptlet in rpm package initscripts-9.03.38-1.el6.centos.2.x86_64 /var/tmp/rpm-tmp.JGu9SX: line 1: /usr/sbin/groupadd: Permission denied error: %pre(initscripts-9.03.38-1.el6.centos.2.x86_64) scriptlet failed, exit status 126 error: install: %pre scriptlet failed (2), skipping initscripts-9.03.38-1.el6.centos.2 initscripts-9.03.38-1.el6.centos.x86_64 was supposed to be removed but is not! Verify: 1/2: initscripts.x86_64 0:9.03.38-1.el6.centos - ud Verify: 2/2: initscripts.x86_64 0:9.03.38-1.el6.centos.2 - u The same thing works if I call the yum cli - and I believe ud flag - where it is trying to remove it is not getting removed (and yum cli appears to use the rpmtransaction directly and not this api). My understanding is that buildtransaction does depsolve and process will do whatever has to be done to each package in the transaction set (if something has to be deprecated). os info: uname -a Linux CentOS6464b 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux cat /etc/issue CentOS release 6.4 (Final) Kernel \r on an \m This does not happen on all centos 6.4s but in this case - the fact that yum cli works and the api does not is the main issue. Any ideas on how to resolve this?
Most likely your custom updater is missing the required selinux context for "rpm work" and because of that, scripts are failing on systems where selinux is enabled:
[pmatilai@mursu ~]$ ls -Z /bin/rpm /usr/bin/yum -rwxr-xr-x. root root system_u:object_r:rpm_exec_t:s0 /bin/rpm -rwxr-xr-x. root root system_u:object_r:rpm_exec_t:s0 /usr/bin/yum ^^^^^^^^^^ 'chcon -t rpm_exec_t <path to your script>' should fix it. - Panu - _______________________________________________ Yum-devel mailing list Yum-devel@lists.baseurl.org http://lists.baseurl.org/mailman/listinfo/yum-devel