Commit d1377c05 authored by Vitaly Lipatov's avatar Vitaly Lipatov

breaks changes in estrlist and fix rpmreqs, improve test for estrlist

parent 5a3b9a1a
......@@ -29,8 +29,7 @@ filter_strip_spaces()
{
# possible use just
#xargs echo
sed -e "s| \+| |g" | \
sed -e "s|^ ||" | sed -e "s| \$||"
sed -e "s| \+| |g" -e "s|^ ||" -e "s| \$||"
}
strip_spaces()
......@@ -53,7 +52,7 @@ count()
union()
{
list $@ | sort -u
strip_spaces $(list $@ | sort -u)
}
uniq()
......@@ -67,13 +66,24 @@ reg_remove()
local i
local RES=
for i in $2 ; do
echo "$i" | grep -q "$1" || RES="$RES $i"
done
strip_spaces "$RES"
}
# remove_from_list "1." "11 12 21 22" -> "21 22"
reg_wordremove()
{
local i
local RES=
for i in $2 ; do
echo "$i" | grep -q -w "$1" || RES="$RES $i"
done
strip_spaces "$RES"
}
# Args: LIST1 LIST2
# do_exclude_list print LIST2 exclude fields contains also in LIST1
# do_exclude_list print LIST2 list exclude fields contains also in LIST1
# Example: exclude "1 3" "1 2 3 4" -> "2 4"
exclude()
{
......@@ -96,6 +106,17 @@ reg_exclude()
strip_spaces "$RES"
}
# regexclude_list "22 1." "11 12 21 22" -> "21"
reg_wordexclude()
{
local i
local RES="$2"
for i in $1 ; do
RES=$(reg_wordremove "$i" "$RES")
done
strip_spaces "$RES"
}
# FIXME:
# reg_include "1." "11 12 21 22" -> "11 12"
reg_include()
......@@ -108,6 +129,14 @@ reg_include()
strip_spaces "$RES"
}
example()
{
local CMD="$1"
local ARG1="$2"
shift 2
echo "\$ $0 $CMD \"$ARG1\" \"$@\""
$0 $CMD "$ARG1" "$@"
}
help()
{
......@@ -117,24 +146,23 @@ help()
echo "strip_spaces [args] - remove spaces between words"
echo "filter_strip_spaces - remove spaces from words from standart input"
echo "reg_remove <PATTERN> [word list] - remove words containing a match to the given PATTERN (grep notation)"
echo "reg_wordremove <PATTERN> [word list] - remove words containing a match to the given PATTERN (grep -w notation)"
echo "exclude <list1> [list2] - print list2 words contains also in list1"
echo "reg_exclude <PATTERN> [word list] - print only words not matched with PATTERN"
echo "reg_wordexclude <PATTERN> [word list] - print only words not matched with PATTERN"
echo "union [word list] - sort and remove duplicates"
echo "uniq [word list] - alias for union"
echo "list [word list] - just list word by line"
echo "uniq [word list] - alias for union"
echo "list [word list] - just list words line by line"
echo "count [word list] - print word count"
echo
echo "Examples:"
echo "\$ $0 reg_remove \"1.\" \"11 12 21 22\""
$0 reg_remove "1." "11 12 21 22"
echo "\$ $0 exclude \"1 3\" \"1 2 3 4\""
$0 exclude "1 3" "1 2 3 4"
echo "\$ $0 reg_exclude \"22 1.\" \"11 12 21 22\""
$0 reg_exclude "22 1." "11 12 21 22"
echo "\$ $0 union \"1 2 2 3 3\""
$0 union "1 2 2 3 3"
echo "\$ $0 count \"1 2 3 4 10\""
$0 count "1 2 3 4 10"
example reg_remove "1." "11 12 21 22"
example reg_wordremove "1." "11 12 21 22"
example exclude "1 3" "1 2 3 4"
example reg_exclude "22 1." "11 12 21 22"
example reg_wordexclude "wo.* er" "work were more else"
example union "1 2 2 3 3"
example count "1 2 3 4 10"
}
COMMAND="$1"
......
......@@ -124,12 +124,12 @@ trans_rpmdeps_to_pkgname_lav()
local ALREADYHANDLEDRPM="rpmlib.* rtld libgcc_s\..* libstdc\+\+.* libc\.so.* ld-linux\.so.* libpthread\.so.* librt\.so.* libdl\.so.*"
local REQLIST="$@"
REQLIST=$(regexp_exclude_list "$ALREADYHANDLEDRPM" "$REQLIST")
REQLIST=$(estrlist reg_wordexclude "$ALREADYHANDLEDRPM" "$REQLIST")
# FIXME: strange regexp for drop libNAME.so.NUM and perl(Package) and /bin/sh
REALPKGNAMELIST=$(regexp_exclude_list "\. \.\. /* (*" "$REQLIST")
REALPKGNAMELIST=$(estrlist reg_exclude "\. /.* (.*" "$REQLIST")
# FIXME: external list? Set priorities/
REQCONVLIST=$(do_exclude_list "$REALPKGNAMELIST" "$REQLIST" | filter_multiple_provides)
REQCONVLIST=$(estrlist exclude "$REALPKGNAMELIST" "$REQLIST" | filter_multiple_provides)
# partially copied from aptU
#VIRTREQ=$(LANG=C apt-get install --print-uris $REQLIST 2>&1 | grep "is a virtual package provided by" | cut -f2 -d" " | sort -u)
......@@ -176,8 +176,8 @@ common-licenses
librpmbuild
passwdqc-control"
REQLIST=$(estrlist union $PKGFILES $REALPKGNAMELIST)
REQLIST=$(regexp_exclude_list "$ALREADYHANDLEDRPM" "$REQLIST" )
estrlist union $REQLIST
REQLIST=$(estrlist reg_wordexclude "$ALREADYHANDLEDRPM" "$REQLIST" )
estrlist union $REQLIST | estrlist list -
}
REQLIST=$(get_rpmpkg_requires $@) || fatal "can't get primary requires"
......
......@@ -38,7 +38,7 @@ do_exclude_list()
# regexp_exclude_list "22 1." "11 12 21 22" -> "21"
regexp_exclude_list()
{
estrlist reg_exclude "$@"
estrlist reg_wordexclude "$@"
}
estrlist()
......
......@@ -9,28 +9,38 @@ LIST3="field"
check()
{
[ "$2" != "$3" ] && echo "FATAL with '$1': result '$3' do not match with '$2'" || echo "OK for '$1' with '$2'"
local result="`$3 "$4" "$5"`"
[ "$2" != "$result" ] && echo "FATAL with '$1': result '$result' do not match with '$2' (command $3 \"$4\" \"$5\")" || echo "OK for '$1' with '$2' for '$3 \"$4\" \"$5\"'"
}
check 1 "field3 field4" "`do_exclude_list "$LIST1" "$LIST2"`"
check 2 "" "`do_exclude_list "$LIST2" "$LIST1"`"
check 3 "field" "`do_exclude_list "$LIST1" "$LIST3"`"
check 3 "field2 field4" "`do_exclude_list "field1 field3" "$LIST2"`"
check 1 "field3 field4" do_exclude_list "$LIST1" "$LIST2"
#check 1.1 "field3 field4" "estrlist wordexclude" "$LIST1" "$LIST2"
check 2 "" do_exclude_list "$LIST2" "$LIST1"
check 3 "field" do_exclude_list "$LIST1" "$LIST3"
#check 3.1 "field" "estrlist wordexclude" "$LIST1" "$LIST3"
check 4 "field2 field4" do_exclude_list "field1 field3" "$LIST2"
#check 4 "" "`do_exclude_list "field3 field[24]" "$LIST2"`"
check 5 "$LIST2" "`do_exclude_list "fiel" "$LIST2"`"
check 6 "$LIST2" "`do_exclude_list "" "$LIST2"`"
check "reg 1" "field1" "`regexp_exclude_list "field3 field[24]" "$LIST2"`"
check "reg 2" "$LIST2" "`regexp_exclude_list "fiel" "$LIST2"`"
check "reg 3" "field1 field3" "`regexp_exclude_list "field[24]" "$LIST2"`"
check "remove 1" "field1" "`remove_from_list "field2" "$LIST1"`"
check "remove 2" "" "`remove_from_list "field." "$LIST2"`"
check "remove 3" "list" "`remove_from_list "field." "$LIST2 list"`"
check "remove 3" "field2 field4" "`remove_from_list "field[13]" "$LIST2"`"
check "remove 4" "$LIST2" "`remove_from_list "fiel" "$LIST2"`"
check 5 "$LIST2" do_exclude_list "fiel" "$LIST2"
check 6 "$LIST2" do_exclude_list "" "$LIST2"
check "reg 1" "field1" regexp_exclude_list "field3 field[24]" "$LIST2"
check "reg 2" "$LIST2" "estrlist reg_wordexclude" "fiel" "$LIST2"
check "reg 3" "field1 field3" regexp_exclude_list "field[24]" "$LIST2"
check "remove 1" "field1" remove_from_list "field2" "$LIST1"
check "remove 2" "" remove_from_list "field." "$LIST2"
check "remove 3" "list" remove_from_list "field." "$LIST2 list"
check "remove 3" "field2 field4" remove_from_list "field[13]" "$LIST2"
check "remove 4" "$LIST2" remove_from_list "fiel" "$LIST2"
#check "remove 5" "field4" "`remove_from_list "field2 field[13]" "$LIST2"`"
check "remove 6" "$LIST2" "`remove_from_list "" "$LIST2"`"
check "remove 6" "$LIST2" remove_from_list "" "$LIST2"
check "strip1" "test" strip_spaces " test "
check "strip2" "test" strip_spaces "test "
check "strip3" "test" strip_spaces " test"
REQLIST='foomatic-db foomatic-db-engine nx fonts-bitmap-misc libasound.so.2 libcrypto.so.10 libX11.so.6 libXcomposite.so.1 libXdamage.so.1 libXfixes.so.3 libXmuu.so.1 libXpm.so.4 libXrandr.so.2 libXtst.so.6 libz.so.1 xkeyboard-config libdl.so.2 bc'
REALPKGNAMELIST="$(estrlist reg_exclude "\. \.\. /.* (.*" "$REQLIST")"
check "rpmreqs" "foomatic-db foomatic-db-engine nx fonts-bitmap-misc xkeyboard-config bc " echo "$REALPKGNAMELIST"
check "strip1" "test" "`strip_spaces " test "`"
check "strip2" "test" "`strip_spaces "test "`"
check "strip3" "test" "`strip_spaces " test"`"
#REQCONVLIST="$(do_exclude_list "$REALPKGNAMELIST" "$REQLIST")"
#check "convlist" "libasound.so.2 libcrypto.so.10 libX11.so.6 libXcomposite.so.1 libXdamage.so.1 libXfixes.so.3 libXmuu.so.1 libXpm.so.4 libXrandr.so.2 libXtst.so.6 libz.so.1 libdl.so.2" "$REQCONVLIST"
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