]> pd.if.org Git - zpackage/blob - zpm-getlibs
create combined single header for jsw library
[zpackage] / zpm-getlibs
1 #!/bin/sh
2
3 # list a files libraries
4
5 LD_TRACE_LOADED_OBJECTS=1  /lib/ld-linux-x86-64.so.2 
6
7 verbose=0
8 all=0
9 script=0
10 check=0
11
12 while getopts avs arg; do
13         case $arg in
14                 a) all=1;;
15                 v) verbose=1;;
16         c) check=1;;
17         s) script=1;;
18         ?) printf 'usage: zpm-preserve [-av] <pkgname>\n'
19                 exit 1
20                 ;;
21         esac
22 done
23
24 pkgname="$1"
25
26 pacman -Qlq "$pkgname" | while read file; do
27         if [ ! -f "$file" ]; then continue; fi
28         base=$(basename "$file")
29         if [ $all -eq 0 ] && [ "$base" = "${base#lib}" ]; then continue; fi
30
31         if [ $check -eq 1 ]; then
32                 elftype -e "$file"
33                 rv=$?
34                 if [ $rv -ne 0 ]; then continue; fi
35                 for lib in $(zpm getlibs $file | grep preserve); do
36                         echo $pkgname $file $lib
37                 done
38                 continue
39         fi
40
41         soname=$(soname $file)
42         if [ $? -eq 0 ] && [ -n "$soname" ]; then
43                 dir=$(dirname "$file")
44                 if [ "$script" -ne 0 ]; then
45                         printf 'mkdir -p "%s"\n' "$dir/preserve"
46                         printf 'ln -f "%s" "%s"\n' "$file" "$dir/preserve/"
47                 else
48                         mkdir -p "$dir/preserve"
49                         if [ "$verbose" -gt 0 ]; then
50                                 printf '# preserving %s\n' "$file"
51                         fi
52                         ln -f "$file" "$dir/preserve/"
53                 fi
54         fi
55 done