]>
Commit | Line | Data |
---|---|---|
c100dca3 FW |
1 | #!/bin/sh |
2 | # Update abilist files based on differences on one architecture. | |
dff8da6b | 3 | # Copyright (C) 2015-2024 Free Software Foundation, Inc. |
c100dca3 FW |
4 | # This file is part of the GNU C Library. |
5 | # | |
6 | # The GNU C Library is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU Lesser General Public | |
8 | # License as published by the Free Software Foundation; either | |
9 | # version 2.1 of the License, or (at your option) any later version. | |
10 | # | |
11 | # The GNU C Library 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 GNU | |
14 | # Lesser General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU Lesser General Public | |
17 | # License along with the GNU C Library; if not, see | |
5a82c748 | 18 | # <https://www.gnu.org/licenses/>. |
c100dca3 FW |
19 | |
20 | set -e | |
21 | export LC_ALL=C | |
22 | ||
c59ee916 | 23 | if [ $# -lt 2 ]; then |
c100dca3 FW |
24 | echo "usage: $0 OLD-FILE NEW-FILE FILES-TO-BE-PATCHED..." 1>&2 |
25 | exit 2 | |
c59ee916 FW |
26 | elif [ $# -eq 2 ]; then |
27 | echo "info: no files to patch" 1>&2 | |
28 | exit 0 | |
c100dca3 FW |
29 | fi |
30 | ||
31 | old_file="$1" | |
32 | shift | |
33 | new_file="$1" | |
34 | shift | |
35 | ||
36 | tmp_old_sorted="$(mktemp)" | |
37 | tmp_new_sorted="$(mktemp)" | |
38 | tmp_new_symbols="$(mktemp)" | |
39 | tmp_patched="$(mktemp)" | |
40 | ||
41 | cleanup () { | |
42 | rm -f -- "$tmp_old_sorted" "$tmp_new_sorted" \ | |
43 | "$tmp_new_symbols" "$tmp_patched" | |
44 | } | |
45 | ||
46 | trap cleanup 0 | |
47 | ||
48 | sort -u -o "$tmp_old_sorted" -- "$old_file" | |
49 | sort -u -o "$tmp_new_sorted" -- "$new_file" | |
50 | ||
51 | # -1 skips symbols only in $old_file (deleted symbols). | |
52 | # -3 skips symbols in both files (unchanged symbols). | |
53 | comm -1 -3 "$tmp_old_sorted" "$tmp_new_sorted" > "$tmp_new_symbols" | |
54 | ||
55 | new_symbol_count="$(wc -l < "$tmp_new_symbols")" | |
56 | if [ "$new_symbol_count" -eq 0 ]; then | |
57 | echo "info: no symbols added" 1>&2 | |
58 | exit 0 | |
59 | fi | |
60 | ||
61 | echo "info: $new_symbol_count symbol(s) added" 1>&2 | |
62 | ||
63 | for to_be_patched in "$@" ; do | |
64 | sort -u -o "$tmp_patched" -- "$to_be_patched" "$tmp_new_symbols" | |
65 | if ! cmp -s -- "$to_be_patched" "$tmp_patched"; then | |
66 | echo "info: updating $to_be_patched" 1>&2 | |
67 | cp -- "$tmp_patched" "$to_be_patched" | |
68 | fi | |
69 | done |