]>
Commit | Line | Data |
---|---|---|
0b3acdf9 | 1 | #!/bin/sh |
0b3acdf9 JB |
2 | |
3 | # _noauto* wrapper for builtin rpm Requires generator | |
4 | # requires: /bin/sh, /usr/bin/rpmdeps, rpm, coreutils, findutils. mktemp | |
5 | # input (stdin): filenames (one per line) | |
6 | # output (stdout): Requires list (one per line) | |
7 | ||
8 | # note that no large list is stored in shell variable - this was VERY slow | |
9 | ||
10 | ulimit -c 0 | |
11 | ||
1cee2a54 JB |
12 | PERLOPT="--define=__perl_requires /bin/sh -c 'cat >/dev/null'" |
13 | PHPOPT="--define=__php_requires /bin/sh -c 'cat >/dev/null'" | |
0ad25a07 JB |
14 | PROVARG="" |
15 | NOPROVFILES="" | |
16 | NOPROV="" | |
0b3acdf9 | 17 | noreqfiles='' |
0ad25a07 JB |
18 | noreq='' |
19 | noreqdep='' | |
20 | while [ $# -gt 0 ]; do | |
21 | case "$1" in | |
22 | --with-perl) | |
23 | PERLOPT="" | |
24 | PROVARG="$PROVARG --with-perl" | |
25 | ;; | |
26 | --with-php) | |
27 | PHPOPT="" | |
28 | PROVARG="$PROVARG --with-php" | |
29 | ;; | |
30 | --buildroot=*) | |
31 | buildroot="${1#--buildroot=}" | |
32 | PROVARG="$PROVARG $1" | |
33 | ;; | |
34 | --noautoprovfiles=*) | |
35 | NOPROVFILES="$1" | |
36 | ;; | |
37 | --noautoprov=*) | |
38 | NOPROV="$1" | |
39 | ;; | |
40 | --noautoreqfiles=*) | |
41 | for i in ${1#--noautoreqfiles=} ; do | |
42 | noreqfiles="${noreqfiles}\|${buildroot}${i}" | |
43 | done | |
44 | ;; | |
45 | --noautoreq=*) | |
46 | for i in ${1#--noautoreq=} ; do | |
47 | noreq="${noreq}\|${i}" | |
48 | done | |
49 | ;; | |
50 | --noautoreqdep=*) | |
51 | for i in ${1#--noautoreqdep=} ; do | |
52 | noreqdep="${noreqdep}\|${i}" | |
53 | done | |
54 | esac | |
55 | shift | |
56 | done | |
57 | ||
0b3acdf9 JB |
58 | if [ -r /etc/rpm/noautoreqfiles ]; then |
59 | for i in `cat /etc/rpm/noautoreqfiles | grep -v '^#'`; do | |
0ad25a07 | 60 | noreqfiles="${noreqfiles}\|${buildroot}${i}" |
0b3acdf9 JB |
61 | done |
62 | fi | |
63 | ||
0b3acdf9 JB |
64 | if [ -r /etc/rpm/noautoreq ]; then |
65 | for i in `cat /etc/rpm/noautoreq | grep -v '^#'`; do | |
66 | noreq="${noreq}\|${i}" | |
67 | done | |
68 | fi | |
69 | ||
0b3acdf9 JB |
70 | if [ -r /etc/rpm/noautoreqdep ]; then |
71 | for i in `cat /etc/rpm/noautoreqdep | grep -v '^#'`; do | |
72 | noreqdep="${noreqdep}\|${i}" | |
73 | done | |
74 | fi | |
75 | ||
76 | FILES=`mktemp ${TMPDIR:-/tmp}/.rpmfilesXXXXXX` | |
77 | PROVS=`mktemp ${TMPDIR:-/tmp}/.rpmprovsXXXXXX` | |
78 | REQS=`mktemp ${TMPDIR:-/tmp}/.rpmreqsXXXXXX` | |
79 | ||
80 | # we must duplicate file list here (to remove Provides list from Requires) | |
0ad25a07 JB |
81 | tee ${FILES} | \ |
82 | /usr/lib/rpm/find-provides-wrapper ${PROVARG} "${NOPROVFILES}" "${NOPROV}" \ | |
83 | > ${PROVS} | |
0b3acdf9 JB |
84 | |
85 | # rpmdeps output seems sorted, but resort it in case of long list split | |
86 | grep -v -e "^\(${noreqfiles}\)\$" ${FILES} | tr '\n' '\0' | \ | |
0ad25a07 JB |
87 | xargs -r -0 /usr/bin/rpmdeps "${PERLOPT}" "${PHPOPT}" --requires | \ |
88 | LC_ALL=C sort -u | grep -v -e "^\(${noreq}\)\$" | \ | |
0b3acdf9 JB |
89 | LC_ALL=C comm -2 -3 - ${PROVS} | tee ${REQS} |
90 | ||
91 | # package names only for SONAMES, perl(module) and pear(module) | |
92 | grep -e '.\+\.so\|perl(.\+)\|pear(.\+)' ${REQS} | \ | |
93 | grep -v -e "^\(${noreqdep}\)\$" | tr '\n' '\0' | \ | |
94 | LC_ALL=C xargs -r -0 -- rpm -q --whatprovides --qf '%{NAME}\n' 2>/dev/null | \ | |
95 | grep -v "no package provides" | LC_ALL=C sort -u | |
96 | ||
97 | rm -f ${FILES} ${PROVS} ${REQS} | |
98 | ||
99 | exit 0 |