コード例 #1
0
# the agent and manager.
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

yp = YumBase()
yp.preconf.debuglevel = 0
yp.preconf.errorlevel = 0
yp.doLock()
yp.getReposFromConfig()
yp.doSackFilelistPopulate()

packages = ["python2-iml-agent"]

if "IML_PROFILE_PACKAGES" in os.environ:
    packages += os.environ["IML_PROFILE_PACKAGES"].split(",")

ypl = yp.doPackageLists(pkgnarrow="updates", patterns=packages)

has_updates = len(ypl.updates) > 0

if "IML_PROFILE_REPOS" in os.environ:
    for bundle in os.environ["IML_PROFILE_REPOS"].split(","):
        if bundle == "external":
            continue
        ypl = yp.doPackageLists(pkgnarrow=["updates"], repoid=bundle)
        has_updates |= len(ypl.updates) > 0

yp.close()
yp.closeRpmDB()
yp.doUnlock()

resp = requests.post(
コード例 #2
0
ファイル: dump_rpm_existing.py プロジェクト: esunny/Ailurus
#coding: utf-8
#
# Ailurus - a simple application installer and GNOME tweaker
#
# Copyright (C) 2009-2010, Ailurus developers and Ailurus contributors
# Copyright (C) 2007-2010, Trusted Digital Technology Laboratory, Shanghai Jiao Tong University, China.
#
# Ailurus is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Ailurus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ailurus; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA

import sys
from yum import YumBase
base = YumBase()
ygh = base.doPackageLists()
for available in ygh.available:
    name = available.pkgtup[0]
    print >>sys.stderr, name # because base.doPackageLists prints text to stdout
コード例 #3
0
ファイル: updatepackages.py プロジェクト: bjwt/leopard
def main(directory, version):
    """
    Update packages in directory and install all those available

    @type  directory: string
    @param directory: path to the directory which contains a copy of the whole system

    @type  version: string
    @param version: PowerKVM version used to update system

    @rtype: boolean
    @returns: True if the packages was successfully updated;
              False otherwise
    """
    os.chroot(directory)

    # update all packages
    yumBase = YumBase()

    # get all enabled repos
    enabledRepos = yumBase.repos.listEnabled()

    # disable all yum repos
    yumBase.repos.disableRepo('*')

    # enable only the powerkvm repo
    yumBase.repos.enableRepo('powerkvm-%s' % version)

    # update system
    yumBase.update()

    rc, msgs = yumBase.buildTransaction()
    if rc != 2:
        return False

    try:
        yumBase.processTransaction()
    except:
        return False

    # check if there is more than one kernel installed
    # if so, remove one
    availableKernels = yumBase.searchPackages(['name'], ['kernel'])
    installedKernels = 0

    for pkg in availableKernels:
        if pkg.repoid == 'installed' and pkg.name == 'kernel':
            installedKernels += 1

    if installedKernels != 1:
        yumBase.remove(name='kernel')

    # install new packages available in the repo
    pkgs = yumBase.doPackageLists().available
    for pkg in pkgs:
        yumBase.install(pkg)

    # build and process the YUM transaction
    rc, msgs = yumBase.buildTransaction()
    if rc != 2:
        return False

    try:
        yumBase.processTransaction()
    except:
        return False

    # re-enable the repos
    for repo in enabledRepos:
        repo.enable()

    return True