Preparing for 4.11.1 final
[platform/upstream/rpm.git] / autodeps / aix.prov
1 #! /usr/bin/ksh
2
3 # Original Author: Ralph Goers(rgoer@Candle.Com)
4 # Borrowed heavily from Tim Mooney's HP version.
5 # This file is distributed under the terms of the GNU General Public License
6 #
7 # find-requires is part of RPM, the RedHat Package Manager.  find-requires
8 # reads a list of full pathnames (in a package) on stdin, and outputs all
9 # shared libraries the package requires to run correctly.
10 #
11
12 find_prov_ia64()
13 {
14    # On AIX for IA64, use the file command to find shared modules
15    #
16    # Example file output:
17    #
18    #$file /usr/lib/ia64l32/libc.so
19    #/usr/lib/ia64l32/libc.so:     ELF 32-bit LSB version 1 AIX shared obj IA-64
20    # 
21    #
22    #
23    
24    # Search for shared objects - the file command on AIX for IA64 reports 
25    # shared objects
26    sed -e "s/['\"]/\\\&/g" -e "s/$/\//g" | LANG=C xargs file | grep -e ":.*shared obj" | cut -d: -f1 | sed "s/\/$//g" | xargs -i basename {} | sort -u
27 }
28
29 find_prov_power()
30 {
31    #
32    # Example dump output:
33    #
34    #$dump -H /usr/bin/dump
35    #
36    #/usr/bin/dump:
37    #
38    #                        ***Loader Section***
39    #                      Loader Header Information
40    #VERSION#         #SYMtableENT     #RELOCent        LENidSTR
41    #0x00000001       0x00000021       0x0000006c       0x0000002f
42    #
43    ##IMPfilID        OFFidSTR         LENstrTBL        OFFstrTBL
44    #0x00000002       0x00000848       0x00000049       0x00000877
45    #
46    #
47    #                        ***Import File Strings***
48    #INDEX  PATH                          BASE                MEMBER
49    #0      /usr/lib:/lib:/usr/lpp/xlC/lib
50    #1                                    libc.a              shr.o
51    
52    #
53    #
54    
55    # Search executables, archives, and symlinks to those types for shared
56    # objects
57    sed -e "s/['\"]/\\\&/g" -e "s/$/\//g" | LANG=C xargs file | grep -e ":.*executable" -e ":.*archive" | cut -d: -f1 | sed "s/\/$//g" |
58    
59    # Use the verbose version of dump to find the sharable objects 
60    while read f
61    do
62            LANG=C /usr/bin/dump -ov $f/ 2>/dev/null | grep -E "^Flags.*SHROBJ|:$" |
63         awk 'match($1,":$") { member=$1 }
64         !match($1,":$") {print member} '
65    done | sed -e 's/:$//' -e 's/\/\[/\(/g' -e 's/\]/)/g' | xargs -i basename {} | 
66    sort -u
67 }
68
69 PATH=/usr/bin
70
71 machinetype=`uname -m`
72 if [[ $machinetype = "ia64" ]]
73 then
74    find_prov_ia64
75 else
76    find_prov_power
77 fi
78