Hijacking The Mock Yum Buildroot

So I wanted to see if I could speed up common mock tasks without using their built-in caching methods as the buildroot package set is changing and it may not pick up those changes. The mock source code is located here (https://fedorahosted.org/mock/) and the results below show that on an x64 machine, the nled build went 22.5% faster! The downside is that you would have to set aside a dedicate builder to constantly create and tar the updated buildroots for the builders running the modified mock. Also note that the speed-up shown for the modified mock did not have to download the tar as it was locally stored.

Regular mock

# rm -rf /tmp/*mock.output* /var/lib/mock/* /var/cache/mock/* /tmp/buildroot.flag ; time mock -vr fedora-15-x86_64 --resultdir=/tmp/mock.output /tmp/nled-2.52-7.fc15.src.rpm 
INFO: mock.py version 1.1.9 starting...
INFO: Done(/tmp/nled-2.52-7.fc15.src.rpm) Config(fedora-15-x86_64) 1 minutes 36 seconds
DEBUG: kill orphans

real	1m37.880s
user	1m3.519s
sys	0m4.444s

Modified mock

# rm -rf /tmp/*mock.output* /var/lib/mock/* /var/cache/mock/* /tmp/buildroot.flag ; time ./py/mock.py -vr fedora-15-x86_64 --resultdir=/tmp/mock.output /tmp/nled-2.52-7.fc15.src.rpm 
INFO: mock.py version unreleased_version starting...
INFO: Done(/tmp/nled-2.52-7.fc15.src.rpm) Config(fedora-15-x86_64) 0 minutes 21 seconds
DEBUG: kill orphans

real	0m22.001s
user	0m44.526s
sys	0m2.925s


155:    decorate(traceLog())
156:    def _unlock_and_rm_chroot(self):
157:        if (os.path.exists("/tmp/buildroot.flag")):
158:            print("CUSTOM: HIJACK SAVING [%s]" % (self.makeChrootPath()))
159:            os.system("tar -cf \"/tmp/buildroot.tar\" -C '%s' ." % (self.makeChrootPath()))
160:            try:
161:                os.unlink("/tmp/buildroot.flag")
162:            except:
163:                pass
826:    decorate(traceLog())
827:    def _yum(self, cmd, returnOutput=0):
828:        """use yum to install packages/package groups into the chroot"""
829:        flag=0
830:        try:
831:            if ((cmd[0] == "groupinstall") and (cmd[1] == "buildsys-build")):
832:                flag=1
833:                if (os.path.exists("/tmp/buildroot.tar")):
834:                    os.system("tar -xvf /tmp/buildroot.tar -C '%s'" % (self.makeChrootPath()))
835:                    return ""
836:        except:
837:            pass
853:        try:
854:            self._callHooks("preyum")
855:            output = mockbuild.util.do(yumcmd, returnOutput=returnOutput)
856:            self._callHooks("postyum")
857:            if (flag == 1):
858:                os.system("touch /tmp/buildroot.flag")
859:                raise mockbuild.exception.YumError, "CUSTOM: HIJACK YUM ERROR"
860:            else:
861:                return output
862:        except mockbuild.exception.Error, e:
863:            raise mockbuild.exception.YumError, str(e)
Hijacking The Mock Yum Buildroot

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s