Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-build-utils
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
korinf
etersoft-build-utils
Commits
004aec4d
Commit
004aec4d
authored
Oct 10, 2020
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use external estrlist
parent
c8e702bd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2 additions
and
271 deletions
+2
-271
estrlist
bin/estrlist
+0
-223
rpmgs
bin/rpmgs
+1
-1
etersoft-build-utils.spec
etersoft-build-utils.spec
+1
-0
test_list_exclude.sh
tests/test_list_exclude.sh
+0
-47
No files found.
bin/estrlist
deleted
100755 → 0
View file @
c8e702bd
#!/bin/bash
# 2009-2010, 2012, 2017 Etersoft www.etersoft.ru
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain
# TODO: rewrite with shell commands, perl or C
# Python - http://www.linuxtopia.org/online_books/programming_books/python_programming/python_ch16s03.html
# Shell - http://linux.byexamples.com/archives/127/uniq-and-basic-set-theory/
# - http://maiaco.com/articles/shellSetOperations.php
# Perl - http://docstore.mik.ua/orelly/perl/cookbook/ch04_09.htm
# - http://blogs.perl.org/users/polettix/2012/03/sets-operations.html
# http://rosettacode.org/wiki/Symmetric_difference
# TODO: add unit tests
# http://ru.wikipedia.org/wiki/Операции_над_множествами
# Base set operations:
# * union
# "1 2 3" "3 4 5" -> "1 2 3 4 5"
# * intersection
# "1 2 3" "3 4 5" -> "3"
# * relative complement (substracted, difference) ( A ? B – members in A but not in B )
# http://en.wikipedia.org/wiki/Complement_%28set_theory%29
# "1 3" "1 2 3 4" -> "2 4"
# * symmetric difference (симметричная разность) ( A ^ B – members in A or B but not both )
# http://en.wikipedia.org/wiki/Symmetric_difference
# "1 2 3" "3 4 5" -> "1 2 4 5"
filter_strip_spaces
()
{
# possible use just
#xargs echo
sed
-e
"s|
\+
| |g"
-e
"s|^ ||"
-e
"s|
\$
||"
}
strip_spaces
()
{
echo
"
$*
"
| filter_strip_spaces
}
isempty
()
{
[
"
$(
strip_spaces
"
$*
"
)
"
=
""
]
}
list
()
{
local
i
for
i
in
$@
;
do
echo
"
$i
"
done
}
count
()
{
list
$@
|
wc
-l
}
union
()
{
strip_spaces
$(
list
$@
|
sort
-u
)
}
uniq
()
{
union
$@
}
has
()
{
local
wd
=
"
$1
"
shift
echo
"
$*
"
|
grep
-q
--
"
$wd
"
}
# Note: used egrep! write '[0-9]+(first|two)', not '[0-9]\+...'
match
()
{
local
wd
=
"
$1
"
shift
echo
"
$*
"
| egrep
-q
--
"
$wd
"
}
# remove_from_list "1." "11 12 21 22" -> "21 22"
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 list exclude fields contains also in LIST1
# Example: exclude "1 3" "1 2 3 4" -> "2 4"
exclude
()
{
local
i
local
RES
=
for
i
in
$2
;
do
echo
"
$1
"
|
grep
-q
-w
"
$i
"
||
RES
=
"
$RES
$i
"
done
strip_spaces
"
$RES
"
}
# regexclude_list "22 1." "11 12 21 22" -> "21"
reg_exclude
()
{
local
i
local
RES
=
"
$2
"
for
i
in
$1
;
do
RES
=
$(
reg_remove
"
$i
"
"
$RES
"
)
done
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
()
{
local
i
local
RES
=
for
i
in
$2
;
do
echo
"
$i
"
|
grep
-q
-w
"
$1
"
&&
RES
=
"
$RES
$i
"
done
strip_spaces
"
$RES
"
}
example
()
{
local
CMD
=
"
$1
"
local
ARG1
=
"
$2
"
shift
2
echo
"
\$
$0
$CMD
\"
$ARG1
\"
\"
$@
\"
"
$0
$CMD
"
$ARG1
"
"
$@
"
}
example_res
()
{
example
"
$@
"
&&
echo
TRUE
||
echo
FALSE
}
help
()
{
echo
"estrlist developed for string list operations. See also cut, join, paste..."
echo
"Usage:
$0
<command> [args]"
echo
"Commands:"
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 exclude list1 items"
echo
" reg_exclude <PATTERN> [word list] - print only words do not matched with PATTERN"
echo
" reg_wordexclude <PATTERN> [word list] - print only words do not matched with PATTERN"
echo
" has <PATTERN> string - check the string for a match to the regular expression given in PATTERN (grep notation)"
echo
" match <PATTERN> string - check the string for a match to the regular expression given in PATTERN (egrep notation)"
echo
" isempty [string] - true if string has no any symbols (only zero or more spaces)"
echo
" union [word list] - sort and remove duplicates"
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:"
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"
example_res isempty
" "
#example_res isempty " 1 "
example_res has ex
"exactly"
example_res has exo
"exactly"
example_res match
"M[0-9]+"
"M250"
example_res match
"M[0-9]+"
"MI"
}
COMMAND
=
"
$1
"
if
[
-z
"
$COMMAND
"
]
;
then
echo
"Run with --help for get command description."
exit
1
fi
if
[
"
$COMMAND
"
=
"-h"
]
||
[
"
$COMMAND
"
=
"--help"
]
;
then
COMMAND
=
"help"
fi
shift
# FIXME: do to call function directly, use case instead?
if
[
"
$1
"
=
"-"
]
;
then
shift
"
$COMMAND
"
"
$(
cat
)
$@
"
elif
[
"
$2
"
=
"-"
]
;
then
"
$COMMAND
"
"
$1
"
"
$(
cat
)
"
else
"
$COMMAND
"
"
$@
"
fi
bin/rpmgs
View file @
004aec4d
...
...
@@ -388,7 +388,7 @@ update_predownloaded()
[
"
$MODE
"
=
"production"
]
&&
PRODUCTION
=
'--production'
info
"Detected npm install hook, running npm install
$PRODUCTION
..."
a
=
npm
install
--verbose
--ignore-scripts
$PRODUCTION
||
fatal
a
=
npm
install
--verbose
--
no-optional
--
ignore-scripts
$PRODUCTION
||
fatal
COMMITMSG
=
"update node_modules with npm install
$PRODUCTION
for
$VERSION
(see
$SDNAME
in .gear/rules)"
if
[
-s
$RGD
/.gear/predownloaded-postinstall-hook
]
;
then
...
...
etersoft-build-utils.spec
View file @
004aec4d
...
...
@@ -25,6 +25,7 @@ BuildArchitectures: noarch
Requires: giter >= 1.10
Requires: eepm >= 2.1.0
Requires: erc >= 0.9.2
Requires: estrlist >= 0.1
Requires: rpm-build
#Requires: rpm-build-compat >= %altcompat_ver
...
...
tests/test_list_exclude.sh
deleted
100755 → 0
View file @
c8e702bd
#!/bin/sh
.
`
dirname
$0
`
/../share/eterbuild/functions/common
load_mod strings
LIST1
=
"field1 field2"
LIST2
=
"field1 field2 field3 field4"
LIST3
=
"field"
check
()
{
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 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
"
"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
"strip1"
"test"
strip_spaces
" test "
check
"strip2"
"test"
strip_spaces
"test "
check
"strip3"
"test"
strip_spaces
" test"
check
"strip4"
"test test"
strip_spaces
" test 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
"
#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"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment