Géeneration automatique des listes de paquets pour bcfg2
darcs-hash:20080319233101-af139-5519d4ba2df29dfc00711f815adce99d93984343.gz
This commit is contained in:
parent
8c31851006
commit
c42796ee67
2 changed files with 42 additions and 21 deletions
|
@ -4,7 +4,7 @@
|
|||
# create-versions-index.py
|
||||
# ------------------------
|
||||
#
|
||||
# Copyright (C) 2008 Jeremie Dimino <jeremie@dimino.org>
|
||||
# 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
|
||||
|
@ -25,27 +25,32 @@ plugin Rules de bcfg2.'''
|
|||
|
||||
__all__ = []
|
||||
|
||||
import apt, commands
|
||||
from xml.dom.minidom import Document
|
||||
import apt_pkg, sys, os, time
|
||||
|
||||
if __name__ == "__main__":
|
||||
import 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
|
||||
|
||||
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])))
|
||||
list = ver.items()
|
||||
list.sort()
|
||||
|
||||
print '<Rule priority="20">'
|
||||
if "sid" in file("/etc/debian_version").read():
|
||||
print '<Group name="debian-testing">'
|
||||
else:
|
||||
print '<Group name="debian-testing" negate="true">'
|
||||
print '<Group name="%s">' % commands.getoutput("uname -m")
|
||||
for pkg in cache:
|
||||
if pkg.candidateVersion:
|
||||
print ('<Package name="%s" version="%s"/>' %
|
||||
(pkg.name, pkg.candidateVersion))
|
||||
print '</Group></Group></Rule>'
|
||||
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>'
|
||||
|
||||
|
|
16
bcfg2/create-versions-index.sh
Executable file
16
bcfg2/create-versions-index.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Outil pour générer la liste des paquets pour bcfg2
|
||||
|
||||
generate () {
|
||||
# $1 = distribution (etch, lenny, ...)
|
||||
distrib=$1
|
||||
arch=$2
|
||||
arch2=$3
|
||||
cat $(locate -r "/$distrib/.*/binary-$arch/Packages$") /mirror/custom/Packages | \
|
||||
awk '$1 == "Package:" {printf "%s ", $2} $1 == "Version:" {print $2}' | \
|
||||
/usr/scripts/bcfg2/create-versions-index.py $arch2 $distrib > /usr/scripts/var/bcfg2/packages-generated-$distrib-$arch2.xml
|
||||
}
|
||||
|
||||
generate etch i386 i686
|
||||
generate etch amd64 x86_64
|
Loading…
Add table
Add a link
Reference in a new issue