From ebc53cf631f1443bff3f66c5558604d60a2e3dd6 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sun, 9 Nov 2003 16:47:45 +0000 Subject: [PATCH] use functions --- ...just_libraries => brp-adjust_libraries.in} | 11 +++------- scripts/brp-alt.in | 1 - ...mpile_python => brp-bytecompile_python.in} | 11 +++------- scripts/{brp-cleanup => brp-cleanup.in} | 21 ++++++------------- scripts/brp-compress.in | 1 - scripts/{brp-fix-perms => brp-fix-perms.in} | 14 +++++-------- scripts/brp-fixup.in | 1 - scripts/brp-strip.in | 3 ++- scripts/brp-verify_elf.in | 1 - scripts/{check-files => check-files.in} | 6 +++--- scripts/compress_files.in | 1 + scripts/{find-lang => find-lang.in} | 9 ++------ scripts/{find-package => find-package.in} | 6 +++--- .../{fixup-binconfig => fixup-binconfig.in} | 13 ++++++------ scripts/{fixup-libtool => fixup-libtool.in} | 9 ++++---- .../{fixup-pkgconfig => fixup-pkgconfig.in} | 11 +++++----- scripts/{pam.prov => pam.prov.in} | 7 +++---- scripts/{pam.req => pam.req.in} | 10 ++++----- scripts/{shell.prov => shell.prov.in} | 4 ++-- scripts/shell.req.in | 4 ---- scripts/{strip_files => strip_files.in} | 7 ++++--- scripts/{verify-elf => verify-elf.in} | 13 ++++++------ 22 files changed, 66 insertions(+), 98 deletions(-) rename scripts/{brp-adjust_libraries => brp-adjust_libraries.in} (79%) rename scripts/{brp-bytecompile_python => brp-bytecompile_python.in} (82%) rename scripts/{brp-cleanup => brp-cleanup.in} (87%) rename scripts/{brp-fix-perms => brp-fix-perms.in} (78%) rename scripts/{check-files => check-files.in} (88%) rename scripts/{find-lang => find-lang.in} (98%) rename scripts/{find-package => find-package.in} (95%) rename scripts/{fixup-binconfig => fixup-binconfig.in} (96%) rename scripts/{fixup-libtool => fixup-libtool.in} (91%) rename scripts/{fixup-pkgconfig => fixup-pkgconfig.in} (94%) rename scripts/{pam.prov => pam.prov.in} (85%) rename scripts/{pam.req => pam.req.in} (90%) rename scripts/{shell.prov => shell.prov.in} (90%) rename scripts/{strip_files => strip_files.in} (93%) rename scripts/{verify-elf => verify-elf.in} (88%) diff --git a/scripts/brp-adjust_libraries b/scripts/brp-adjust_libraries.in similarity index 79% rename from scripts/brp-adjust_libraries rename to scripts/brp-adjust_libraries.in index 6846649..efcb1b5 100755 --- a/scripts/brp-adjust_libraries +++ b/scripts/brp-adjust_libraries.in @@ -3,7 +3,7 @@ # brp-adjust_libraries - update symbolic links to shared libraries. # # $Id$ -# Copyright (C) 2000 Dmitry V. Levin +# Copyright (C) 2000,2003 Dmitry V. Levin # # 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 @@ -20,13 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -PROG="${0##*/}" - -# 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 +. @RPMCONFIGDIR@/functions +ValidateBuildRoot cd "$RPM_BUILD_ROOT" diff --git a/scripts/brp-alt.in b/scripts/brp-alt.in index 9648788..50fd0cc 100755 --- a/scripts/brp-alt.in +++ b/scripts/brp-alt.in @@ -22,7 +22,6 @@ # . @RPMCONFIGDIR@/functions - ValidateBuildRoot cd "$RPM_BUILD_ROOT" diff --git a/scripts/brp-bytecompile_python b/scripts/brp-bytecompile_python.in similarity index 82% rename from scripts/brp-bytecompile_python rename to scripts/brp-bytecompile_python.in index b9708c3..249a189 100755 --- a/scripts/brp-bytecompile_python +++ b/scripts/brp-bytecompile_python.in @@ -3,7 +3,7 @@ # brp-bytecompile_python - compile python modules. # # $Id$ -# Copyright (C) 2000 Dmitry V. Levin +# Copyright (C) 2000,2003 Dmitry V. Levin # # 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 @@ -20,13 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -PROG="${0##*/}" - -# 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 +. @RPMCONFIGDIR@/functions +ValidateBuildRoot cd "$RPM_BUILD_ROOT" diff --git a/scripts/brp-cleanup b/scripts/brp-cleanup.in similarity index 87% rename from scripts/brp-cleanup rename to scripts/brp-cleanup.in index 126c606..488a5fd 100755 --- a/scripts/brp-cleanup +++ b/scripts/brp-cleanup.in @@ -3,7 +3,7 @@ # brp-cleanup - cleanup buildroot. # # $Id$ -# Copyright (C) 2000-2002 Dmitry V. Levin +# Copyright (C) 2000-2003 Dmitry V. Levin # # 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 @@ -20,25 +20,16 @@ # 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%% }" echo "Cleaning files in $RPM_BUILD_ROOT ($RPM_CLEANUP_METHOD)" -if [ "$RPM_CLEANUP_METHOD" = skip ]; 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 +if [ "$RPM_CLEANUP_METHOD" = skip -o "$RPM_CLEANUP_METHOD" = none ]; then exit 0 fi diff --git a/scripts/brp-compress.in b/scripts/brp-compress.in index 9ccd32f..5af6790 100755 --- a/scripts/brp-compress.in +++ b/scripts/brp-compress.in @@ -21,7 +21,6 @@ # . @RPMCONFIGDIR@/functions - ValidateBuildRoot cd "$RPM_BUILD_ROOT" || exit diff --git a/scripts/brp-fix-perms b/scripts/brp-fix-perms.in similarity index 78% rename from scripts/brp-fix-perms rename to scripts/brp-fix-perms.in index 3acc2df..64e4d8a 100755 --- a/scripts/brp-fix-perms +++ b/scripts/brp-fix-perms.in @@ -3,7 +3,7 @@ # brp-fix-perms - try to fix filesystem permissions. # # $Id$ -# Copyright (C) 2001,2002 Dmitry V. Levin +# Copyright (C) 2001-2003 Dmitry V. Levin # # 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 @@ -20,13 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -PROG="${0##*/}" - -# 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 +. @RPMCONFIGDIR@/functions +ValidateBuildRoot cd "$RPM_BUILD_ROOT" @@ -37,7 +32,8 @@ done # Following objects should not be group/world writable. 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 # Following files should not be group/world readable. diff --git a/scripts/brp-fixup.in b/scripts/brp-fixup.in index 9071d21..c56e631 100755 --- a/scripts/brp-fixup.in +++ b/scripts/brp-fixup.in @@ -21,7 +21,6 @@ # . @RPMCONFIGDIR@/functions - ValidateBuildRoot cd "$RPM_BUILD_ROOT" diff --git a/scripts/brp-strip.in b/scripts/brp-strip.in index 8894ff7..132f480 100755 --- a/scripts/brp-strip.in +++ b/scripts/brp-strip.in @@ -4,7 +4,7 @@ # Inspired by brp-strip script from RPM source code. # # $Id$ -# Copyright (C) 2000 Dmitry V. Levin +# Copyright (C) 2000,2003 Dmitry V. Levin # # 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 @@ -22,6 +22,7 @@ # . @RPMCONFIGDIR@/functions +ValidateBuildRoot Usage() { diff --git a/scripts/brp-verify_elf.in b/scripts/brp-verify_elf.in index 38d07ab..e4cf4da 100755 --- a/scripts/brp-verify_elf.in +++ b/scripts/brp-verify_elf.in @@ -21,7 +21,6 @@ # . @RPMCONFIGDIR@/functions - ValidateBuildRoot cd "$RPM_BUILD_ROOT" diff --git a/scripts/check-files b/scripts/check-files.in similarity index 88% rename from scripts/check-files rename to scripts/check-files.in index 7ad1edf..c2f665c 100755 --- a/scripts/check-files +++ b/scripts/check-files.in @@ -20,8 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# If using normal root, avoid changing anything. -[ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] +. @RPMCONFIGDIR@/functions +ValidateBuildRoot cd "$RPM_BUILD_ROOT" @@ -36,7 +36,7 @@ exit_handler() trap exit_handler SIGHUP SIGINT SIGQUIT SIGTERM EXIT -WORKDIR="$(mktemp -dt check-files.XXXXXXXXXX)" +WORKDIR="$(mktemp -dt "$PROG.XXXXXXXXXX")" export LC_ALL=C diff --git a/scripts/compress_files.in b/scripts/compress_files.in index 63d7a31..d4b0ac4 100755 --- a/scripts/compress_files.in +++ b/scripts/compress_files.in @@ -21,6 +21,7 @@ # . @RPMCONFIGDIR@/functions +ValidateBuildRoot RPM_COMPRESS_METHOD="${RPM_COMPRESS_METHOD## }" RPM_COMPRESS_METHOD="${RPM_COMPRESS_METHOD%% }" diff --git a/scripts/find-lang b/scripts/find-lang.in similarity index 98% rename from scripts/find-lang rename to scripts/find-lang.in index 88e12f2..54acc6b 100755 --- a/scripts/find-lang +++ b/scripts/find-lang.in @@ -21,13 +21,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -PROG="${0##*/}" - -Fatal() -{ - echo "${0##*/}: $*" >&2 - exit 1 -} +. @RPMCONFIGDIR@/functions +ValidateBuildRoot Usage() { diff --git a/scripts/find-package b/scripts/find-package.in similarity index 95% rename from scripts/find-package rename to scripts/find-package.in index cdc25e0..ad2c47e 100755 --- a/scripts/find-package +++ b/scripts/find-package.in @@ -18,8 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# If using normal root, avoid changing anything. -[ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] +. @RPMCONFIGDIR@/functions +ValidateBuildRoot FindPackage() { @@ -34,7 +34,7 @@ FindPackage() # Does it start with buildroot? if [ -z "${r##$RPM_BUILD_ROOT*}" ]; then - echo "$f: invalid dependence: $r" >&2 + Info "$f: invalid dependence: $r" return 1 fi diff --git a/scripts/fixup-binconfig b/scripts/fixup-binconfig.in similarity index 96% rename from scripts/fixup-binconfig rename to scripts/fixup-binconfig.in index af55be7..d62144c 100755 --- a/scripts/fixup-binconfig +++ b/scripts/fixup-binconfig.in @@ -20,7 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -PROG="${0##*/}" +. @RPMCONFIGDIR@/functions +ValidateBuildRoot WORKDIR="$(mktemp -dt "$PROG.XXXXXXXXXX")" TMPFILE="$WORKDIR/tmp" @@ -117,8 +118,8 @@ fix() fi if ! cmp -s "$f_new" "$f"; then - echo "$fname:" >&2 - diff "$f" "$f_new" >&2 ||: + echo "$fname:" + diff "$f" "$f_new" ||: cat "$f_new" >"$f" || return 1 fi @@ -162,8 +163,8 @@ fix() fi if ! cmp -s "$f_new" "$f"; then - echo "$fname:" >&2 - diff "$f" "$f_new" >&2 ||: + echo "$fname:" + diff "$f" "$f_new" ||: cat "$f_new" >"$f" || return 1 fi } @@ -171,7 +172,7 @@ fix() rc=0 for f in "$@"; do if [ ! -f "$f" ]; then - echo "$PROG: $f: file unavailable" >&2 + Info "$f: file unavailable" rc=1 continue fi diff --git a/scripts/fixup-libtool b/scripts/fixup-libtool.in similarity index 91% rename from scripts/fixup-libtool rename to scripts/fixup-libtool.in index 7e26c9e..a21eef1 100755 --- a/scripts/fixup-libtool +++ b/scripts/fixup-libtool.in @@ -20,14 +20,15 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -PROG="${0##*/}" +. @RPMCONFIGDIR@/functions +ValidateBuildRoot : ${RPM_FIXUP_SKIPLIST:=} rc=0 for f in "$@"; do if [ ! -f "$f" ]; then - echo "$PROG: $f: file unavailable" >&2 + Info "$f: file unavailable" rc=1 continue fi @@ -50,7 +51,7 @@ for f in "$@"; do if [ "$new_val" != "$old_val" ]; then 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 # fix dependency_libs @@ -81,7 +82,7 @@ for f in "$@"; do if [ "$new_val" != "$old_val" ]; then 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 done diff --git a/scripts/fixup-pkgconfig b/scripts/fixup-pkgconfig.in similarity index 94% rename from scripts/fixup-pkgconfig rename to scripts/fixup-pkgconfig.in index 528e19e..267ff7f 100755 --- a/scripts/fixup-pkgconfig +++ b/scripts/fixup-pkgconfig.in @@ -3,7 +3,7 @@ # fixup-pkgconfig - /usr/lib/pkgconfig/*.pc fixups. # # $Id$ -# Copyright (C) 2002 Dmitry V. Levin +# Copyright (C) 2002,2003 Dmitry V. Levin # # 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 @@ -20,7 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -PROG="${0##*/}" +. @RPMCONFIGDIR@/functions +ValidateBuildRoot TMPFILE="$(mktemp -t "$PROG.XXXXXXXXXX")" @@ -98,7 +99,7 @@ fix() if [ "$new_val" != "$old_val" ]; then 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 # fix libs @@ -137,14 +138,14 @@ fix() if [ "$new_val" != "$old_val" ]; then 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 } rc=0 for f in "$@"; do if [ ! -f "$f" ]; then - echo "$PROG: $f: file unavailable" >&2 + Info "$f: file unavailable" rc=1 continue fi diff --git a/scripts/pam.prov b/scripts/pam.prov.in similarity index 85% rename from scripts/pam.prov rename to scripts/pam.prov.in index 0b7905a..d41821b 100755 --- a/scripts/pam.prov +++ b/scripts/pam.prov.in @@ -18,16 +18,15 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# If using normal root, avoid changing anything. -[ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] +. @RPMCONFIGDIR@/functions +ValidateBuildRoot file="$1" head -1 "$file" |grep -qs '^#%PAM' || exit 0 if [ -n "$PAM_NAME_SUFFIX" -a -z "${PAM_NAME_SUFFIX##%*}" ]; then - echo "error: PAM_NAME_SUFFIX=$PAM_NAME_SUFFIX" >&2 - exit 1 + Fatal "invalid PAM_NAME_SUFFIX=$PAM_NAME_SUFFIX" fi echo "pam$PAM_NAME_SUFFIX(${file##*/})" diff --git a/scripts/pam.req b/scripts/pam.req.in similarity index 90% rename from scripts/pam.req rename to scripts/pam.req.in index cded519..6780aab 100755 --- a/scripts/pam.req +++ b/scripts/pam.req.in @@ -18,21 +18,19 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# If using normal root, avoid changing anything. -[ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] +. @RPMCONFIGDIR@/functions +ValidateBuildRoot file="$1" head -1 "$file" |grep -qs '^#%PAM' || exit 0 if [ -n "$PAM_SO_SUFFIX" -a -z "${PAM_SO_SUFFIX##%*}" ]; then - echo "error: PAM_SO_SUFFIX=$PAM_SO_SUFFIX" >&2 - exit 1 + Fatal "invalid PAM_SO_SUFFIX=$PAM_SO_SUFFIX" fi if [ -n "$PAM_NAME_SUFFIX" -a -z "${PAM_NAME_SUFFIX##%*}" ]; then - echo "error: PAM_NAME_SUFFIX=$PAM_NAME_SUFFIX" >&2 - exit 1 + Fatal "invalid PAM_NAME_SUFFIX=$PAM_NAME_SUFFIX" fi # hack for "buildreq -bi". diff --git a/scripts/shell.prov b/scripts/shell.prov.in similarity index 90% rename from scripts/shell.prov rename to scripts/shell.prov.in index 2d1edfe..66a7385 100755 --- a/scripts/shell.prov +++ b/scripts/shell.prov.in @@ -18,8 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# If using normal root, avoid changing anything. -[ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] +. @RPMCONFIGDIR@/functions +ValidateBuildRoot file="$1" diff --git a/scripts/shell.req.in b/scripts/shell.req.in index 828f0c4..aa3e666 100755 --- a/scripts/shell.req.in +++ b/scripts/shell.req.in @@ -18,10 +18,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -. @RPMCONFIGDIR@/functions - -ValidateBuildRoot - . @RPMCONFIGDIR@/find-package FIND_REQ="/bin/sh --rpm-requires" diff --git a/scripts/strip_files b/scripts/strip_files.in similarity index 93% rename from scripts/strip_files rename to scripts/strip_files.in index 28bc990..56aedc9 100755 --- a/scripts/strip_files +++ b/scripts/strip_files.in @@ -3,7 +3,7 @@ # strip_files - strip files helper. # # $Id$ -# Copyright (C) 2000-2002 Dmitry V. Levin +# Copyright (C) 2000-2003 Dmitry V. Levin # # 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 @@ -20,7 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -PROG="${0##*/}" +. @RPMCONFIGDIR@/functions +ValidateBuildRoot StripNote() { @@ -43,7 +44,7 @@ DoStrip() rc=0 for f in "$@"; do if [ ! -f "$f" ]; then - echo "$PROG: $f: file unavailable" >&2 + Info "$f: file unavailable" rc=1 continue fi diff --git a/scripts/verify-elf b/scripts/verify-elf.in similarity index 88% rename from scripts/verify-elf rename to scripts/verify-elf.in index 45d915d..157b57c 100755 --- a/scripts/verify-elf +++ b/scripts/verify-elf.in @@ -20,14 +20,15 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -PROG="${0##*/}" +. @RPMCONFIGDIR@/functions +ValidateBuildRoot : ${RPM_VERIFY_ELF_SKIPLIST:=} rc=0 for f in "$@"; do if [ ! -f "$f" ]; then - echo "$PROG: $f: file unavailable" >&2 + Info "$f: file unavailable" rc=1 continue fi @@ -55,7 +56,7 @@ for f in "$@"; do found= for p in $RPM_BUILD_ROOT $RPM_BUILD_DIR $RPM_SOURCE_DIR; do 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 fi done @@ -65,7 +66,7 @@ for f in "$@"; do fi 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 break fi @@ -74,7 +75,7 @@ for f in "$@"; do break fi - echo "$f: RPATH entry found: $rpath" >&2 + Info "$f: RPATH entry found: $rpath" rc=1 break done @@ -86,7 +87,7 @@ for f in "$@"; do if [ "$VERIFY_ELF_TEXTREL" = relaxed ]; then break fi - echo "$f: TEXTREL entry found: $textrel" >&2 + Info "$f: TEXTREL entry found: $textrel" rc=1 break done