Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
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
Nurlan
eepm
Commits
27ad1b7d
Commit
27ad1b7d
authored
Aug 23, 2016
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite query and packages
parent
e0f6e354
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
22 deletions
+45
-22
epm-packages
bin/epm-packages
+36
-18
epm-query
bin/epm-query
+9
-4
No files found.
bin/epm-packages
View file @
27ad1b7d
...
@@ -41,6 +41,11 @@ __aptcyg_print_full()
...
@@ -41,6 +41,11 @@ __aptcyg_print_full()
echo
"
$1
-
$VERSION
"
echo
"
$1
-
$VERSION
"
}
}
__fo_pfn
()
{
grep
-v
"^$"
|
grep
--
"
$pkg_filenames
"
}
# TODO: we have a problem with error status here
# TODO: we have a problem with error status here
epm_packages
()
epm_packages
()
{
{
...
@@ -49,23 +54,28 @@ epm_packages()
...
@@ -49,23 +54,28 @@ epm_packages()
case
$PMTYPE
in
case
$PMTYPE
in
apt-rpm
)
apt-rpm
)
# FIXME: strong equal
CMD
=
"rpm -qa
$pkg_filenames
"
CMD
=
"rpm -qa
$pkg_filenames
"
[
-n
"
$short
"
]
&&
CMD
=
"rpm -qa --queryformat %{name}
\n
$pkg_filenames
"
[
-n
"
$short
"
]
&&
CMD
=
"rpm -qa --queryformat %{name}
\n
$pkg_filenames
"
;;
docmd
$CMD
return
;;
*
-dpkg
)
*
-dpkg
)
# FIXME: strong equal
#CMD="dpkg -l $pkg_filenames"
#CMD="dpkg -l $pkg_filenames"
CMD
=
"dpkg-query -W --showformat=
\$
{db:Status-Abbrev}
\$
{Package}-
\$
{Version}
\n
$pkg_filenames
"
CMD
=
"dpkg-query -W --showformat=
\$
{db:Status-Abbrev}
\$
{Package}-
\$
{Version}
\n
$pkg_filenames
"
[
-n
"
$short
"
]
&&
CMD
=
"dpkg-query -W --showformat=
\$
{db:Status-Abbrev}
\$
{Package}
\n
$pkg_filenames
"
[
-n
"
$short
"
]
&&
CMD
=
"dpkg-query -W --showformat=
\$
{db:Status-Abbrev}
\$
{Package}
\n
$pkg_filenames
"
docmd
$CMD
|
grep
"^i"
|
sed
-e
"s|.* ||g"
showcmd
$CMD
retur
n
$CMD
|
grep
"^i"
|
sed
-e
"s|.* ||g"
| __fo_pf
n
;;
return
;;
snappy
)
snappy
)
CMD
=
"snappy info"
CMD
=
"snappy info"
;;
;;
yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm
)
yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm
)
# FIXME: strong equal
CMD
=
"rpm -qa
$pkg_filenames
"
CMD
=
"rpm -qa
$pkg_filenames
"
[
-n
"
$short
"
]
&&
CMD
=
"rpm -qa --queryformat %{name}
\n
$pkg_filenames
"
[
-n
"
$short
"
]
&&
CMD
=
"rpm -qa --queryformat %{name}
\n
$pkg_filenames
"
;;
docmd
$CMD
return
;;
emerge
)
emerge
)
CMD
=
"qlist -I -C"
CMD
=
"qlist -I -C"
# print with colors for console output
# print with colors for console output
...
@@ -73,26 +83,27 @@ case $PMTYPE in
...
@@ -73,26 +83,27 @@ case $PMTYPE in
;;
;;
pkgsrc
)
pkgsrc
)
CMD
=
"pkg_info"
CMD
=
"pkg_info"
docmd
$CMD
|
sed
-e
"s| .*||g"
showcmd
$CMD
retur
n
$CMD
|
sed
-e
"s| .*||g"
| __fo_pf
n
;;
return
;;
pkgng
)
pkgng
)
if
[
-n
"
$pkg_filenames
"
]
;
then
if
[
-n
"
$pkg_filenames
"
]
;
then
CMD
=
"pkg info -E
$pkg_filenames
"
CMD
=
"pkg info -E
$pkg_filenames
"
else
else
CMD
=
"pkg info"
CMD
=
"pkg info"
fi
fi
showcmd
$CMD
if
[
-n
"
$short
"
]
;
then
if
[
-n
"
$short
"
]
;
then
docmd
$CMD
|
sed
-e
"s| .*||g"
|
sed
-e
"s|-[0-9].*||g"
$CMD
|
sed
-e
"s| .*||g"
|
sed
-e
"s|-[0-9].*||g"
| __fo_pfn
else
else
docmd
$CMD
|
sed
-e
"s| .*||g"
$CMD
|
sed
-e
"s| .*||g"
| __fo_pfn
fi
fi
return
return
;;
;;
pacman
)
pacman
)
CMD
=
"pacman -Qs
$pkg_filenames
"
CMD
=
"pacman -Qs
$pkg_filenames
"
showcmd
$CMD
if
[
-n
"
$short
"
]
;
then
if
[
-n
"
$short
"
]
;
then
docmd
$CMD
|
sed
-e
"s| .*||g"
-e
"s|.*/||g"
|
grep
-v
"^$"
$CMD
|
sed
-e
"s| .*||g"
-e
"s|.*/||g"
| __fo_pfn
return
return
fi
fi
;;
;;
...
@@ -112,7 +123,7 @@ case $PMTYPE in
...
@@ -112,7 +123,7 @@ case $PMTYPE in
# FIXME: does not work for libjpeg-v8a
# FIXME: does not work for libjpeg-v8a
# TODO: remove last 3 elements (if arch is second from the last?)
# TODO: remove last 3 elements (if arch is second from the last?)
# FIXME this hack
# FIXME this hack
docmd
ls
-1
/var/log/packages/ |
sed
-e
"s|-[0-9].*||g"
|
sed
-e
"s|libjpeg-v8a.*|libjpeg|g"
docmd
ls
-1
/var/log/packages/ |
sed
-e
"s|-[0-9].*||g"
|
sed
-e
"s|libjpeg-v8a.*|libjpeg|g"
| __fo_pfn
return
return
fi
fi
;;
;;
...
@@ -133,10 +144,18 @@ case $PMTYPE in
...
@@ -133,10 +144,18 @@ case $PMTYPE in
;;
;;
xbps
)
xbps
)
CMD
=
"xbps-query -l"
CMD
=
"xbps-query -l"
showcmd
$CMD
if
[
-n
"
$short
"
]
;
then
$CMD
|
sed
-e
"s|^ii ||g"
-e
"s| .*||g"
-e
"s|
\(
.*
\)
-.*|
\1
|g"
| __fo_pfn
else
$CMD
|
sed
-e
"s|^ii ||g"
-e
"s| .*||g"
| __fo_pfn
fi
return
0
;;
;;
android
)
android
)
CMD
=
"pm list packages"
CMD
=
"pm list packages"
docmd
$CMD
|
sed
-e
"s|^package:||g"
showcmd
$CMD
$CMD
|
sed
-e
"s|^package:||g"
| __fo_pfn
return
return
;;
;;
aptcyg
)
aptcyg
)
...
@@ -155,8 +174,7 @@ case $PMTYPE in
...
@@ -155,8 +174,7 @@ case $PMTYPE in
;;
;;
esac
esac
docmd
$CMD
docmd
$CMD
| __fopfn
# FIXME: do not print empty lines, but we will lost error status definitely
# FIXME: we print empty lines, but will lost error status
# | grep -v "^$"
}
}
bin/epm-query
View file @
27ad1b7d
...
@@ -33,16 +33,18 @@ _get_grep_exp()
...
@@ -33,16 +33,18 @@ _get_grep_exp()
# TODO: combine with -qa (the difference only in return status now)
# TODO: combine with -qa (the difference only in return status now)
_shortquery_via_packages_list
()
_shortquery_via_packages_list
()
{
{
local
res
=
0
local
res
=
1
local
grepexp
local
grepexp
local
firstpkg
=
$1
local
firstpkg
=
$1
shift
shift
grepexp
=
$(
_get_grep_exp
$firstpkg
)
grepexp
=
$(
_get_grep_exp
$firstpkg
)
# TODO: we miss status due grep
# Note: double call due stderr redirect
# Note: we use short=1 here due grep by ^name$
# Note: we use short=1 here due grep by ^name$
# separate first line for print out command
# separate first line for print out command
short
=
1
pkg_filenames
=
$firstpkg
epm_packages |
grep
--
"
$grepexp
"
||
res
=
1
short
=
1
pkg_filenames
=
$firstpkg
epm_packages |
grep
--
"
$grepexp
"
&&
res
=
0
||
res
=
1
local
pkg
local
pkg
for
pkg
in
"
$@
"
;
do
for
pkg
in
"
$@
"
;
do
...
@@ -57,16 +59,19 @@ _shortquery_via_packages_list()
...
@@ -57,16 +59,19 @@ _shortquery_via_packages_list()
# TODO: non optimal double epm packages call
# TODO: non optimal double epm packages call
_query_via_packages_list
()
_query_via_packages_list
()
{
{
local
res
=
0
local
res
=
1
local
grepexp
local
grepexp
local
firstpkg
=
$1
local
firstpkg
=
$1
shift
shift
grepexp
=
$(
_get_grep_exp
$firstpkg
)
grepexp
=
$(
_get_grep_exp
$firstpkg
)
# TODO: we miss status due grep
# TODO: grep correctly
# Note: double call due stderr redirect
# Note: we use short=1 here due grep by ^name$
# Note: we use short=1 here due grep by ^name$
# separate first line for print out command
# separate first line for print out command
short
=
1
pkg_filenames
=
$firstpkg
epm_packages |
grep
-q
--
"
$grepexp
"
&&
quiet
=
1
pkg_filenames
=
$firstpkg
epm_packages
||
res
=
1
short
=
1
pkg_filenames
=
$firstpkg
epm_packages |
grep
-q
--
"
$grepexp
"
&&
quiet
=
1
pkg_filenames
=
$firstpkg
epm_packages
&&
res
=
0
||
res
=
1
local
pkg
local
pkg
for
pkg
in
"
$@
"
;
do
for
pkg
in
"
$@
"
;
do
...
...
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