scripts/bcfg2/create-versions-index.py
Jeremie Dimino c42796ee67 Géeneration automatique des listes de paquets pour bcfg2
darcs-hash:20080319233101-af139-5519d4ba2df29dfc00711f815adce99d93984343.gz
2008-03-20 00:31:01 +01:00

56 lines
1.6 KiB
Python
Executable file

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# create-versions-index.py
# ------------------------
#
# Copyright (C) 2008 Jeremie Dimino <dimino@crans.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__ = []
import apt_pkg, sys, os, time
apt_pkg.init()
ver = {}
for line in sys.stdin:
[name, new_ver] = line.split()
old_ver = ver.get(name, None)
if not old_ver or apt_pkg.VersionCompare(new_ver, old_ver) == 1:
ver[name] = new_ver
list = ver.items()
list.sort()
print ("<!-- Fichier autogénéré le %s avec %s -->" %
(time.ctime(), os.path.basename(sys.argv[0])))
print '<Rule priority="20">'
if sys.argv[2] == "testing":
print '<Group name="debian-testing">'
else:
print '<Group name="debian-testing" negate="true">'
print '<Group name="%s">' % sys.argv[1]
for (name,ver) in list:
print '<Package name="%s" version="%s"/>' % (name, ver)
print '</Group></Group></Rule>'