[CentOS] synthesizing yum transactions

Brian Reichert

reichert at numachi.com
Thu Nov 5 16:39:41 UTC 2015


Ok, I'm trying way too hard to shovel myself out of a hole.

We have a bunch of remote CentOS 6 servers, that were configured
with kickstart.

They've subsequently had additional RPMs installed/updated via the
'rpm' utility.

We have reason to occasionally rewind the state of the server back
to it's original set of RPMs.

Of late, we've found that 'yum' handles this scenario quite nicely,
IFF (if and only if) that all RPM changes were handled via the 'yum'
utility itself, such that yum can manage a list of transactions.
In this case 'yum history rollback 1' does exactly what we need.

My problem is that we did not exclusively use 'yum' to do this work,
and even though there are newer RPMs in place, yum only knows about
transaction ID 1, from the initial kickstart installation.  Hence,
it thinks there's nothing to rollback from.

So, given the knowledge of what RPMs are currently installed, is
there a way to invent a new transaction incorporating them, without
reinstalling the RPMs in question?

I feel I've come close, with this methodology, basically coercing
yum to rebuild a database in a private directory:

  # installroot for yum
  workdir=/home/yum-hack

  rm -rf ${workdir}
  mkdir -p ${workdir}
  cd ${workdir}

  # list of newer RPMs (after transaction ID 1)
  new=new_rpms

  # dup repos and rpm/yum databases
  for tree in /var/lib/rpm/ /var/cache/yum/ /var/lib/yum/ /etc/yum.repos.d/; do
    echo ${tree}
    mkdir -p ./${tree}
    cp -pr ${tree}/* ./${tree}
  done

  cat new_rpm | xargs /usr/bin/yum -y --nogpgcheck --installroot=${workdir} \
    --setopt=tsflags=noscripts reinstall

On the surface, this seems to work, in that I now can see a transaction
list:

  yum --installroot=/home/yum-hack history list all

But, any effort to rollback to tid 1 yields:

  Transaction history is incomplete, before 5.
   You can use 'history rollback force', to try anyway.
  Error: Failed history rollback, incomplete

So, I've clearly tricked myself.

Does anyone have any suggestions about how I _should_ retroactively
invent an additional yum transaction?

This there some state I failed to introduce into the the above
private directory?

I've only begun to dive into the yum source to try to track down
what triggers this error, but if anyone has some immediate knowledge,
or suggestion for a better forum where I can ask this question?

Some details of my environment, if that's helpful:

  [root at 172-20-245-145 ~]# cat /etc/redhat-release
  CentOS release 6.5 (Final)
  [root at 172-20-245-145 ~]# rpm -q yum rpm
  yum-3.2.29-69.el6.centos.noarch
  rpm-4.8.0-37.el6.x86_64

Thanks for any advice...

-- 
Brian Reichert				<reichert at numachi.com>
BSD admin/developer at large	



More information about the CentOS mailing list