2002-03-25 23:37:46 +03:00
#!/bin/sh -e
#
# brp-cleanup - cleanup buildroot.
#
2002-07-21 18:14:51 +04:00
# Copyright (C) 2000-2002 Dmitry V. Levin <ldv@altlinux.org>
2002-03-25 23:37:46 +03:00
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
PROG="${0##*/}"
2002-08-28 19:06:42 +04:00
RPM_CLEANUP_METHOD="${RPM_CLEANUP_METHOD## }"
RPM_CLEANUP_METHOD="${RPM_CLEANUP_METHOD%% }"
2002-07-21 17:48:37 +04:00
echo "Cleaning files in $RPM_BUILD_ROOT ($RPM_CLEANUP_METHOD)"
if [ "$RPM_CLEANUP_METHOD" = skip ]; then
exit 0
fi
2002-03-25 23:37:46 +03:00
# If using normal root, avoid changing anything.
2003-11-07 20:45:11 +03:00
if [ -z "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ]; then
2002-03-25 23:37:46 +03:00
echo "$PROG: non-/ \$RPM_BUILD_ROOT expected" >&2
exit 1
fi
cd "$RPM_BUILD_ROOT"
2002-07-21 17:48:37 +04:00
if [ "$RPM_CLEANUP_METHOD" = none ]; then
exit 0
fi
2002-09-27 17:41:26 +04:00
: ${RPM_CLEANUP_TOPDIR:=}
[ -d "$RPM_BUILD_ROOT$RPM_CLEANUP_TOPDIR" ] || exit 0
: ${RPM_CLEANUP_SKIPLIST:=}
export RPM_CLEANUP_SKIPLIST
2002-07-21 17:48:37 +04:00
if [ -n "$RPM_CLEANUP_METHOD" -a "$RPM_CLEANUP_METHOD" != auto ]; then
exec "$RPM_CLEANUP_METHOD"
fi
2002-09-27 17:41:26 +04:00
find .$RPM_CLEANUP_TOPDIR -type f \( \
2002-03-25 23:37:46 +03:00
-name '#*#' \
-o -name '*~' \
-o -name DEADJOE \
-o -name '*.orig' \
-o -name '*.rej' \
-o -name '*.bak' \
-o -name '.*.orig' \
-o -name '.*.rej' \
-o -name '.*.bak' \
-o -name .SUMS \
-o -name TAGS \
-o -name core \
-o \( -path '*/.deps/*' -a -name '*.P' \) \
2002-07-21 17:48:37 +04:00
\) -print0 |
xargs -r0 rm -vf --
2002-03-25 23:37:46 +03:00
2002-09-27 17:41:26 +04:00
find .$RPM_CLEANUP_TOPDIR -type d -name CVS -print0 |
2002-07-21 17:48:37 +04:00
xargs -r0 rm -vrf --
2002-03-25 23:37:46 +03:00
2003-05-26 01:01:24 +04:00
if cd ./etc/pam.d >/dev/null 2>&1; then
find -type f -mindepth 1 -maxdepth 1 -print0 |
xargs -r0 subst -p '
s,^\(#\?\)auth[[:space:]]\+,\1auth ,g
s,^\(#\?\)account[[:space:]]\+,\1account ,g
s,^\(#\?\)password[[:space:]]\+,\1password ,g
s,^\(#\?\)session[[:space:]]\+,\1session ,g
s,\([[:space:]]\)/lib/security/\(pam_\),\1\2,g
s,\([[:space:]]\)required[[:space:]]\+pam_stack.so[[:space:]]\+service=,\1include ,g
' --
fi
2002-09-27 17:41:26 +04:00
# All the rest is perl cleanup stuff.
2003-05-26 01:01:24 +04:00
cd ./usr/lib/perl5 >/dev/null 2>&1 || exit 0
2002-03-25 23:37:46 +03:00
2002-07-21 17:48:37 +04:00
find -type f -name .packlist -print0 |
xargs -r0 rm -vf --
2002-03-25 23:37:46 +03:00
2002-07-21 17:48:37 +04:00
find -type f -name \*.bs -size 0 -print0 |
xargs -r0 rm -vf --
2002-03-25 23:37:46 +03:00
f="$(find -type f -name \*.bs)"
if [ -n "$f" ]; then
echo "$PROG: non empty *.bs file(s) found:"
2003-11-07 20:45:11 +03:00
printf %s\\n "$f"
2002-03-25 23:37:46 +03:00
echo "$PROG: please contact packager"
exit 1
fi