Skip to content

Commit

Permalink
adapt for new era
Browse files Browse the repository at this point in the history
  • Loading branch information
tpgxyz committed Nov 8, 2021
1 parent 460256b commit 3ffddde
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 163 deletions.
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
NAME = spec-helper
VERSION = 0.31.49
SVNPATH = [email protected]:OpenMandrivaSoftware/spec-helper.git
VERSION = 0.31.50
GITPATH = [email protected]:OpenMandrivaSoftware/spec-helper.git

SCRIPT_FILES = clean_files clean_perl check_elf_files \
lib_symlinks fix_file_permissions fix_mo fix_xdg fix_pkgconfig fix_pamd \
remove_info_dir remove_libtool_files remove_rpath relink_symlinks fix_eol \
python_shebangs
remove_info_dir remove_libtool_files remove_rpath relink_symlinks fix_eol

BIN_FILES = rediff_patch spec-cleaner
MACROS_FILES = spec-helper.macros
MACROS_FILES = macros.spec-helper
TEST_FILES = t/*.t
FILES = Makefile NEWS README \
$(SCRIPT_FILES) $(BIN_FILES) $(MACROS_FILES:=.in) \
Expand All @@ -17,20 +17,20 @@ TEST_VERBOSE = 0

bindir = /usr/bin
pkgdatadir = /usr/share/$(NAME)
rpmmacrosdir = /etc/rpm/macros.d
rpmmacrodir = /usr/lib/rpm/macros.d

all:
@echo "use make install or make dist"

install: $(MACROS_FILES)
install -d -m 755 $(DESTDIR)$(bindir)
install -m 755 $(BIN_FILES) $(DESTDIR)$(bindir)
install -p -m 755 $(BIN_FILES) $(DESTDIR)$(bindir)
install -d -m 755 $(DESTDIR)$(pkgdatadir)
install -m 755 $(SCRIPT_FILES) $(DESTDIR)$(pkgdatadir)
install -d -m 755 $(DESTDIR)/$(rpmmacrosdir)
install -m 644 $(MACROS_FILES) $(DESTDIR)/$(rpmmacrosdir)
install -p -m 755 $(SCRIPT_FILES) $(DESTDIR)$(pkgdatadir)
install -d -m 755 $(DESTDIR)$(rpmmacrodir)
install -p -m 644 $(MACROS_FILES) $(DESTDIR)$(rpmmacrodir)

spec-helper.macros: spec-helper.macros.in
macros.spec-helper: macros.spec-helper.in
sed -e 's:@pkgdatadir@:$(pkgdatadir):' < $< > $@

clean:
Expand Down
28 changes: 14 additions & 14 deletions check_elf_files
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
# Check elf files

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

LIB="`rpm --eval %{_lib}`"
LIB="$(rpm --eval %{_lib})"
export LD_LIBRARY_PATH="$RPM_BUILD_ROOT/$LIB:$RPM_BUILD_ROOT/usr/$LIB"


Expand All @@ -23,13 +23,13 @@ find "$RPM_BUILD_ROOT" -type f \( -executable -o -name \*.so\* \) -a \
xargs --no-run-if-empty -0 file -N -L |
grep -e '\.so.*: ELF.*shared' -e ': ELF.*executable' |
while read match; do
path="`echo $match | sed -e 's#\(\.so.*\): ELF.*shared.*#\1#' -e 's#: ELF.*executable.*##'`"
syspath="`echo $path | sed -e \"s#^$RPM_BUILD_ROOT##\"`"
if echo $match | grep -q -e ': ELF'; then
unused_libs="`ldd -u -r $path 2> /dev/null | grep /`"
path="$(printf '%s\n' $match | sed -e 's#\(\.so.*\): ELF.*shared.*#\1#' -e 's#: ELF.*executable.*##')"
syspath="$(printf '%s\n' $path | sed -e \"s#^$RPM_BUILD_ROOT##\")"
if printf '%s\n' $match | grep -q -e ': ELF'; then
unused_libs="$(ldd -u -r $path 2> /dev/null | grep /)"
if [ -n "$unused_libs" ]; then
echo "Warning: unused libraries in $syspath: " >&2
echo "$unused_libs" >&2
printf '%s\n' "Warning: unused libraries in $syspath: " >&2
printf '%s\n' "$unused_libs" >&2
fi
fi
done
Expand All @@ -41,11 +41,11 @@ find "$RPM_BUILD_ROOT" -type f -name \*.so\* -a \
xargs --no-run-if-empty -0 file -N -L |
grep -e '\.so.*: ELF.*shared' |
while read match; do
path="`echo $match | sed -e 's#\(\.so.*\): ELF.*shared.*#\1#'`"
syspath="`echo $path | sed -e \"s#^$RPM_BUILD_ROOT##\"`"
unused_libs="`ldd -u -r $path 2> /dev/null | grep /`"
undefined_symbols="`ldd -r $path 2>&1 | grep '^undefined symbol: '| sed -e 's#^undefined symbol:##g' -e \"s#($path).*##g\" | tr -d '\n' | tr -d '\t'`"
path="$(printf '%s\n' $match | sed -e 's#\(\.so.*\): ELF.*shared.*#\1#')"
syspath="$(printf '%s\n' $path | sed -e \"s#^$RPM_BUILD_ROOT##\")"
unused_libs="$(ldd -u -r $path 2> /dev/null | grep /)"
undefined_symbols="$(ldd -r $path 2>&1 | grep '^undefined symbol: '| sed -e 's#^undefined symbol:##g' -e \"s#($path).*##g\" | tr -d '\n' | tr -d '\t')"
if [ -n "$undefined_symbols" ]; then
echo "Warning: undefined symbols in $syspath:$undefined_symbols" >&2
printf '%s\n' "Warning: undefined symbols in $syspath:$undefined_symbols" >&2
fi
done
6 changes: 3 additions & 3 deletions clean_files
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# remove backup files

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

if [ -n "$1" ]; then
DIRECTORY=$(echo $1 | sed -e "s#^$RPM_BUILD_ROOT##g")
DIRECTORY=$(printf '%s\n' $1 | sed -e "s#^$RPM_BUILD_ROOT##g")
if [ ! -d "$RPM_BUILD_ROOT$DIRECTORY" ]; then
exit 0
fi
Expand Down
10 changes: 5 additions & 5 deletions clean_perl
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
#!/bin/sh

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

perldirs="$RPM_BUILD_ROOT/usr/lib/perl5 $RPM_BUILD_ROOT/usr/lib64/perl5 $RPM_BUILD_ROOT/usr/share/perl5"
d=""
for i in $perldirs; do
[ -d "$i" ] || continue
d="$d $i"
[ -d "$i" ] || continue
d="$d $i"
done
[ -z "$d" ] && exit 0

find $d -name ".packlist" -o -name perllocal.pod | xargs rm -f

for i in $(find $d -name "*.bs"); do
if [ -s $i ]; then
echo "non empty .bs file!"
printf '%s\n' "non empty .bs file!"
else
rm -f $i
fi
Expand Down
6 changes: 3 additions & 3 deletions fix_eol
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# convert end of line patterns from DOS to UNIX

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

if [ -n "$1" ]; then
DIRECTORY=$(echo $1 | sed -e "s#^$RPM_BUILD_ROOT##g")
DIRECTORY=$(printf '%s\n' $1 | sed -e "s#^$RPM_BUILD_ROOT##g")
if [ ! -d "$RPM_BUILD_ROOT$DIRECTORY" ]; then
exit 0
fi
Expand Down
8 changes: 4 additions & 4 deletions fix_file_permissions
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

Expand All @@ -28,11 +28,11 @@ done
if [ -d "${RPM_BUILD_ROOT}/usr/share/info/" ]; then
find "${RPM_BUILD_ROOT}/usr/share/info/" \
-type f -print0 |
xargs --no-run-if-empty -0 chmod 644
xargs --no-run-if-empty -0 chmod 644
fi

if [ -d "${RPM_BUILD_ROOT}/usr/share/man/" ]; then
find "${RPM_BUILD_ROOT}/usr/share/man/" \
-type f -print0 |
xargs --no-run-if-empty -0 chmod 644
xargs --no-run-if-empty -0 chmod 644
fi
6 changes: 3 additions & 3 deletions fix_mo
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#---------------------------------------------------------------

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

Expand All @@ -40,7 +40,7 @@ for i in "$KO_MESSAGES"/*.mo ; do
sed 's:그놈:GNOME:g' < $TMP > $TMP2 && msgfmt -o $i $TMP2
ret=$?
else
echo "Unsupported encoding" 1>&2
printf '%s\n' "Unsupported encoding" 1>&2
fi
done

Expand Down
10 changes: 5 additions & 5 deletions fix_pamd
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/bin/sh

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

configs=`find $RPM_BUILD_ROOT/etc/pam.d/ -type f ! -type l 2> /dev/null`
configs=$(find $RPM_BUILD_ROOT/etc/pam.d/ -type f ! -type l 2> /dev/null)
if [ -n "$configs" ]; then
echo -n "Fixing pam.d config files..."
printf '%s\n' "Fixing pam.d config files..."
sed -e 's,/lib64/security/,,g ; s,/lib/security/,,g' $configs
echo "done"
printf '%s\n' "...done"
fi
10 changes: 5 additions & 5 deletions fix_pkgconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
# (c) Andrey Bondrov <[email protected]> 2016

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

for pc in $(find "$RPM_BUILD_ROOT" -name \*.pc); do
for pc in $(find "$RPM_BUILD_ROOT" -name \*.pc -type f); do
export PKG_CONFIG_PATH="$(dirname $pc)"
pcfile="$(basename $pc)"
pcmodule="$(echo $pcfile|cut -d. -f1)"
pcmodule="$(printf '%s\n' $pcfile|cut -d. -f1)"
for variable in $(pkg-config --print-variables "$pcmodule"); do
dir=$(pkg-config --variable="$variable" "$pcmodule")
if [[ "$dir" == "/"* && -d "$dir" ]]; then
if [ "$dir" != "`realpath $dir`" ]; then
if [ "$dir" != "$(realpath $dir)" ]; then
parentdir=$(dirname ${dir})
subdir=$(basename ${dir})
regexp="-e s|\(${variable}=.*/${subdir}\)/.*\$|\1|g"
Expand Down
5 changes: 2 additions & 3 deletions fix_xdg
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# Fix .desktop files to be compliant with XDG specification

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

Expand All @@ -18,4 +18,3 @@ do
# if these lines do not end with '='
sed -i 's/^\(Actions=.*\|MimeType=.*\|OnlyShowIn=.*\|Categories=.*\)\([[:alnum:]]\)[[:space:]]*$/\1\2;/' "$f"
done

13 changes: 6 additions & 7 deletions lib_symlinks
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,28 @@
# File : lib_symlinks
# Author : Frederic Lepied
# Created On : Tue Nov 7 08:33:05 2000
# Description : Run ldconfig to create symlinks to libraries.
# Description : Run ldconfig to create symlinks to libraries.
#
# Copyright (C) 2000 by Frederic Lepied <[email protected]>
# Redistribution of this file is permitted under the terms of the GNU
# Public License (GPL)
#---------------------------------------------------------------

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

libs=`find "$RPM_BUILD_ROOT" -type d \
libs=$(find "$RPM_BUILD_ROOT" -type d \
-a "(" -name lib -o -name lib64 ")" \
-a ! "(" -path '*/usr/src/debug*' -o -path '*/usr/lib/debug*' ")" \
`
-a ! "(" -path '*/usr/src/debug*' -o -path '*/usr/lib/debug*' ")")

if [ -n "$libs" -o -n "$EXTRA_LIBS_TO_SYMLINK" ]; then
if [ -n "$libs" ] || [ -n "$EXTRA_LIBS_TO_SYMLINK" ]; then
/sbin/ldconfig -n -N $libs $EXTRA_LIBS_TO_SYMLINK
fi

Expand Down
1 change: 0 additions & 1 deletion spec-helper.macros.in → macros.spec-helper.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
%{?!dont_fix_eol: [ -n "$DONT_FIX_EOL" ] || %_spec_helper_dir/fix_eol} \
%{?!dont_check_elf_files: [ -n "$DONT_CHECK_ELF_FILES" ] || %_spec_helper_dir/check_elf_files} \
%{?!dont_remove_rpath: [ -n "$DONT_REMOVE_RPATH" ] || %_spec_helper_dir/remove_rpath} \
%{?!dont_check_python_shebangs: [ -n "$DONT_CHECK_PYTHON_SHEBANGS" ] || %_spec_helper_dir/python_shebangs} \
%{?!__debug_package: [ -n "%{?dont_strip:1}%{?!dont_strip:$DONT_STRIP}" ] || export DISABLE_DEBUG=1 && %__debug_install_post} \
%{nil}

Expand Down
10 changes: 5 additions & 5 deletions python_shebangs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh

if [ -z "$RPM_BUILD_ROOT" ]; then
echo "No build root defined" >&2
printf '%s\n' "No build root defined" >&2
exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
echo "Invalid build root" >&2
printf '%s\n' "Invalid build root" >&2
exit 1
fi

Expand All @@ -15,7 +15,7 @@ set -efu
# otherwise we will have to switch to bashisms and require /dev/fd/*
tmpfile="$(mktemp)"
trap 'rm -f "$tmpfile"' EXIT
echo 0 > "$tmpfile"
printf '%s\n' "0" > "$tmpfile"

for dir in /bin /usr/bin /sbin /usr/sbin /usr/libexec
do
Expand All @@ -32,9 +32,9 @@ do
# #! /usr/bin/env python
# Note that a space may be in the end of the shebang line
if head -n 1 "$file" | grep -qE '^#!([[:blank:]])*.*(/python|[[:blank:]]python)([[:blank:]])*$' ; then
echo "Unversioned Python shebangs are not allowed. Specify python3 or python2 explicitly in $file"
printf '%s\n' "Unversioned Python shebangs are not allowed. Specify python3 or python2 explicitly in $file"
# Do not fail on the 1st error, print all errors at one time
echo 1 > "$tmpfile"
printf '%s\n' "1" > "$tmpfile"
fi
done
done
Expand Down
Loading

0 comments on commit 3ffddde

Please sign in to comment.