Commit 7c7081a6 authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmcs: implement group replacing

parent c23c6003
......@@ -35,6 +35,7 @@ toalt_pkgrepl()
s/| /|/g"
for i in $PKGREPLBASE/pkgrepl.fedora $PKGREPLBASE/pkgrepl.* ; do
#echo $i - $1
test -r "$i" || continue
REPLRULE=`grep -v "^#" "$i" 2>/dev/null | grep -- "$1\$" | sed -e "$WARULES" | sed -e "s/^\(.*\)|\(.*\)\$/\2|\1/g" | head -n1`
# For broken rule
echo $REPLRULE | grep "^|" >/dev/null && REPLRULE=""
......@@ -51,6 +52,34 @@ toalt_pkgrepl()
return 1
}
# TODO: down handle spaces correctly
# Get replacement rule for some group in $1 to ALT
toalt_grprepl()
{
local i REPLRULE WARULES
WARULES="s/^ //g
s/ \$//g
s/ |/|/g
s/| /|/g"
GRPREPLBASE=$PKGREPLBASE/../grprepl
for i in $GRPREPLBASE/grprepl.fedora $GRPREPLBASE/grprepl.rpm $GRPREPLBASE/grprepl.* ; do
test -r "$i" || continue
REPLRULE=`grep -v "^#" "$i" 2>/dev/null | grep -- "$1\$" | sed -e "$WARULES" | sed -e "s/^\(.*\)|\(.*\)\$/\2|\1/g" | head -n1`
# For broken rule
echo $REPLRULE | grep "^|" >/dev/null && REPLRULE=""
echo $REPLRULE | grep "|\$" >/dev/null && REPLRULE=""
if [ -n "$REPLRULE" ] ; then
GRPREPLRULE1=`echo $REPLRULE | cut -d"|" -f1 | sed -e "s|\+|\\\\\+|g"`
GRPREPLRULE2=`echo $REPLRULE | cut -d"|" -f2 | sed -e "s|\+|\\\\\+|g"`
return 0
else
GRPREPLRULE1=
GRPREPLRULE2=
fi
done
return 1
}
parse_cmd_pre "$@"
......@@ -330,6 +359,13 @@ do
#echo REPLRULE: $REPLRULE
done
echog -n "fix groups..."
for n in `print_grpreq $i` ; do
toalt_grprepl $n && ALLREPLRULES="$ALLREPLRULES
s|(^Group.*)$GRPREPLRULE1|\1$GRPREPLRULE2|g" && test -n "$VERBOSE" && echo "Replace '$GRPREPLRULE1' with '$GRPREPLRULE2'"
#echo REPLRULE: $REPLRULE
done
#echo ALL: $ALLREPLRULES
# Replace package names in source spec
......
......@@ -65,6 +65,12 @@ print_pkgreq()
eval_spec ${1} | grep "^Requires" | sed -e "s|^.*:||g" | clean_pkgreq
}
# Print list of all groups
print_grpreq()
{
eval_spec ${1} | grep "^Group" | sed -e "s|^.*:||g" | sort -u | filter_strip_spaces
}
# internal
print_replbased_list()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment