1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/sh
# 2012 (c) Etersoft www.etersoft.ru
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain
#
VERBOSE=
# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
load_mod spec rpm
if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
echo "rpmreqs [package(s) file(s)] - print out package requires"
exit 0
fi
# moved from aptU
get_rpm_package_requires()
{
rpmquery --requires $@ | cut -f1 -d" " | sed -e "s|\(^lib.*\)(.*[0-9])|\1|g" | grep -v "^rpmlib" | sort -u
}
filter_pkgname()
{
sed -e "s/^i586-//g
s/.*(64bit)$//g
s/\.32bit$//g"
}
filter_multiple_provides()
{
sed -e "s|/usr/bin/lpstat|cups|g
s|libldap_r-2.4.so.2|libldap|g
s|liblber-2.4.so.2|libldap|g
s|libudev.so.1|libudev1|g
s|/usr/bin/wine||g
s|/usr/bin/jconsole|java-1.7.0-openjdk-devel|g
s|/sbin/modprobe||g
s|gcc-c++|gcc5-c++|g
s|libwine.so.1||g"
}
convert_pkgfile_to_pkgname()
{
for ni in $@ ; do
# drop internal reqs (already converted via apt)
#echo $ni | grep -q "/" && continue
#echo $ni | grep -q "\.so" && continue
#echo $ni | grep -q ")" && continue
# extra words when run on x86_64
ni=$(querypackage $ni NAME)
echo $ni | filter_pkgname
done | sort -u
}
# Translate requires from local rpm package to package names (on local ALT Linux Sisyphus)
# FIXME: do not support x86_64 issues, use only with 32 bit packages
# Use test from tests/test_cget_depends.sh
trans_rpmdeps_to_pkgname_ldv()
{
# partially copied from aptU
local ALREADYHANDLEDRPM="rpmlib.* rtld libgcc_s\..* libstdc\+\+.* libc\.so.* ld-linux\.so.* libpthread\.so.* librt\.so.*"
local REQLIST="$@"
REQLIST=$(regexp_exclude_list "$ALREADYHANDLEDRPM" "$REQLIST")
REALPKGNAMELIST=$(regexp_exclude_list ". /*" "$REQLIST")
REQCONVLIST=$(do_exclude_list "$REALPKGNAMELIST" "$REQLIST")
set_hasherdir
HASHERDIR=$HASHERDIR-pkgreqs
mkdir -p $HASHERDIR
PKGFILES=$(mkaptbox -f $HASHERDIR && $HASHERDIR/aptbox/apt-get install -qqqy -oRPM::PM=external -oDir::Bin::rpm=hsh-rpmi-print-files $REQCONVLIST)
# 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)
# FIXME: f.i., we got /usr/bin/lpstat in VIRTREQ (select cups or lprng package?). Skip now
#REQLIST=$(regexp_exclude_list "VIRTREQ" "$REQLIST")
#TRREALREQ=$(LANG=C apt-get install --print-uris $REQLIST 2>&1 | grep "^Selecting" | cut -f2 -d" " | sort -u)
# remove basesystem packages
ALREADYHANDLEDRPM="
bash sh filesystem alt-gpgkeys glibc-core glibc-locales glibc-preinstall
tcb-utils nss_tcb libtcb chkconfig service setup
shadow-utils shadow-convert module-init-tools kmod util-linux-control pam
alternatives
automake-common
glib2-locales
rpm-macros-alternatives
emacs-base
pam0-config
pam0_mktemp
pam0_passwdqc
pam0_tcb
pam0_userpass
pam-config
pam-config-control
sysvinit-utils
libpam0
control
libbeecrypt7
libX11-locales
glib2-locales
libtic
libpasswdqc
librpm
libshell
ca-certificates
common-licenses
librpmbuild
passwdqc-control"
REQLIST=$(estrlist union $(convert_pkgfile_to_pkgname $PKGFILES) $REALPKGNAMELIST)
REQLIST=$(regexp_exclude_list "$ALREADYHANDLEDRPM" "$REQLIST" )
estrlist union $REQLIST
}
# Translate requires from local rpm package to package names (on local ALT Linux Sisyphus)
# FIXME: do not support x86_64 issues, use only with 32 bit packages
# Use test from tests/test_cget_depends.sh
# TODO: use hasher (see func before)
# TODO: do not run apt-get install directly
trans_rpmdeps_to_pkgname_lav()
{
# partially copied from aptU
local ALREADYHANDLEDRPM="rpmlib.* rtld libgcc_s\..* libstdc\+\+.* libc\.so.* libm\.so.* ld-linux\.so.* ld-linux-x86-64\.so.* libpthread\.so.* librt\.so.* libdl\.so.*"
local REQLIST="$@"
REQLIST=$(estrlist reg_wordexclude "$ALREADYHANDLEDRPM" "$REQLIST")
# FIXME: strange regexp for drop libNAME.so.NUM and perl(Package) and /bin/sh
REALPKGNAMELIST=$(estrlist reg_exclude "\.so\. /.* (.*" "$REQLIST")
# FIXME: external list? Set priorities/
REQCONVLIST=$(estrlist exclude "$REALPKGNAMELIST" "$REQLIST" | filter_multiple_provides | sed -e "s|(64bit)|.*(64bit)|g")
# 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)
#FIXME: f.i., we got /usr/bin/lpstat in VIRTREQ (select cups or lprng package?). Skip now
#REQLIST=$(regexp_exclude_list "VIRTREQ" "$REQLIST")
# TODO: we have store_output function
TFILE=$(make_temp_file)
PKGFILES=
if [ -n "$REQCONVLIST" ] ; then
PKGFILES=$(LANG=C apt-get install --print-uris $REQCONVLIST 2>$TFILE | egrep "(^Selecting|.* is already the newest version.)" | sed -e "s|^Selecting ||g" | sed -e "s| is already the newest version.||g" | sed -e "s| .*||g" | sort -u | filter_pkgname) || warning "Error return code from apt-get install"
if grep -q "is a virtual package provided by" $TFILE ; then
local INSTALLMARK="\[Installed\]"
if ! grep -q "$INSTALLMARK" $TFILE ; then
fatal "multiple provides: $(cat $TFILE)"
fi
PKGINSTALLED="$(grep "$INSTALLMARK" $TFILE | estrlist filter_strip_spaces | sed -e "s| .*||g")"
if [ -z "$PKGINSTALLED" ] ; then
fatal "can't resolve multiple provides: $(cat $TFILE)"
fi
PKGFILES="$PKGFILES $PKGINSTALLED"
fi
fi
if grep -q "Couldn't find package" $TFILE ; then
fatal "$(cat $TFILE | grep "Couldn't find package")"
fi
#grep -q "^E:" $TFILE && fatal "Can't get correct result from apt: $(cat $TFILE)"
rm -f $TFILE
# remove ALT basesystem packages
ALREADYHANDLEDRPM="
bash sh filesystem alt-gpgkeys glibc-core glibc-locales glibc-preinstall
rpm apt apt-repo
tcb-utils nss_tcb libtcb chkconfig service setup
shadow-utils shadow-convert module-init-tools kmod util-linux-control pam
alternatives
automake-common
glib2-locales
altlinux-release
rpm-macros-alternatives
emacs-base
pam0-config
pam0_mktemp
pam0_passwdqc
pam0_tcb
pam0_userpass
pam-config
pam-config-control
sysvinit-utils
libpam0
control
libbeecrypt7
libX11-locales
gcc-c++
glib2-locales
libtic
libpasswdqc
librpm
libshell
ca-certificates
common-licenses
librpmbuild
passwdqc-control"
REQLIST=$(estrlist union $PKGFILES $REALPKGNAMELIST)
REQLIST=$(estrlist reg_wordexclude "$ALREADYHANDLEDRPM" "$REQLIST" )
estrlist union $REQLIST | estrlist list -
}
REQLIST=$(get_rpm_package_requires $@) || fatal "can't get primary requires"
trans_rpmdeps_to_pkgname_lav $REQLIST