#!/bin/bash
#################################################################################
#
# Name : CentOS comps.xml generator
# Function : merge all the upstream comps.xml file into one
# How to call it : see usage()
# Author : Fabian Arrotin (arrfab@centos.org)
# Requirements : sqlite3 / xmlstarlet
#
#################################################################################
usage() {
cat << EOF
You need to call the script like this : $0 -arguments
-a : define the arch (required, default:none, values : [i386,x86_64])
-p : define the path containing all the Upstream comps.xml files for all variants(required, default:none)
-r : release to build ( eg. 6 - important as some releases do comps differently )
-h : display this help
EOF
}
while getopts “ha:p:m:r:” OPTION
do
case $OPTION in
h)
usage
exit 1
;;
a)
arch=$OPTARG
;;
p)
destdir=$OPTARG
;;
r)
release=$OPTARG
;;
?)
usage
exit
;;
esac
done
varcheck() {
if [ -z "$1" ] ; then
usage
exit 1
fi
}
compsxmlin() {
echo Creating Comps DB tables ...
echo "CREATE TABLE categories (id ,name, desc, display_order ); CREATE TABLE languages (lang); CREATE TABLE groups (id, name, desc, def, uservisible, langonly, packagelist); CREATE TABLE grouplist (groupid, category_id); CREATE TABLE environments (id,name,description,def,displayorder,grouplist,optionlist); " |sqlite3 $sqlitedb
# beginning the loop for each xml file
for xmlfile in $(ls $destdir/*.xml);
do
# just do that once
if [ "$aretableready" = "1" ] ; then
echo "Languages tables are already filled ... "
else
echo Detecting languages and preparing - altering the tables ...
if [ "$release" = "7" ]; then
for lang in $(grep 'name xml:lang=' $xmlfile|sed s/@/_arobas_/g|cut -f 1 -d '>'|cut -f 2 -d '"'|sort|uniq);do echo "insert into languages values ('$lang') ;"|sqlite3 $sqlitedb;done
else
for lang in $(grep 'description xml:lang=' $xmlfile|sed s/@/_arobas_/g|cut -f 1 -d '>'|cut -f 2 -d '"'|sort|uniq);do echo "insert into languages values ('$lang') ;"|sqlite3 $sqlitedb;done
fi
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb);do echo "alter table categories add desc_$lang ; alter table categories add name_$lang ; "|sqlite3 $sqlitedb;done
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb);do echo "alter table groups add desc_$lang ; alter table groups add name_$lang ; "|sqlite3 $sqlitedb;done
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb);do echo "alter table environments add desc_$lang ; alter table environments add name_$lang ; "|sqlite3 $sqlitedb;done
export aretableready='1'
fi
echo Processing now $xmlfile
echo Detecting categories and filling the tables ...
# categories/id
for id in $(xmlstarlet sel -t -m "//comps/category" -v id -n $xmlfile);do isindb=$(echo "select id from categories where id='$id';"|sqlite3 $sqlitedb ) ;test "$isindb" = "$id" || (echo "insert into categories (id) values ('$id');"|sqlite3 $sqlitedb);done
# categories/name
for id in $(xmlstarlet sel -t -m "//comps/category" -v id -n $xmlfile); do name=$(xmlstarlet sel -t -m "//comps/category[id='$id']" -v name $xmlfile);isindb=$(echo "select name from categories where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$name" || (echo "update categories set name='$name' where id='$id' ;"|sqlite3 $sqlitedb ); done
# categories/description
for id in $(xmlstarlet sel -t -m "//comps/category" -v id -n $xmlfile); do desc=$(xmlstarlet sel -t -m "//comps/category[id='$id']" -v description $xmlfile);echo "update categories set desc='$desc' where id='$id' ;"|sqlite3 $sqlitedb; done
# categories/display_order
for id in $(xmlstarlet sel -t -m "//comps/category" -v id -n $xmlfile); do display_order=$(xmlstarlet sel -t -m "//comps/category[id='$id']" -v display_order $xmlfile); isindb=$(echo "select display_order from categories where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$display_order" || (echo "update categories set display_order='$display_order' where id='$id' ;"|sqlite3 $sqlitedb); done
# categories/name_$lang
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb|sed s/_arobas_/@/g);do for id in $(xmlstarlet sel -t -m "//comps/category" -v id -n $xmlfile);do namelang=$(xmlstarlet sel -t -m "//comps/category[id='$id']" -v "name[@xml:lang='$lang']" $xmlfile); langsql=$(echo $lang|sed s/@/_arobas_/g) ; isindb=$(echo "select name_$langsql from categories where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$namelang" || (namelangsql=$(echo $namelang|sed s/"'"/"''"/g) ;echo "update categories set name_$langsql='$namelangsql' where id='$id';"|sqlite3 $sqlitedb) ; done ; done
# categories/description_$lang
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb|sed s/_arobas_/@/g);do for id in $(xmlstarlet sel -t -m "//comps/category" -v id -n $xmlfile);do desclang=$(xmlstarlet sel -t -m "//comps/category[id='$id']" -v "description[@xml:lang='$lang']" $xmlfile); langsql=$(echo $lang|sed s/@/_arobas_/g) ; isindb=$(echo "select desc_$langsql from categories where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$desclang" || (desclangsql=$(echo $desclang|sed s/"'"/"''"/g) ;echo "update categories set desc_$langsql='$desclangsql' where id='$id';"|sqlite3 $sqlitedb) ; done ; done
# categories/grouplist
for id in $(xmlstarlet sel -t -m "//comps/category" -v id -n $xmlfile); do for groupid in $(xmlstarlet sel -t -m "//comps/category[id='$id']" -v grouplist $xmlfile); do isindb=$(echo "select groupid from grouplist where category_id='$id' and groupid='$groupid';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$groupid" || (echo "insert into grouplist (groupid, category_id) values ('$groupid','$id');"|sqlite3 $sqlitedb); done ; done
echo Detecting groups and filling the tables ...
# groups/id
for id in $(xmlstarlet sel -t -m "//comps/group" -v id -n $xmlfile);do isindb=$(echo "select id from groups where id='$id';"|sqlite3 $sqlitedb ) ;test "$isindb" = "$id" || (echo "insert into groups (id) values ('$id');"|sqlite3 $sqlitedb);done
# groups/name
for id in $(xmlstarlet sel -t -m "//comps/group" -v id -n $xmlfile); do name=$(xmlstarlet sel -t -m "//comps/group[id='$id']" -v name $xmlfile);isindb=$(echo "select name from groups where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$name" || (echo "update groups set name='$name' where id='$id' ;"|sqlite3 $sqlitedb ); done
# groups/default
for id in $(xmlstarlet sel -t -m "//comps/group" -v id -n $xmlfile); do def=$(xmlstarlet sel -t -m "//comps/group[id='$id']" -v default $xmlfile);isindb=$(echo "select def from groups where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$def" || (echo "update groups set def='$def' where id='$id' ;"|sqlite3 $sqlitedb ); done
# groups/description
for id in $(xmlstarlet sel -t -m "//comps/group" -v id -n $xmlfile); do desc=$(xmlstarlet sel -t -m "//comps/group[id='$id']" -v description $xmlfile);isindb=$(echo "select desc from groups where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$desc" || (descsql=$(echo $desc|sed s/"'"/"''"/g) ; echo "update groups set desc='$descsql' where id='$id' ;"|sqlite3 $sqlitedb ); done
# groups/uservisible
for id in $(xmlstarlet sel -t -m "//comps/group" -v id -n $xmlfile); do uservisible=$(xmlstarlet sel -t -m "//comps/group[id='$id']" -v uservisible $xmlfile);isindb=$(echo "select uservisible from groups where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$uservisible" || (echo "update groups set uservisible='$uservisible' where id='$id' ;"|sqlite3 $sqlitedb ); done
# groups/langonly
for id in $(xmlstarlet sel -t -m "//comps/group" -v id -n $xmlfile); do langonly=$(xmlstarlet sel -t -m "//comps/group[id='$id']" -v langonly $xmlfile);isindb=$(echo "select langonly from groups where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$langonly" || (echo "update groups set langonly='$langonly' where id='$id' ;"|sqlite3 $sqlitedb ); done
# groups/name_$lang
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb|sed s/_arobas_/@/g);do for id in $(xmlstarlet sel -t -m "//comps/group" -v id -n $xmlfile);do namelang=$(xmlstarlet sel -t -m "//comps/group[id='$id']" -v "name[@xml:lang='$lang']" $xmlfile); langsql=$(echo $lang|sed s/@/_arobas_/g) ; isindb=$(echo "select name_$langsql from groups where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$namelang" || (namelangsql=$(echo $namelang|sed s/"'"/"''"/g) ; echo "update groups set name_$langsql='$namelangsql' where id='$id';"|sqlite3 $sqlitedb) ; done ; done
# groups/desc_$lang
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb|sed s/_arobas_/@/g);do for id in $(xmlstarlet sel -t -m "//comps/group" -v id -n $xmlfile);do desclang=$(xmlstarlet sel -t -m "//comps/group[id='$id']" -v "description[@xml:lang='$lang']" $xmlfile); langsql=$(echo $lang|sed s/@/_arobas_/g) ; isindb=$(echo "select desc_$langsql from groups where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$desclang" || (desclangsql=$(echo $desclang|sed s/"'"/"''"/g) ; echo "update groups set desc_$langsql='$desclangsql' where id='$id';"|sqlite3 $sqlitedb) ; done ; done
# groups/packagelist
for id in $(xmlstarlet sel -t -m "//comps/group" -v id -n $xmlfile);
do
packagelist=$(xmlstarlet sel -t -m "//comps/group[id='$id']" -c packagelist $xmlfile|sed '/packagelist/d')
isindb=$(echo "select packagelist from groups where id='$id';"|sqlite3 $sqlitedb )
if [ -z "$isindb" ] ; then
echo "update groups set packagelist='$packagelist' where id='$id' ;"|sqlite3 $sqlitedb
else
breakline='
'
newpkglist=${isindb}${breakline}${packagelist}
toinsert=$(echo "$newpkglist"|sort|uniq)
echo "update groups set packagelist='$toinsert' where id='$id' ;"|sqlite3 $sqlitedb
fi
done
# Special case for release 7 as anaconda now use environment tags in the xml not present in 5 and 6
if [ "$release" = "7" ] ;then
echo "Detecting environments and filling the tables ..."
# environments/id
for id in $(xmlstarlet sel -t -m "//comps/environment" -v id -n $xmlfile);do isindb=$(echo "select id from environments where id='$id';"|sqlite3 $sqlitedb ) ;test "$isindb" = "$id" || (echo "insert into environments (id) values ('$id');"|sqlite3 $sqlitedb);done
# enviroments/name
for id in $(xmlstarlet sel -t -m "//comps/environment" -v id -n $xmlfile); do name=$(xmlstarlet sel -t -m "//comps/environment[id='$id']" -v name $xmlfile);isindb=$(echo "select name from environments where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$name" || (echo "update environments set name='$name' where id='$id' ;"|sqlite3 $sqlitedb ); done
# environments/description
for id in $(xmlstarlet sel -t -m "//comps/environment" -v id -n $xmlfile); do desc=$(xmlstarlet sel -t -m "//comps/environment[id='$id']" -v description $xmlfile);isindb=$(echo "select description from environments where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$desc" || (descsql=$(echo $desc|sed s/"'"/"''"/g) ; echo "update environments set description='$descsql' where id='$id' ;"|sqlite3 $sqlitedb ); done
# environments/display_order
for id in $(xmlstarlet sel -t -m "//comps/environment" -v id -n $xmlfile); do displayorder=$(xmlstarlet sel -t -m "//comps/environment[id='$id']" -v display_order $xmlfile);isindb=$(echo "select displayorder from environments where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$displayorder" || (echo "update environments set displayorder='$displayorder' where id='$id' ;"|sqlite3 $sqlitedb ); done
# environments/name_$lang
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb|sed s/_arobas_/@/g);do for id in $(xmlstarlet sel -t -m "//comps/environment" -v id -n $xmlfile);do namelang=$(xmlstarlet sel -t -m "//comps/environment[id='$id']" -v "name[@xml:lang='$lang']" $xmlfile); langsql=$(echo $lang|sed s/@/_arobas_/g) ; isindb=$(echo "select name_$langsql from environments where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$namelang" || (namelangsql=$(echo $namelang|sed s/"'"/"''"/g) ; echo "update environments set name_$langsql='$namelangsql' where id='$id';"|sqlite3 $sqlitedb) ; done ; done
# environments/desc_$lang
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb|sed s/_arobas_/@/g);do for id in $(xmlstarlet sel -t -m "//comps/environment" -v id -n $xmlfile);do desclang=$(xmlstarlet sel -t -m "//comps/environment[id='$id']" -v "description[@xml:lang='$lang']" $xmlfile); langsql=$(echo $lang|sed s/@/_arobas_/g) ; isindb=$(echo "select desc_$langsql from environments where id='$id';"|sqlite3 $sqlitedb ) ; test "$isindb" = "$desclang" || (desclangsql=$(echo $desclang|sed s/"'"/"''"/g) ; echo "update environments set desc_$langsql='$desclangsql' where id='$id';"|sqlite3 $sqlitedb) ; done ; done
# environments/grouplist
for id in $(xmlstarlet sel -t -m "//comps/environment" -v id -n $xmlfile);
do
grouplist=$(xmlstarlet sel -t -m "//comps/environment[id='$id']" -c grouplist $xmlfile|sed '/grouplist/d')
isindb=$(echo "select grouplist from environments where id='$id';"|sqlite3 $sqlitedb )
if [ -z "$isindb" ] ; then
echo "update environments set grouplist='$grouplist' where id='$id' ;"|sqlite3 $sqlitedb
else
breakline='
'
newgrplist=${isindb}${breakline}${grouplist}
toinsert=$(echo "$newgrplist"|sort|uniq)
echo "update environments set grouplist='$toinsert' where id='$id' ;"|sqlite3 $sqlitedb
fi
done
# environments/optionlist
for id in $(xmlstarlet sel -t -m "//comps/environment" -v id -n $xmlfile);
do
optionlist=$(xmlstarlet sel -t -m "//comps/environment[id='$id']" -c optionlist $xmlfile|sed '/optionlist/d')
isindb=$(echo "select optionlist from environments where id='$id';"|sqlite3 $sqlitedb )
if [ -z "$isindb" ] ; then
echo "update environments set optionlist='$optionlist' where id='$id' ;"|sqlite3 $sqlitedb
else
breakline='
'
newoptlist=${isindb}${breakline}${optionlist}
toinsert=$(echo "$newoptlist"|sort|uniq)
echo "update environments set optionlist='$toinsert' where id='$id' ;"|sqlite3 $sqlitedb
fi
done
# end of environments for release 7
fi
#final done for the xmlfile loop
done
}
dbupdate() {
# Fixing some groups that are by default active but have to be deselected on a CentOS install
if [ "$release" = "6" ];then
for groupid in client-mgmt-tools ha ha-management load-balancer resilient-storage scalable-file-systems ;do
echo "update groups set def='false' where id='$groupid';"|sqlite3 $sqlitedb
done
elif [ "$release" = "5" ];then
for groupid in admin-tools base-x games gnome-desktop graphical-internet graphics hyperv java legacy-software-support office printing sound-and-video cluster-storage clustering xen ;do
echo "update groups set def='false' where id='$groupid';"|sqlite3 $sqlitedb
done
for groupid in base dialup ;do
echo "update groups set uservisible='true' where id='$groupid';"|sqlite3 $sqlitedb
done
fi
}
compsxmlout() {
echo Generating the $outputxml file ...
echo "<?xml version='1.0' encoding='UTF-8'?>" >$outputxml
echo "<!DOCTYPE comps PUBLIC \"-//CentOS//DTD Comps info//EN\" \"comps.dtd\">" >> $outputxml
echo "<comps>" >> $outputxml
#group
for id in $(echo "select id from groups;"|sqlite3 $sqlitedb);do
echo " <group>" >>$outputxml
echo " <id>$id</id>" >> $outputxml
name=$(echo "select name from groups where id='$id';"|sqlite3 $sqlitedb)
echo " <name>$name</name>" >> $outputxml
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb) ;do
namelang=$(echo "select name_$lang from groups where id='$id';"|sqlite3 $sqlitedb )
if [ -n "$namelang" ] ; then
langxml=$(echo $lang|sed s/_arobas_/@/g)
echo " <name xml:lang='$langxml'>$namelang</name>" >> $outputxml
fi
done
desc=$(echo "select desc from groups where id='$id';"|sqlite3 $sqlitedb)
if [ -n "$desc" ] ; then
echo " <description>$desc</description>" >> $outputxml
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb) ;do
desclang=$(echo "select desc_$lang from groups where id='$id';"|sqlite3 $sqlitedb )
if [ -n "$desclang" ] ; then
langxml=$(echo $lang|sed s/_arobas_/@/g)
echo " <description xml:lang='$langxml'>$desclang</description>" >> $outputxml
fi
done
else
echo " <description/>" >> $outputxml
fi
def=$(echo "select def from groups where id='$id';"|sqlite3 $sqlitedb)
echo " <default>$def</default>" >> $outputxml
uservisible=$(echo "select uservisible from groups where id='$id';"|sqlite3 $sqlitedb)
echo " <uservisible>$uservisible</uservisible>" >> $outputxml
langonly=$(echo "select langonly from groups where id='$id';"|sqlite3 $sqlitedb)
if [ -n "$langonly" ] ; then
echo " <langonly>$langonly</langonly>" >> $outputxml
fi
plist=$(echo "select packagelist from groups where id='$id';"|sqlite3 $sqlitedb )
echo " <packagelist>" >>$outputxml
echo " $plist" >>$outputxml
echo " </packagelist>" >>$outputxml
echo " </group>" >>$outputxml
done
#category
for id in $(echo "select id from categories;"|sqlite3 $sqlitedb);do
echo " <category>" >>$outputxml
echo " <id>$id</id>" >> $outputxml
name=$(echo "select name from categories where id='$id';"|sqlite3 $sqlitedb)
echo " <name>$name</name>" >> $outputxml
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb) ;do
namelang=$(echo "select name_$lang from categories where id='$id';"|sqlite3 $sqlitedb )
if [ -n "$namelang" ] ; then
langxml=$(echo $lang|sed s/_arobas_/@/g)
echo " <name xml:lang='$langxml'>$namelang</name>" >> $outputxml
fi
done
desc=$(echo "select desc from categories where id='$id';"|sqlite3 $sqlitedb)
echo " <description>$desc</description>" >> $outputxml
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb) ;do
desclang=$(echo "select desc_$lang from categories where id='$id';"|sqlite3 $sqlitedb )
if [ -n "$desclang" ] ; then
langxml=$(echo $lang|sed s/_arobas_/@/g)
echo " <description xml:lang='$langxml'>$desclang</description>" >> $outputxml
fi
done
echo " <grouplist>" >>$outputxml
for groupid in $(echo "select groupid from grouplist where category_id='$id';"|sqlite3 $sqlitedb) ; do
echo " <groupid>$groupid</groupid>" >>$outputxml
done
echo " </grouplist>" >>$outputxml
echo " </category>" >>$outputxml
done
if [ "$release" = "7" ] ; then
#environment
for id in $(echo "select id from environments;"|sqlite3 $sqlitedb);do
echo " <environment>" >>$outputxml
echo " <id>$id</id>" >> $outputxml
name=$(echo "select name from environments where id='$id';"|sqlite3 $sqlitedb)
echo " <name>$name</name>" >> $outputxml
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb) ;do
namelang=$(echo "select name_$lang from environments where id='$id';"|sqlite3 $sqlitedb )
if [ -n "$namelang" ] ; then
langxml=$(echo $lang|sed s/_arobas_/@/g)
echo " <name xml:lang='$langxml'>$namelang</name>" >> $outputxml
fi
done
desc=$(echo "select description from environments where id='$id';"|sqlite3 $sqlitedb)
echo " <description>$desc</description>" >> $outputxml
for lang in $(echo "select * from languages;" |sqlite3 $sqlitedb) ;do
desclang=$(echo "select desc_$lang from environments where id='$id';"|sqlite3 $sqlitedb )
if [ -n "$desclang" ] ; then
langxml=$(echo $lang|sed s/_arobas_/@/g)
echo " <description xml:lang='$langxml'>$desclang</description>" >> $outputxml
fi
done
displayorder=$(echo "select displayorder from environments where id='$id';"|sqlite3 $sqlitedb)
echo " <display_order>$displayorder</display_order>" >> $outputxml
grouplist=$(echo "select grouplist from environments where id='$id';"|sqlite3 $sqlitedb )
echo " <grouplist>" >>$outputxml
echo " $grouplist" >>$outputxml
echo " </grouplist>" >>$outputxml
optionlist=$(echo "select optionlist from environments where id='$id';"|sqlite3 $sqlitedb )
echo " <optionlist>" >>$outputxml
echo " $optionlist" >>$outputxml
echo " </optionlist>" >>$outputxml
echo " </environment>" >>$outputxml
done
# Adding the langpacks not entered into sqlite as it's really small
echo ' <langpacks>
<match install="autocorr-%s" name="autocorr-en"/>
<match install="firefox-langpack-%s" name="firefox"/>
<match install="gimp-help-%s" name="gimp-help"/>
<match install="gnome-getting-started-docs-%s" name="gnome-getting-started-docs"/>
<match install="hunspell-%s" name="hunspell"/>
<match install="hyphen-%s" name="hyphen"/>
<match install="kde-l10n-%s" name="kdelibs"/>
<match install="libreoffice-langpack-%s" name="libreoffice-core"/>
<match install="man-pages-%s" name="man-pages"/>
<match install="mythes-%s" name="mythes"/>
</langpacks> ' >>$outputxml
# Enf release 7 special conditonal output
fi
echo "" >> $outputxml
echo "</comps>" >> $outputxml
# Now fixing some well-known branding issues (as the new comps.xml is still generated from upstream xml files)
if [ "$release" = "6" ];then
sed -i s/"Red Hat Enterprise Linux"/"CentOS Linux"/g $outputxml
sed -i s/"redhat-indexhtml"/"centos-indexhtml"/g $outputxml
sed -i '/Red_Hat_Enterprise_Linux-Release_Notes/d' $outputxml
sed -i '/subscription-manager-gnome/d' $outputxml
sed -i '/subscription-manager/d' $outputxml
sed -i '/subscription-manager-firstboot/d' $outputxml
sed -i '/redhat-support-tool/d' $outputxml
sed -i '/rhn-setup-gnome/d' $outputxml
sed -i '/rhnsd/d' $outputxml
sed -i '/yum-rhn-plugin/d' $outputxml
elif [ "$release" = "7" ];then
sed -i s/"Red Hat Enterprise Linux"/"CentOS Linux"/g $outputxml
sed -i s/"redhat-indexhtml"/"centos-indexhtml"/g $outputxml
sed -i '/Red_Hat_Enterprise_Linux-Release_Notes/d' $outputxml
sed -i '/subscription-manager-gnome/d' $outputxml
sed -i '/subscription-manager/d' $outputxml
sed -i '/subscription-manager-firstboot/d' $outputxml
sed -i '/redhat-support-tool/d' $outputxml
sed -i '/rhn-setup-gnome/d' $outputxml
sed -i '/rhnsd/d' $outputxml
sed -i '/yum-rhn-plugin/d' $outputxml
sed -i '/redhat-release/d' $outputxml
elif [ "$release" = "5" ];then
sed -i '/redhat-release-notes/d' $outputxml
sed -i s/"Red Hat"/"CentOS"/g $outputxml
sed -i s/"redhat-release"/"centos-release"/g $outputxml
sed -i '/redhat-support-tool/d' $outputxml
fi
}
sqlitedb="/dev/shm/comps-$release-$arch.db"
outputxml="c$release-$arch-comps.xml"
# and now the real processing ...
varcheck $arch
varcheck $destdir
varcheck $release
for binary in sqlite3 xmlstarlet xsltproc ;do
which $binary > /dev/null 2>&1
if [ "$?" = "1" ] ;then
echo "Binary $binary not found ... exiting"
exit 1
fi
done
if [ -e $sqlitedb ] ;then
echo "$sqlitedb file already existing - not overwriting by default ..."
exit 1
fi
echo sqlite file = $sqlitedb
echo Generated comps xml file = $outputxml
time compsxmlin
dbupdate
time compsxmlout
echo "Cleaning-up produced $outputxml file with xsltproc ..."
/bin/cp $outputxml $outputxml-toclean
xsltproc --novalid --output $outputxml $(dirname $0)/comps-cleanup.xsl $outputxml-toclean
echo "Validating final $outputxml file .."
xmlstarlet val $outputxml