Exemplo n.º 1
0
    def _doMirror(self, mirrorCfg, sourceRepos, targetRepos, fullSync = False):

        from conary.conaryclient import mirror
        from conary.lib import util

        # set the correct tmpdir to use
        tmpDir = os.path.join(self.cfg.dataPath, 'tmp')
        if os.access(tmpDir, os.W_OK):
            util.settempdir(tmpDir)
            log.info("Using %s as tmpDir", tmpDir)
        else:
            log.warning("Using system temporary directory")

        fullSync = self.options.sync or fullSync
        if fullSync:
            log.info("Full sync requested on this mirror")
        if self.options.syncSigs:
            log.info("Full signature sync requested on this mirror")

        # first time through, we should pass in sync options;
        # subsequent passes should use the mirror marks
        passNumber = 1

        if self.options.test:
            # If we are testing, print the configuration
            if not self.options.showConfig:
                log.info("--test implies --show-config")
                self.options.showConfig = True

        if self.options.showConfig:
            print >> sys.stdout, "-- Start Mirror Configuration File --"
            mirrorCfg.display()
            print >> sys.stdout, "-- End Mirror Configuration File --"
            sys.stdout.flush()

        if self.options.test:
            log.info("Testing mode, not actually mirroring")
            return

        log.info("Beginning pass %d", passNumber)
        callAgain = mirror.mirrorRepository(sourceRepos, targetRepos,
            mirrorCfg, sync = self.options.sync or fullSync,
            syncSigs = self.options.syncSigs)
        log.info("Completed pass %d", passNumber)

        while callAgain:
            passNumber += 1
            log.info("Beginning pass %d", passNumber)
            callAgain = mirror.mirrorRepository(sourceRepos,
                targetRepos, mirrorCfg)
            log.info("Completed pass %d", passNumber)
Exemplo n.º 2
0
    def __init__(self,
                 readConfigFiles=False,
                 ignoreErrors=False,
                 readProxyValuesFirst=True):
        """
        Initialize a ConaryConfiguration object

        @param readConfigFiles: If True, read /etc/conaryrc and entitlements
        files
        @type readConfigFiles: bool

        @param ignoreErrors: If True, ParseError exceptions will not be raised
        @type ignoreErrors: bool

        @param readProxyValuesFirst: If True, parse local config files for
        proxy settings and apply them before further configuration.
        @type readProxyValuesFirst: bool

        @raises ParseError: Raised if configuration syntax is invalid and
        ignoreErrors is False.
        """
        SectionedConfigFile.__init__(self)
        self._ignoreErrors = ignoreErrors

        self.addListener('signatureKey', lambda *args: self._resetSigMap())

        if readConfigFiles:
            if readProxyValuesFirst:
                self.limitToKeys('conaryProxy', 'proxy')
                self.ignoreUrlIncludes()
                self.readFiles()
                self.limitToKeys(False)
                self.ignoreUrlIncludes(False)

            self.readFiles()
            # Entitlement files are config files
            self.readEntitlementDirectory()

        util.settempdir(self.tmpDir)
Exemplo n.º 3
0
    def __init__(self, readConfigFiles = False, ignoreErrors = False,
                 readProxyValuesFirst=True):
        """
        Initialize a ConaryConfiguration object

        @param readConfigFiles: If True, read /etc/conaryrc and entitlements
        files
        @type readConfigFiles: bool

        @param ignoreErrors: If True, ParseError exceptions will not be raised
        @type ignoreErrors: bool

        @param readProxyValuesFirst: If True, parse local config files for
        proxy settings and apply them before further configuration.
        @type readProxyValuesFirst: bool

        @raises ParseError: Raised if configuration syntax is invalid and
        ignoreErrors is False.
        """
        SectionedConfigFile.__init__(self)
        self._ignoreErrors = ignoreErrors

        self.addListener('signatureKey', lambda *args: self._resetSigMap())

        if readConfigFiles:
            if readProxyValuesFirst:
                self.limitToKeys('conaryProxy', 'proxy')
                self.ignoreUrlIncludes()
                self.readFiles()
                self.limitToKeys(False)
                self.ignoreUrlIncludes(False)

            self.readFiles()
            # Entitlement files are config files
            self.readEntitlementDirectory()

        util.settempdir(self.tmpDir)
Exemplo n.º 4
0
    def install(self):
        self.cfg.root = self.root
        self._lock(self.root, fcntl.LOCK_SH)
        if self.oldRoot:
            if self.serverCfg.reuseChroots:
                self._moveOldRoot(self.oldRoot, self.root)
        if not self.jobList and not self.crossJobList:
            # should only be true in debugging situations
            return

        manifest, done = self._restoreFromCache()
        self._breakLinks()
        if done:
            return

        def _install(jobList):
            self.cfg.flavor = []
            openpgpkey.getKeyCache().setPublicPath(
                                     self.cfg.root + '/root/.gnupg/pubring.gpg')
            openpgpkey.getKeyCache().setPrivatePath(
                                self.cfg.root + '/root/.gnupg/secring.gpg')
            self.cfg.pubRing = [self.cfg.root + '/root/.gnupg/pubring.gpg']
            client = conaryclient.ConaryClient(self.cfg)
            client.setUpdateCallback(self.callback)
            if self.csCache:
                changeSetList = self.csCache.getChangeSets(client.getRepos(),
                                                           jobList,
                                                           callback=self.callback)
            else:
                changeSetList = []

            updJob = client.newUpdateJob()
            try:
                client.prepareUpdateJob(updJob,
                    jobList, keepExisting=False, resolveDeps=False,
                    recurse=False, checkPathConflicts=False,
                    fromChangesets=changeSetList,
                    migrate=True)
            except conaryclient.update.NoNewTrovesError:
                # since we're migrating, this simply means there were no
                # operations to be performed
                pass
            else:
                util.mkdirChain(self.cfg.root + '/root')
                client.applyUpdate(updJob, replaceFiles=True,
                                   tagScript=self.cfg.root + '/root/tagscripts')

        self._installRPM()
        self._touchShadow()
        util.settempdir(self.cfg.root + self.cfg.tmpDir)

        if self.bootstrapJobList:
            self.logger.info("Installing initial chroot bootstrap requirements")
            oldRoot = self.cfg.dbPath
            try:
                # Bootstrap troves are installed outside the system DB,
                # although it doesn't matter as much in trove builds as it does
                # in image builds.
                self.cfg.dbPath += '.bootstrap'
                _install(self.bootstrapJobList)
            finally:
                self.cfg.dbPath = oldRoot

        if self.jobList:
            self.logger.info("Installing chroot requirements")
            _install(self.jobList)

        if self.crossJobList:
            self.logger.info("Installing chroot cross-compile requirements")
            oldRoot = self.cfg.root
            try:
                self.cfg.root += self.sysroot
                _install(self.crossJobList)
            finally:
                self.cfg.root = oldRoot

        util.settempdir(self.cfg.tmpDir)
        self._uninstallRPM()

        # directories must be traversable and files readable (RMK-1006)
        for root, dirs, files in os.walk(self.cfg.root, topdown=True):
            for directory in dirs:
                _addModeBits(os.sep.join((root, directory)), 05)
            for filename in files:
                _addModeBits(os.sep.join((root, filename)), 04)

        if manifest:
            manifest.write(self.cfg.root)
        if self.chrootFingerprint:
            strFingerprint = sha1helper.sha1ToString(self.chrootFingerprint)
            self.logger.info('caching chroot with fingerprint %s',
                    strFingerprint)
            self.chrootCache.store(self.chrootFingerprint, self.cfg.root)
            self.logger.info('caching chroot %s done',
                    strFingerprint)
            self._breakLinks()
Exemplo n.º 5
0
    def install(self):
        self.cfg.root = self.root
        self._lock(self.root, fcntl.LOCK_SH)
        if self.oldRoot:
            if self.serverCfg.reuseChroots:
                self._moveOldRoot(self.oldRoot, self.root)
        if not self.jobList and not self.crossJobList:
            # should only be true in debugging situations
            return

        manifest, done = self._restoreFromCache()
        self._breakLinks()
        if done:
            return

        def _install(jobList):
            self.cfg.flavor = []
            openpgpkey.getKeyCache().setPublicPath(self.cfg.root +
                                                   '/root/.gnupg/pubring.gpg')
            openpgpkey.getKeyCache().setPrivatePath(self.cfg.root +
                                                    '/root/.gnupg/secring.gpg')
            self.cfg.pubRing = [self.cfg.root + '/root/.gnupg/pubring.gpg']
            client = conaryclient.ConaryClient(self.cfg)
            client.setUpdateCallback(self.callback)
            if self.csCache:
                changeSetList = self.csCache.getChangeSets(
                    client.getRepos(), jobList, callback=self.callback)
            else:
                changeSetList = []

            updJob = client.newUpdateJob()
            try:
                client.prepareUpdateJob(updJob,
                                        jobList,
                                        keepExisting=False,
                                        resolveDeps=False,
                                        recurse=False,
                                        checkPathConflicts=False,
                                        fromChangesets=changeSetList,
                                        migrate=True)
            except conaryclient.update.NoNewTrovesError:
                # since we're migrating, this simply means there were no
                # operations to be performed
                pass
            else:
                util.mkdirChain(self.cfg.root + '/root')
                client.applyUpdate(updJob,
                                   replaceFiles=True,
                                   tagScript=self.cfg.root +
                                   '/root/tagscripts')

        self._installRPM()
        self._touchShadow()
        util.settempdir(self.cfg.root + self.cfg.tmpDir)

        if self.bootstrapJobList:
            self.logger.info(
                "Installing initial chroot bootstrap requirements")
            oldRoot = self.cfg.dbPath
            try:
                # Bootstrap troves are installed outside the system DB,
                # although it doesn't matter as much in trove builds as it does
                # in image builds.
                self.cfg.dbPath += '.bootstrap'
                _install(self.bootstrapJobList)
            finally:
                self.cfg.dbPath = oldRoot

        if self.jobList:
            self.logger.info("Installing chroot requirements")
            _install(self.jobList)

        if self.crossJobList:
            self.logger.info("Installing chroot cross-compile requirements")
            oldRoot = self.cfg.root
            try:
                self.cfg.root += self.sysroot
                _install(self.crossJobList)
            finally:
                self.cfg.root = oldRoot

        util.settempdir(self.cfg.tmpDir)
        self._uninstallRPM()

        # directories must be traversable and files readable (RMK-1006)
        for root, dirs, files in os.walk(self.cfg.root, topdown=True):
            for directory in dirs:
                _addModeBits(os.sep.join((root, directory)), 05)
            for filename in files:
                _addModeBits(os.sep.join((root, filename)), 04)

        if manifest:
            manifest.write(self.cfg.root)
        if self.chrootFingerprint:
            strFingerprint = sha1helper.sha1ToString(self.chrootFingerprint)
            self.logger.info('caching chroot with fingerprint %s',
                             strFingerprint)
            self.chrootCache.store(self.chrootFingerprint, self.cfg.root)
            self.logger.info('caching chroot %s done', strFingerprint)
            self._breakLinks()
Exemplo n.º 6
0
    def installFileTree(self, dest, bootloader_override=None, no_mbr=False):
        self.downloadChangesets()
        self.root = dest
        self.status("Installing image contents")
        self.loadRPM()

        if os.access(constants.tmpDir, os.W_OK):
            util.settempdir(constants.tmpDir)
            log.info("Using %s as tmpDir" % constants.tmpDir)
        else:
            log.warning("Using system temporary directory")

        self.conarycfg.root = dest
        self.conarycfg.installLabelPath = [self.baseVersion.trailingLabel()]
        self.conarycfg.configLine("pinTroves " + self.getPins())
        try:
            self.createDirectory("proc")
            self.createDirectory("sys")
            logCall("mount -n -t proc none %s" % os.path.join(dest, "proc"))
            logCall("mount -n -t sysfs none %s" % os.path.join(dest, "sys"))

            self.preInstallScripts()

            callback = None
            cclient = self._openClient(dest)
            try:
                callback = InstallCallback(self.status)
                cclient.setUpdateCallback(callback)

                # Tell SLES RPM scripts that we're building a fresh system
                os.environ["YAST_IS_RUNNING"] = "instsys"

                self.installBootstrapTroves(callback)
                self.updateGroupChangeSet(cclient)

                del os.environ["YAST_IS_RUNNING"]

            finally:
                cclient.close()
                if callback:
                    callback.closeCB()
                cclient = callback = None

            self.status("Finalizing install")
            util.rmtree(self.changesetDir)

            if not self.bootloader:
                self.bootloader = generators.get_bootloader(self, dest, self.geometry, bootloader_override)

            if no_mbr:
                self.bootloader.do_install = False
            if self.isDomU:
                self.bootloader.force_domU = True

            self.preTagScripts()
            self.runTagScripts()
            self.postTagScripts()

            return self.bootloader

        finally:
            try:
                self.killChrootProcesses(dest)
            except:
                log.exception("Error during cleanup:")
            try:
                self.umountChrootMounts(dest)
            except:
                log.exception("Error during cleanup:")