use functions

This commit is contained in:
Дмитрий Левин 2003-11-09 16:47:45 +00:00
parent 8b81f418b6
commit ebc53cf631
22 changed files with 66 additions and 98 deletions

View File

@ -3,7 +3,7 @@
# brp-adjust_libraries - update symbolic links to shared libraries. # brp-adjust_libraries - update symbolic links to shared libraries.
# #
# $Id$ # $Id$
# Copyright (C) 2000 Dmitry V. Levin <ldv@altlinux.org> # Copyright (C) 2000,2003 Dmitry V. Levin <ldv@altlinux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -20,13 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
PROG="${0##*/}" . @RPMCONFIGDIR@/functions
ValidateBuildRoot
# If using normal root, avoid changing anything.
if [ -z "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ]; then
echo "$PROG: non-/ \$RPM_BUILD_ROOT expected" >&2
exit 1
fi
cd "$RPM_BUILD_ROOT" cd "$RPM_BUILD_ROOT"

View File

@ -22,7 +22,6 @@
# #
. @RPMCONFIGDIR@/functions . @RPMCONFIGDIR@/functions
ValidateBuildRoot ValidateBuildRoot
cd "$RPM_BUILD_ROOT" cd "$RPM_BUILD_ROOT"

View File

@ -3,7 +3,7 @@
# brp-bytecompile_python - compile python modules. # brp-bytecompile_python - compile python modules.
# #
# $Id$ # $Id$
# Copyright (C) 2000 Dmitry V. Levin <ldv@altlinux.org> # Copyright (C) 2000,2003 Dmitry V. Levin <ldv@altlinux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -20,13 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
PROG="${0##*/}" . @RPMCONFIGDIR@/functions
ValidateBuildRoot
# If using normal root, avoid changing anything.
if [ -z "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ]; then
echo "$PROG: non-/ \$RPM_BUILD_ROOT expected" >&2
exit 1
fi
cd "$RPM_BUILD_ROOT" cd "$RPM_BUILD_ROOT"

View File

@ -3,7 +3,7 @@
# brp-cleanup - cleanup buildroot. # brp-cleanup - cleanup buildroot.
# #
# $Id$ # $Id$
# Copyright (C) 2000-2002 Dmitry V. Levin <ldv@altlinux.org> # Copyright (C) 2000-2003 Dmitry V. Levin <ldv@altlinux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -20,25 +20,16 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
PROG="${0##*/}" . @RPMCONFIGDIR@/functions
ValidateBuildRoot
cd "$RPM_BUILD_ROOT"
RPM_CLEANUP_METHOD="${RPM_CLEANUP_METHOD## }" RPM_CLEANUP_METHOD="${RPM_CLEANUP_METHOD## }"
RPM_CLEANUP_METHOD="${RPM_CLEANUP_METHOD%% }" RPM_CLEANUP_METHOD="${RPM_CLEANUP_METHOD%% }"
echo "Cleaning files in $RPM_BUILD_ROOT ($RPM_CLEANUP_METHOD)" echo "Cleaning files in $RPM_BUILD_ROOT ($RPM_CLEANUP_METHOD)"
if [ "$RPM_CLEANUP_METHOD" = skip ]; then if [ "$RPM_CLEANUP_METHOD" = skip -o "$RPM_CLEANUP_METHOD" = none ]; then
exit 0
fi
# If using normal root, avoid changing anything.
if [ -z "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ]; then
echo "$PROG: non-/ \$RPM_BUILD_ROOT expected" >&2
exit 1
fi
cd "$RPM_BUILD_ROOT"
if [ "$RPM_CLEANUP_METHOD" = none ]; then
exit 0 exit 0
fi fi

View File

@ -21,7 +21,6 @@
# #
. @RPMCONFIGDIR@/functions . @RPMCONFIGDIR@/functions
ValidateBuildRoot ValidateBuildRoot
cd "$RPM_BUILD_ROOT" || exit cd "$RPM_BUILD_ROOT" || exit

View File

@ -3,7 +3,7 @@
# brp-fix-perms - try to fix filesystem permissions. # brp-fix-perms - try to fix filesystem permissions.
# #
# $Id$ # $Id$
# Copyright (C) 2001,2002 Dmitry V. Levin <ldv@altlinux.org> # Copyright (C) 2001-2003 Dmitry V. Levin <ldv@altlinux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -20,13 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
PROG="${0##*/}" . @RPMCONFIGDIR@/functions
ValidateBuildRoot
# If using normal root, avoid changing anything.
if [ -z "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ]; then
echo "$PROG: non-/ \$RPM_BUILD_ROOT expected" >&2
exit 1
fi
cd "$RPM_BUILD_ROOT" cd "$RPM_BUILD_ROOT"
@ -37,7 +32,8 @@ done
# Following objects should not be group/world writable. # Following objects should not be group/world writable.
for d in usr/*; do for d in usr/*; do
[ "$d" = "usr/src" -o -L "$d" -o ! -d "$d" ] || chmod -R go-w "$d" [ "$d" = "usr/src" -o -L "$d" -o ! -d "$d" ] ||
chmod -R go-w "$d"
done done
# Following files should not be group/world readable. # Following files should not be group/world readable.

View File

@ -21,7 +21,6 @@
# #
. @RPMCONFIGDIR@/functions . @RPMCONFIGDIR@/functions
ValidateBuildRoot ValidateBuildRoot
cd "$RPM_BUILD_ROOT" cd "$RPM_BUILD_ROOT"

View File

@ -4,7 +4,7 @@
# Inspired by brp-strip script from RPM source code. # Inspired by brp-strip script from RPM source code.
# #
# $Id$ # $Id$
# Copyright (C) 2000 Dmitry V. Levin <ldv@altlinux.org> # Copyright (C) 2000,2003 Dmitry V. Levin <ldv@altlinux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -22,6 +22,7 @@
# #
. @RPMCONFIGDIR@/functions . @RPMCONFIGDIR@/functions
ValidateBuildRoot
Usage() Usage()
{ {

View File

@ -21,7 +21,6 @@
# #
. @RPMCONFIGDIR@/functions . @RPMCONFIGDIR@/functions
ValidateBuildRoot ValidateBuildRoot
cd "$RPM_BUILD_ROOT" cd "$RPM_BUILD_ROOT"

View File

@ -20,8 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# If using normal root, avoid changing anything. . @RPMCONFIGDIR@/functions
[ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] ValidateBuildRoot
cd "$RPM_BUILD_ROOT" cd "$RPM_BUILD_ROOT"
@ -36,7 +36,7 @@ exit_handler()
trap exit_handler SIGHUP SIGINT SIGQUIT SIGTERM EXIT trap exit_handler SIGHUP SIGINT SIGQUIT SIGTERM EXIT
WORKDIR="$(mktemp -dt check-files.XXXXXXXXXX)" WORKDIR="$(mktemp -dt "$PROG.XXXXXXXXXX")"
export LC_ALL=C export LC_ALL=C

View File

@ -21,6 +21,7 @@
# #
. @RPMCONFIGDIR@/functions . @RPMCONFIGDIR@/functions
ValidateBuildRoot
RPM_COMPRESS_METHOD="${RPM_COMPRESS_METHOD## }" RPM_COMPRESS_METHOD="${RPM_COMPRESS_METHOD## }"
RPM_COMPRESS_METHOD="${RPM_COMPRESS_METHOD%% }" RPM_COMPRESS_METHOD="${RPM_COMPRESS_METHOD%% }"

View File

@ -21,13 +21,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
PROG="${0##*/}" . @RPMCONFIGDIR@/functions
ValidateBuildRoot
Fatal()
{
echo "${0##*/}: $*" >&2
exit 1
}
Usage() Usage()
{ {

View File

@ -18,8 +18,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# If using normal root, avoid changing anything. . @RPMCONFIGDIR@/functions
[ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] ValidateBuildRoot
FindPackage() FindPackage()
{ {
@ -34,7 +34,7 @@ FindPackage()
# Does it start with buildroot? # Does it start with buildroot?
if [ -z "${r##$RPM_BUILD_ROOT*}" ]; then if [ -z "${r##$RPM_BUILD_ROOT*}" ]; then
echo "$f: invalid dependence: $r" >&2 Info "$f: invalid dependence: $r"
return 1 return 1
fi fi

View File

@ -20,7 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
PROG="${0##*/}" . @RPMCONFIGDIR@/functions
ValidateBuildRoot
WORKDIR="$(mktemp -dt "$PROG.XXXXXXXXXX")" WORKDIR="$(mktemp -dt "$PROG.XXXXXXXXXX")"
TMPFILE="$WORKDIR/tmp" TMPFILE="$WORKDIR/tmp"
@ -117,8 +118,8 @@ fix()
fi fi
if ! cmp -s "$f_new" "$f"; then if ! cmp -s "$f_new" "$f"; then
echo "$fname:" >&2 echo "$fname:"
diff "$f" "$f_new" >&2 ||: diff "$f" "$f_new" ||:
cat "$f_new" >"$f" || return 1 cat "$f_new" >"$f" || return 1
fi fi
@ -162,8 +163,8 @@ fix()
fi fi
if ! cmp -s "$f_new" "$f"; then if ! cmp -s "$f_new" "$f"; then
echo "$fname:" >&2 echo "$fname:"
diff "$f" "$f_new" >&2 ||: diff "$f" "$f_new" ||:
cat "$f_new" >"$f" || return 1 cat "$f_new" >"$f" || return 1
fi fi
} }
@ -171,7 +172,7 @@ fix()
rc=0 rc=0
for f in "$@"; do for f in "$@"; do
if [ ! -f "$f" ]; then if [ ! -f "$f" ]; then
echo "$PROG: $f: file unavailable" >&2 Info "$f: file unavailable"
rc=1 rc=1
continue continue
fi fi

View File

@ -20,14 +20,15 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
PROG="${0##*/}" . @RPMCONFIGDIR@/functions
ValidateBuildRoot
: ${RPM_FIXUP_SKIPLIST:=} : ${RPM_FIXUP_SKIPLIST:=}
rc=0 rc=0
for f in "$@"; do for f in "$@"; do
if [ ! -f "$f" ]; then if [ ! -f "$f" ]; then
echo "$PROG: $f: file unavailable" >&2 Info "$f: file unavailable"
rc=1 rc=1
continue continue
fi fi
@ -50,7 +51,7 @@ for f in "$@"; do
if [ "$new_val" != "$old_val" ]; then if [ "$new_val" != "$old_val" ]; then
subst -p "s,^libdir='[^']*'\$,libdir='$new_val',g" "$f" subst -p "s,^libdir='[^']*'\$,libdir='$new_val',g" "$f"
echo "${fname#.}: libdir: '$old_val' --> '$new_val'" >&2 echo "${fname#.}: libdir: '$old_val' --> '$new_val'"
fi fi
# fix dependency_libs # fix dependency_libs
@ -81,7 +82,7 @@ for f in "$@"; do
if [ "$new_val" != "$old_val" ]; then if [ "$new_val" != "$old_val" ]; then
subst -p "s,^dependency_libs='[^']*'\$,dependency_libs='$new_val',g" "$f" subst -p "s,^dependency_libs='[^']*'\$,dependency_libs='$new_val',g" "$f"
echo "${fname#.}: dependency_libs: '$old_val' --> '$new_val'" >&2 echo "${fname#.}: dependency_libs: '$old_val' --> '$new_val'"
fi fi
done done

View File

@ -3,7 +3,7 @@
# fixup-pkgconfig - /usr/lib/pkgconfig/*.pc fixups. # fixup-pkgconfig - /usr/lib/pkgconfig/*.pc fixups.
# #
# $Id$ # $Id$
# Copyright (C) 2002 Dmitry V. Levin <ldv@altlinux.org> # Copyright (C) 2002,2003 Dmitry V. Levin <ldv@altlinux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -20,7 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
PROG="${0##*/}" . @RPMCONFIGDIR@/functions
ValidateBuildRoot
TMPFILE="$(mktemp -t "$PROG.XXXXXXXXXX")" TMPFILE="$(mktemp -t "$PROG.XXXXXXXXXX")"
@ -98,7 +99,7 @@ fix()
if [ "$new_val" != "$old_val" ]; then if [ "$new_val" != "$old_val" ]; then
subst -p "s|^Cflags: .*|Cflags: $new_val|g" -- "$f" || return 1 subst -p "s|^Cflags: .*|Cflags: $new_val|g" -- "$f" || return 1
echo "$fname: Cflags: '$old_val' --> '$new_val'" >&2 echo "$fname: Cflags: '$old_val' --> '$new_val'"
fi fi
# fix libs # fix libs
@ -137,14 +138,14 @@ fix()
if [ "$new_val" != "$old_val" ]; then if [ "$new_val" != "$old_val" ]; then
subst -p "s|^Libs: .*|Libs: $new_val|g" -- "$f" || return 1 subst -p "s|^Libs: .*|Libs: $new_val|g" -- "$f" || return 1
echo "$fname: Libs: '$old_val' --> '$new_val'" >&2 echo "$fname: Libs: '$old_val' --> '$new_val'"
fi fi
} }
rc=0 rc=0
for f in "$@"; do for f in "$@"; do
if [ ! -f "$f" ]; then if [ ! -f "$f" ]; then
echo "$PROG: $f: file unavailable" >&2 Info "$f: file unavailable"
rc=1 rc=1
continue continue
fi fi

View File

@ -18,16 +18,15 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# If using normal root, avoid changing anything. . @RPMCONFIGDIR@/functions
[ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] ValidateBuildRoot
file="$1" file="$1"
head -1 "$file" |grep -qs '^#%PAM' || exit 0 head -1 "$file" |grep -qs '^#%PAM' || exit 0
if [ -n "$PAM_NAME_SUFFIX" -a -z "${PAM_NAME_SUFFIX##%*}" ]; then if [ -n "$PAM_NAME_SUFFIX" -a -z "${PAM_NAME_SUFFIX##%*}" ]; then
echo "error: PAM_NAME_SUFFIX=$PAM_NAME_SUFFIX" >&2 Fatal "invalid PAM_NAME_SUFFIX=$PAM_NAME_SUFFIX"
exit 1
fi fi
echo "pam$PAM_NAME_SUFFIX(${file##*/})" echo "pam$PAM_NAME_SUFFIX(${file##*/})"

View File

@ -18,21 +18,19 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# If using normal root, avoid changing anything. . @RPMCONFIGDIR@/functions
[ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] ValidateBuildRoot
file="$1" file="$1"
head -1 "$file" |grep -qs '^#%PAM' || exit 0 head -1 "$file" |grep -qs '^#%PAM' || exit 0
if [ -n "$PAM_SO_SUFFIX" -a -z "${PAM_SO_SUFFIX##%*}" ]; then if [ -n "$PAM_SO_SUFFIX" -a -z "${PAM_SO_SUFFIX##%*}" ]; then
echo "error: PAM_SO_SUFFIX=$PAM_SO_SUFFIX" >&2 Fatal "invalid PAM_SO_SUFFIX=$PAM_SO_SUFFIX"
exit 1
fi fi
if [ -n "$PAM_NAME_SUFFIX" -a -z "${PAM_NAME_SUFFIX##%*}" ]; then if [ -n "$PAM_NAME_SUFFIX" -a -z "${PAM_NAME_SUFFIX##%*}" ]; then
echo "error: PAM_NAME_SUFFIX=$PAM_NAME_SUFFIX" >&2 Fatal "invalid PAM_NAME_SUFFIX=$PAM_NAME_SUFFIX"
exit 1
fi fi
# hack for "buildreq -bi". # hack for "buildreq -bi".

View File

@ -18,8 +18,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# If using normal root, avoid changing anything. . @RPMCONFIGDIR@/functions
[ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] ValidateBuildRoot
file="$1" file="$1"

View File

@ -18,10 +18,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
. @RPMCONFIGDIR@/functions
ValidateBuildRoot
. @RPMCONFIGDIR@/find-package . @RPMCONFIGDIR@/find-package
FIND_REQ="/bin/sh --rpm-requires" FIND_REQ="/bin/sh --rpm-requires"

View File

@ -3,7 +3,7 @@
# strip_files - strip files helper. # strip_files - strip files helper.
# #
# $Id$ # $Id$
# Copyright (C) 2000-2002 Dmitry V. Levin <ldv@altlinux.org> # Copyright (C) 2000-2003 Dmitry V. Levin <ldv@altlinux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -20,7 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
PROG="${0##*/}" . @RPMCONFIGDIR@/functions
ValidateBuildRoot
StripNote() StripNote()
{ {
@ -43,7 +44,7 @@ DoStrip()
rc=0 rc=0
for f in "$@"; do for f in "$@"; do
if [ ! -f "$f" ]; then if [ ! -f "$f" ]; then
echo "$PROG: $f: file unavailable" >&2 Info "$f: file unavailable"
rc=1 rc=1
continue continue
fi fi

View File

@ -20,14 +20,15 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
PROG="${0##*/}" . @RPMCONFIGDIR@/functions
ValidateBuildRoot
: ${RPM_VERIFY_ELF_SKIPLIST:=} : ${RPM_VERIFY_ELF_SKIPLIST:=}
rc=0 rc=0
for f in "$@"; do for f in "$@"; do
if [ ! -f "$f" ]; then if [ ! -f "$f" ]; then
echo "$PROG: $f: file unavailable" >&2 Info "$f: file unavailable"
rc=1 rc=1
continue continue
fi fi
@ -55,7 +56,7 @@ for f in "$@"; do
found= found=
for p in $RPM_BUILD_ROOT $RPM_BUILD_DIR $RPM_SOURCE_DIR; do for p in $RPM_BUILD_ROOT $RPM_BUILD_DIR $RPM_SOURCE_DIR; do
if printf %s "$rpath" |fgrep -qs "$p"; then if printf %s "$rpath" |fgrep -qs "$p"; then
echo "$f: RPATH entry contains \"$p\": $rpath" >&2 Info "$f: RPATH entry contains \"$p\": $rpath"
found=1 found=1
fi fi
done done
@ -65,7 +66,7 @@ for f in "$@"; do
fi fi
if printf %s "$rpath" |fgrep -qs :; then if printf %s "$rpath" |fgrep -qs :; then
echo "$f: RPATH entry contains \":\": $rpath" >&2 Info "$f: RPATH entry contains \":\": $rpath"
[ "$VERIFY_ELF_RPATH" = relaxed ] || rc=1 [ "$VERIFY_ELF_RPATH" = relaxed ] || rc=1
break break
fi fi
@ -74,7 +75,7 @@ for f in "$@"; do
break break
fi fi
echo "$f: RPATH entry found: $rpath" >&2 Info "$f: RPATH entry found: $rpath"
rc=1 rc=1
break break
done done
@ -86,7 +87,7 @@ for f in "$@"; do
if [ "$VERIFY_ELF_TEXTREL" = relaxed ]; then if [ "$VERIFY_ELF_TEXTREL" = relaxed ]; then
break break
fi fi
echo "$f: TEXTREL entry found: $textrel" >&2 Info "$f: TEXTREL entry found: $textrel"
rc=1 rc=1
break break
done done