Blame scripts/update-abilist.sh

Packit 6c4009
#!/bin/sh
Packit 6c4009
# Update abilist files based on differences on one architecture.
Packit 6c4009
# Copyright (C) 2015-2018 Free Software Foundation, Inc.
Packit 6c4009
# This file is part of the GNU C Library.
Packit 6c4009
#
Packit 6c4009
# The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
# modify it under the terms of the GNU Lesser General Public
Packit 6c4009
# License as published by the Free Software Foundation; either
Packit 6c4009
# version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
#
Packit 6c4009
# The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
# Lesser General Public License for more details.
Packit 6c4009
#
Packit 6c4009
# You should have received a copy of the GNU Lesser General Public
Packit 6c4009
# License along with the GNU C Library; if not, see
Packit 6c4009
# <http://www.gnu.org/licenses/>.
Packit 6c4009
Packit 6c4009
set -e
Packit 6c4009
export LC_ALL=C
Packit 6c4009
Packit 6c4009
if [ $# -lt 2 ]; then
Packit 6c4009
  echo "usage: $0 OLD-FILE NEW-FILE FILES-TO-BE-PATCHED..." 1>&2
Packit 6c4009
  exit 2
Packit 6c4009
elif [ $# -eq 2 ]; then
Packit 6c4009
  echo "info: no files to patch" 1>&2
Packit 6c4009
  exit 0
Packit 6c4009
fi
Packit 6c4009
Packit 6c4009
old_file="$1"
Packit 6c4009
shift
Packit 6c4009
new_file="$1"
Packit 6c4009
shift
Packit 6c4009
Packit 6c4009
tmp_old_sorted="$(mktemp)"
Packit 6c4009
tmp_new_sorted="$(mktemp)"
Packit 6c4009
tmp_new_symbols="$(mktemp)"
Packit 6c4009
tmp_patched="$(mktemp)"
Packit 6c4009
Packit 6c4009
cleanup () {
Packit 6c4009
  rm -f -- "$tmp_old_sorted" "$tmp_new_sorted" \
Packit 6c4009
    "$tmp_new_symbols" "$tmp_patched"
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
trap cleanup 0
Packit 6c4009
Packit 6c4009
sort -u -o "$tmp_old_sorted" -- "$old_file"
Packit 6c4009
sort -u -o "$tmp_new_sorted" -- "$new_file"
Packit 6c4009
Packit 6c4009
# -1 skips symbols only in $old_file (deleted symbols).
Packit 6c4009
# -3 skips symbols in both files (unchanged symbols).
Packit 6c4009
comm -1 -3 "$tmp_old_sorted" "$tmp_new_sorted" > "$tmp_new_symbols"
Packit 6c4009
Packit 6c4009
new_symbol_count="$(wc -l < "$tmp_new_symbols")"
Packit 6c4009
if [ "$new_symbol_count" -eq 0 ]; then
Packit 6c4009
  echo "info: no symbols added" 1>&2
Packit 6c4009
  exit 0
Packit 6c4009
fi
Packit 6c4009
Packit 6c4009
echo "info: $new_symbol_count symbol(s) added" 1>&2
Packit 6c4009
Packit 6c4009
for to_be_patched in "$@" ; do
Packit 6c4009
  sort -u -o "$tmp_patched" -- "$to_be_patched" "$tmp_new_symbols"
Packit 6c4009
  if ! cmp -s -- "$to_be_patched" "$tmp_patched"; then
Packit 6c4009
    echo "info: updating $to_be_patched" 1>&2
Packit 6c4009
    cp -- "$tmp_patched" "$to_be_patched"
Packit 6c4009
  fi
Packit 6c4009
done