scripts: move ProvidedSymbols() and SuggestBPP() to separate files
ProvidedSymbols() used to be defined both in lib.prov.in and lib.req.in, fix this code duplication by moving ProvidedSymbols() to separate provided_symbols executable script. Likewise, SuggestBPP() used to be defined both in lib.prov.in and lib.req.in, fix this code duplication by moving SuggestBPP() to separate suggest_bpp executable script.
This commit is contained in:
parent
c5d7a2ddf2
commit
2107482334
@ -475,10 +475,12 @@ mv -T %buildroot%_rpmlibdir/{,build}macros
|
||||
%rpmattr %_rpmlibdir/percolate
|
||||
%rpmattr %_rpmlibdir/pkgconfig.*
|
||||
%rpmattr %_rpmlibdir/pkgconfiglib.*
|
||||
%rpmattr %_rpmlibdir/provided_symbols
|
||||
%rpmattr %_rpmlibdir/rpmlib.*
|
||||
%rpmattr %_rpmlibdir/shell.*
|
||||
%rpmattr %_rpmlibdir/shebang.*
|
||||
%rpmattr %_rpmlibdir/static.*
|
||||
%rpmattr %_rpmlibdir/suggest_bpp
|
||||
%rpmattr %_rpmlibdir/symlinks.*
|
||||
%rpmattr %_rpmlibdir/tmpdir.sh
|
||||
%rpmattr %_rpmlibdir/verify-elf
|
||||
|
@ -20,6 +20,7 @@ EXTRA_DIST = \
|
||||
files.req files.req.files 0common-files.req.list \
|
||||
is_elf_so_executable \
|
||||
ldd lib.req lib.req.files lib.prov lib.prov.files shlib.req.awk \
|
||||
provided_symbols suggest_bpp \
|
||||
pam.req pam.req.files pam.prov pam.prov.files \
|
||||
percolate \
|
||||
pkgconfig.req pkgconfiglib.req pkgconfig.req.files \
|
||||
@ -51,6 +52,7 @@ config_SCRIPTS = \
|
||||
files.req files.req.files \
|
||||
is_elf_so_executable \
|
||||
ldd lib.req lib.req.files lib.prov lib.prov.files shlib.req.awk \
|
||||
provided_symbols suggest_bpp \
|
||||
pam.req pam.req.files pam.prov pam.prov.files \
|
||||
pkgconfig.req pkgconfiglib.req pkgconfig.req.files \
|
||||
percolate \
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh -efu
|
||||
#
|
||||
# Copyright (C) 2000-2006 Dmitry V. Levin <ldv@altlinux.org>
|
||||
# Copyright (C) 2000-2019 Dmitry V. Levin <ldv@altlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -99,12 +99,12 @@ LibProv()
|
||||
printf '%s\n' "$provname"
|
||||
return 0
|
||||
fi
|
||||
local sym="$(ProvidedSymbols "$f")"
|
||||
local sym="$(@RPMCONFIGDIR@/provided_symbols "$f")"
|
||||
if [ -n "$sym" ]; then
|
||||
local n bpp set
|
||||
n=$(printf '%s\n' "$sym" |wc -l)
|
||||
Verbose "$f: $n symbols"
|
||||
bpp=$(SuggestBPP "$n")
|
||||
bpp=$(@RPMCONFIGDIR@/suggest_bpp "$n")
|
||||
set=$(printf '%s\n' "$sym" |@RPMCONFIGDIR@/mkset "$bpp")
|
||||
printf '%s = %s\n' "$provname" "$set"
|
||||
else
|
||||
@ -113,40 +113,4 @@ LibProv()
|
||||
fi
|
||||
}
|
||||
|
||||
ProvidedSymbols()
|
||||
{
|
||||
readelf --wide --dyn-syms "$1" |
|
||||
awk '+$1 && NF>=8 &&
|
||||
# dl-lookup.c: /st_value
|
||||
($2!="00000000" && $2!="0000000000000000" || $4=="TLS") &&
|
||||
# dl-lookup.c: /ALLOWED_STT
|
||||
($4=="NOTYPE" || $4=="OBJECT" || $4 == "FUNC" || $4=="COMMON" || $4=="TLS" || $4=="IFUNC") &&
|
||||
# dl-lookup.c: /hidden
|
||||
($6=="DEFAULT" || $6=="PROTECTED") &&
|
||||
# dl-lookup.c: /switch.*ST_BIND
|
||||
($5=="GLOBAL" || $5=="WEAK" || $5 == "UNIQUE") {
|
||||
# dl-lookup.c: /st_shndx
|
||||
match($0, "[[:space:]][[:digit:]]+[[:space:]]+([^[:space:]()@]+)(@+[^[:space:]()@]+)?$", a)
|
||||
sym = a[1]
|
||||
if (sym == "" ||
|
||||
# ignore special symbols found in each library
|
||||
sym == "__bss_start" ||
|
||||
sym == "_edata" ||
|
||||
sym == "_end" ||
|
||||
sym == "_fini" ||
|
||||
sym == "_init")
|
||||
next
|
||||
print sym
|
||||
}' |
|
||||
LC_ALL=C sort -u
|
||||
}
|
||||
|
||||
SuggestBPP()
|
||||
{
|
||||
# For the number of symbols in the range 2^{m-1}..2^m-1,
|
||||
# use m+10 bits per symbol. Upper bound on the error rate
|
||||
# is 2^{-10} (about 0.1%).
|
||||
perl -le 'print int log(shift) / log(2) + 11' "$1"
|
||||
}
|
||||
|
||||
ArgvFileAction LibProv "$@"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh -efu
|
||||
#
|
||||
# Copyright (C) 2000-2006,2008 Dmitry V. Levin <ldv@altlinux.org>
|
||||
# Copyright (C) 2000-2019 Dmitry V. Levin <ldv@altlinux.org>
|
||||
# Copyright (C) 2007-2010 Alexey Tourbin <at@altlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@ -217,42 +217,6 @@ NF==2 && ($1==name || basename($1)==name) && $1~"^/" && $2~"^[(]0x" {print $1}
|
||||
LC_ALL=C sort -t$'\t' -m -u -k2,2 -k1,1 -o "$tmpdir"/sym2lib{,} "$tmpdir"/a/sym2lib
|
||||
}
|
||||
|
||||
ProvidedSymbols()
|
||||
{
|
||||
readelf --wide --dyn-syms "$1" |
|
||||
awk '+$1 && NF>=8 &&
|
||||
# dl-lookup.c: /st_value
|
||||
($2!="00000000" && $2!="0000000000000000" || $4=="TLS") &&
|
||||
# dl-lookup.c: /ALLOWED_STT
|
||||
($4=="NOTYPE" || $4=="OBJECT" || $4 == "FUNC" || $4=="COMMON" || $4=="TLS" || $4=="IFUNC") &&
|
||||
# dl-lookup.c: /hidden
|
||||
($6=="DEFAULT" || $6=="PROTECTED") &&
|
||||
# dl-lookup.c: /switch.*ST_BIND
|
||||
($5=="GLOBAL" || $5=="WEAK" || $5 == "UNIQUE") {
|
||||
# dl-lookup.c: /st_shndx
|
||||
match($0, "[[:space:]][[:digit:]]+[[:space:]]+([^[:space:]()@]+)(@+[^[:space:]()@]+)?$", a)
|
||||
sym = a[1]
|
||||
if (sym == "" ||
|
||||
# ignore special symbols found in each library
|
||||
sym == "__bss_start" ||
|
||||
sym == "_edata" ||
|
||||
sym == "_end" ||
|
||||
sym == "_fini" ||
|
||||
sym == "_init")
|
||||
next
|
||||
print sym
|
||||
}' |
|
||||
LC_ALL=C sort -u
|
||||
}
|
||||
|
||||
SuggestBPP()
|
||||
{
|
||||
# For the number of symbols in the range 2^{m-1}..2^m-1,
|
||||
# use m+10 bits per symbol. Upper bound on the error rate
|
||||
# is 2^{-10} (about 0.1%).
|
||||
perl -le 'print int log(shift) / log(2) + 11' "$1"
|
||||
}
|
||||
|
||||
ArgvFileAction LibReq "$@"
|
||||
[ -s "$tmpdir"/lib2dep ] || exit 0
|
||||
|
||||
@ -286,10 +250,10 @@ while IFS=$'\t' read -r lib dep; do
|
||||
continue
|
||||
fi
|
||||
# Deal with bpp.
|
||||
provsym=$(ProvidedSymbols "$lib")
|
||||
provsym=$(@RPMCONFIGDIR@/provided_symbols "$lib")
|
||||
if [ -n "$provsym" ]; then
|
||||
provn=$(printf '%s\n' "$provsym" |wc -l)
|
||||
bpp=$(SuggestBPP "$provn")
|
||||
bpp=$(@RPMCONFIGDIR@/suggest_bpp "$provn")
|
||||
else
|
||||
Warning "$lib provides no symbols"
|
||||
bpp=10
|
||||
|
35
scripts/provided_symbols
Executable file
35
scripts/provided_symbols
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/sh -efu
|
||||
#
|
||||
# Copyright (C) 2010-2011 Alexey Tourbin <at@altlinux.org>
|
||||
# Copyright (C) 2018 Dmitry V. Levin <ldv@altlinux.org>
|
||||
# Copyright (C) 2018 Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
export LC_ALL=C
|
||||
|
||||
readelf --wide --dyn-syms -- "$@" |
|
||||
awk '+$1 && NF>=8 &&
|
||||
# dl-lookup.c: /st_value
|
||||
($2!="00000000" && $2!="0000000000000000" || $4=="TLS") &&
|
||||
# dl-lookup.c: /ALLOWED_STT
|
||||
($4=="NOTYPE" || $4=="OBJECT" || $4 == "FUNC" || $4=="COMMON" || $4=="TLS" || $4=="IFUNC") &&
|
||||
# dl-lookup.c: /hidden
|
||||
($6=="DEFAULT" || $6=="PROTECTED") &&
|
||||
# dl-lookup.c: /switch.*ST_BIND
|
||||
($5=="GLOBAL" || $5=="WEAK" || $5 == "UNIQUE") {
|
||||
# dl-lookup.c: /st_shndx
|
||||
match($0, "[[:space:]][[:digit:]]+[[:space:]]+([^[:space:]()@]+)(@+[^[:space:]()@]+)?$", a)
|
||||
sym = a[1]
|
||||
if (sym == "" ||
|
||||
# ignore special symbols found in each library
|
||||
sym == "__bss_start" ||
|
||||
sym == "_edata" ||
|
||||
sym == "_end" ||
|
||||
sym == "_fini" ||
|
||||
sym == "_init")
|
||||
next
|
||||
print sym
|
||||
}' |
|
||||
sort -u
|
11
scripts/suggest_bpp
Executable file
11
scripts/suggest_bpp
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh -efu
|
||||
#
|
||||
# Copyright (C) 2010 Alexey Tourbin <at@altlinux.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# For the number of symbols in the range 2^{m-1}..2^m-1,
|
||||
# use m+10 bits per symbol. Upper bound on the error rate
|
||||
# is 2^{-10} (about 0.1%).
|
||||
exec perl -le 'print int log(shift) / log(2) + 11' "$1"
|
Loading…
Reference in New Issue
Block a user