]>
Commit | Line | Data |
---|---|---|
97756e21 MT |
1 | #!/bin/bash |
2 | ############################################################################ | |
3 | # # | |
4 | # This file is part of the IPFire Firewall. # | |
5 | # # | |
6 | # IPFire is free software; you can redistribute it and/or modify # | |
7 | # it under the terms of the GNU General Public License as published by # | |
8 | # the Free Software Foundation; either version 2 of the License, or # | |
9 | # (at your option) any later version. # | |
10 | # # | |
11 | # IPFire 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 General Public License for more details. # | |
15 | # # | |
16 | # You should have received a copy of the GNU General Public License # | |
17 | # along with IPFire; if not, write to the Free Software # | |
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # | |
19 | # # | |
20 | # Copyright (C) 2020 IPFire Team <info@ipfire.org>. # | |
21 | # # | |
22 | ############################################################################ | |
23 | ||
24 | PATHS=( | |
45e1202d | 25 | /usr/lib/sse2 |
97756e21 MT |
26 | /usr/lib |
27 | /lib | |
28 | ) | |
29 | ||
30 | main() { | |
1475bc53 DW |
31 | local dry_run="false" |
32 | ||
33 | while [ $# -gt 0 ]; do | |
34 | case "${1}" in | |
35 | --dry-run) | |
36 | dry_run="true" | |
37 | ;; | |
38 | ||
39 | *) | |
40 | echo "${0}: Invalid argument: ${1}" >&2 | |
41 | return 2 | |
42 | ;; | |
43 | esac | |
44 | shift | |
45 | done | |
46 | ||
97756e21 MT |
47 | # Update the runtime linker cache (this may fix any broken symlinks) |
48 | ldconfig | |
49 | ||
50 | local path | |
51 | for path in ${PATHS[@]}; do | |
52 | echo "Searching in ${path}..." | |
53 | ||
54 | # Find all files called libsomething.so.N | |
55 | local lib | |
56 | for lib in $(find "${path}" -maxdepth 1 -type l -name "lib*.so.*" | sort); do | |
57 | # Read the name of the linked library | |
58 | local link="$(readlink -m "${lib}")" | |
59 | ||
60 | # We have two versioning schemas that we need to distinguish... | |
61 | local files=() | |
62 | case "${link}" in | |
63 | # Libraries called libsomething-N.so | |
64 | */lib*-*.so) | |
65 | files+=( ${link%-*}-* ) | |
66 | ;; | |
67 | ||
68 | # Libraries called libsomething.so.N.* | |
69 | *) | |
70 | files+=( ${lib}* ) | |
71 | ;; | |
72 | esac | |
73 | ||
74 | # Remove all files that have the same base name than | |
75 | # the library we are looking at, apart from the symlink | |
76 | # and the linked file itself. | |
77 | local file | |
78 | for file in ${files[@]}; do | |
79 | case "${file}" in | |
80 | # Ignore these files | |
81 | ${lib}|${link}) | |
82 | ;; | |
83 | ||
84 | *) | |
1475bc53 DW |
85 | echo "Removing ${file}..." |
86 | ||
87 | # Actually remove the file (maybe) | |
8c0ab3d4 | 88 | if [ "${dry_run}" = "false" ]; then |
1475bc53 DW |
89 | unlink "${file}" |
90 | fi | |
97756e21 MT |
91 | ;; |
92 | esac | |
93 | done | |
94 | done | |
95 | done | |
96 | } | |
97 | ||
98 | main "$@" || exit $? |