Outil pour générer la liste des paquets avec leurs versions.
darcs-hash:20080209182235-af139-ada04c70e8aabe4ac033c456e0a56222d0d400d4.gz
This commit is contained in:
parent
83de6af5dc
commit
f112789a58
1 changed files with 58 additions and 0 deletions
58
bcfg2/create-versions-index.py
Executable file
58
bcfg2/create-versions-index.py
Executable file
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# create-versions-index.py
|
||||
# ------------------------
|
||||
#
|
||||
# Copyright (C) 2008 Jeremie Dimino <jeremie@dimino.org>
|
||||
#
|
||||
# This file 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.
|
||||
#
|
||||
# This file 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
|
||||
|
||||
'''Outil pour générer la liste des paquets avec leurs version pour le
|
||||
plugin Rules de bcfg2.'''
|
||||
|
||||
__all__ = ["gen_rules"]
|
||||
|
||||
import apt, commands
|
||||
from xml.dom.minidom import Document
|
||||
|
||||
def gen_rules(cache):
|
||||
'''Création des règles'''
|
||||
doc = Document()
|
||||
root = doc.createElement("Rule")
|
||||
root.setAttribute("priority", "20")
|
||||
group = doc.createElement("Group")
|
||||
group.setAttribute("name", commands.getoutput("uname -m"))
|
||||
|
||||
for pkg in cache:
|
||||
if pkg.candidateVersion:
|
||||
pkginfo = doc.createElement("Package")
|
||||
pkginfo.setAttribute("name", pkg.name)
|
||||
pkginfo.setAttribute("version", pkg.candidateVersion)
|
||||
group.appendChild(pkginfo)
|
||||
|
||||
root.appendChild(group)
|
||||
|
||||
return root
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys, os, time
|
||||
|
||||
print >>sys.stderr, "Chargement du cache..."
|
||||
cache = apt.Cache()
|
||||
print >>sys.stderr, "Génération du document XML..."
|
||||
print ("<!-- Fichier autogénéré le %s avec %s -->" %
|
||||
(time.ctime(), os.path.basename(sys.argv[0])))
|
||||
sys.stdout.write(gen_rules(cache).toprettyxml())
|
Loading…
Add table
Add a link
Reference in a new issue