3
# Copyright (C) 2012-2013, 2016, 2018, 2019, 2022 Etersoft
4
# Copyright (C) 2012-2013, 2016, 2018, 2019, 2022 Vitaly Lipatov <lav@etersoft.ru>
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
23
__epm_filter_out_base_alt_reqs()
25
grep -E -v "(^rpmlib\(|^/bin/sh|^/bin/bash|^rtld\(GNU_HASH\)|ld-linux)"
28
__epm_alt_rpm_requires()
30
if [ -n "$short" ] ; then
31
# TODO see also rpmreqs from etersoft-build-utils
32
docmd rpm -q --requires "$@" | __epm_filter_out_base_alt_reqs | sed -e "s| .*||"
34
docmd rpm -q --requires "$@" | __epm_filter_out_base_alt_reqs
38
get_linked_shared_libs()
40
assure_exists readelf binutils
41
#is_command readelf || fatal "Can't get required shared library: readelf is missed. Try install binutils package."
42
#ldd "$exe" | sed -e 's|[[:space:]]*||' | grep "^lib.*[[:space:]]=>[[:space:]]\(/usr/lib\|/lib\)" | sed -e 's|[[:space:]].*||'
43
LC_ALL=C readelf -d "$1" | grep "(NEEDED)" | grep "Shared library:" | sed -e 's|.*Shared library: \[||' -e 's|\]$||' | grep "^lib"
48
get_linked_shared_libs "$1"
53
get_linked_shared_libs "$1" | sed -e 's|$|()(64bit)|'
59
if [ -n "$direct" ] ; then
61
get_linked_shared_libs $i
67
if file "$i" | grep -q " ELF 32-bit " ; then
68
__epm_elf32_requires "$i"
69
elif file "$i" | grep -q " ELF 64-bit " ; then
70
__epm_elf64_requires "$i"
72
warning "Unknown ELF binary"
80
[ -n "$pkg_files" ] || return
82
# TODO: handle separately
83
local PKGTYPE="$(get_package_type $pkg_files)"
87
assure_exists rpm >/dev/null
88
__epm_alt_rpm_requires -p $pkg_files
91
assure_exists dpkg >/dev/null
92
a='' docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
95
showcmd eopkg info $pkg_files
96
LC_ALL=C eopkg info $pkg_files | grep "^Dependencies" | head -n1 | sed -e "s|Dependencies[[:space:]]*: ||"
99
__epm_elf_requires $pkg_files
102
fatal "Have no suitable command for $PKGTYPE"
111
[ -n "$pkg_names" ] || return
116
# FIXME: need fix for a few names case
117
# FIXME: too low level of requires name (libSOME.so)
118
if is_installed $pkg_names ; then
119
assure_exists rpm >/dev/null
120
__epm_alt_rpm_requires $pkg_names
123
if [ -n "$verbose" ] ; then
124
CMD="apt-cache depends"
126
if [ -n "$short" ] ; then
127
LC_ALL=C docmd apt-cache depends $pkg_names | grep "Depends:" | sed -e 's|, |\n|g' -e "s|.*Depends: ||" -e "s|<\(.*\)>|\1|" | __epm_filter_out_base_alt_reqs | sed -e "s| .*||"
129
LC_ALL=C docmd apt-cache depends $pkg_names | grep "Depends:" | sed -e 's|, |\n|g' -e "s|.*Depends: ||" -e "s|<\(.*\)>|\1|" | __epm_filter_out_base_alt_reqs
136
CMD="pkcon required-by"
139
# # FIXME: use hi level commands
140
# CMD="rpm -q --requires"
143
CMD="urpmq --requires"
146
if is_installed $pkg_names ; then
147
CMD="rpm -q --requires"
153
if is_installed $pkg_names ; then
154
CMD="rpm -q --requires"
156
CMD="dnf repoquery --requires"
162
apt-dpkg|aptitude-dpkg)
163
# FIXME: need fix for a few names case
164
if is_installed $pkg_names ; then
165
showcmd dpkg -s $pkg_names
166
a='' dpkg -s $pkg_names | grep "^Depends:" | sed "s|^Depends:||g"
169
CMD="apt-cache depends"
174
CMD="equery depgraph"
177
#docmd brew info $pkg_names | grep "^Required: " | sed -s "|s|^Requires: ||"
178
docmd brew deps $pkg_names
182
#CMD="pkg rquery '%dn-%dv'"
189
showcmd eopkg info $pkg_names
190
LC_ALL=C eopkg info $pkg_names | grep "^Dependencies" | sed -e "s|Dependencies[[:space:]]*: ||"
197
#CMD="apt-cyg depends"
199
docmd apt-cyg show $pkg_names | grep "^requires: " | sed "s|^requires: ||g"
203
fatal "Have no suitable command for $PMTYPE"
214
# if possible, it will put pkg_urls into pkg_files or pkg_names
215
if [ -n "$pkg_urls" ] ; then
216
load_helper epm-download
217
__handle_pkg_urls_to_checking
220
[ -n "$pkg_filenames" ] || fatal "Requires: package name is missed"
222
epm_requires_files $pkg_files
223
# shellcheck disable=SC2046
224
epm_requires_names $(print_name $pkg_names)