]> git.proxmox.com Git - mirror_lxc.git/blame - config/yum/lxc-patch.py
string_utils: coding rules
[mirror_lxc.git] / config / yum / lxc-patch.py
CommitLineData
7ceebfd1
DE
1# Yum plugin to re-patch container rootfs after a yum update is done
2#
3# Copyright (C) 2012 Oracle
4#
5# Authors:
6# Dwight Engen <dwight.engen@oracle.com>
7#
391260dc
DE
8# This library is free software; you can redistribute it and/or
9# modify it under the terms of the GNU Lesser General Public
10# License as published by the Free Software Foundation; either
11# version 2.1 of the License, or (at your option) any later version.
7ceebfd1 12#
391260dc 13# This library is distributed in the hope that it will be useful,
7ceebfd1 14# but WITHOUT ANY WARRANTY; without even the implied warranty of
391260dc
DE
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16# Lesser General Public License for more details.
7ceebfd1 17#
391260dc
DE
18# You should have received a copy of the GNU Lesser General Public
19# License along with this library; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
21# USA
7ceebfd1
DE
22#
23
24import os
25from fnmatch import fnmatch
26from yum.plugins import TYPE_INTERACTIVE
27from yum.plugins import PluginYumExit
28
29requires_api_version = '2.0'
30plugin_type = (TYPE_INTERACTIVE,)
31
32def posttrans_hook(conduit):
33 pkgs = []
34 patch_required = False
35
36 # If we aren't root, we can't have updated anything
37 if os.geteuid():
38 return
39
40 # See what packages have files that were patched
41 confpkgs = conduit.confString('main', 'packages')
42 if not confpkgs:
43 return
44
45 tmp = confpkgs.split(",")
46 for confpkg in tmp:
47 pkgs.append(confpkg.strip())
48
49 conduit.info(2, "lxc-patch: checking if updated pkgs need patching...")
50 ts = conduit.getTsInfo()
51 for tsmem in ts.getMembers():
52 for pkg in pkgs:
53 if fnmatch(pkg, tsmem.po.name):
54 patch_required = True
55 if patch_required:
56 conduit.info(2, "lxc-patch: patching container...")
57 os.spawnlp(os.P_WAIT, "lxc-patch", "lxc-patch", "--patch", "/")