#!/bin/sh
#
# fedora-wipebuildtree
# Erases all files within the rpm build dir
#
# Author:  Warren Togami <warren@togami.com>
# License: GPL
# $Id: fedora-wipebuildtree,v 1.5 2005/02/05 22:52:38 scop Exp $

# Sanity Check: Forbid root user
if [ $(id -u) -eq 0 ]; then
    echo
    echo "ERROR: You should not be building RPMS as the superuser!"
    echo "Please use fedora-buildrpmtree as a normal user and build"
    echo "packages as that user.  If package building fails, then"
    echo "the package is improper and needs fixing."
    echo
    exit 255
fi

# Wipe RPM Build Directory clean
echo "Removing all build files..."
rm -rf $(rpm --eval "%{_builddir}")/*
rm -rf $(rpm --eval "%{_sourcedir}")/*
rm -rf $(rpm --eval "%{_srcrpmdir}")/*
rm -rf $(rpm --eval "%{_specdir}")/*
find $(rpm --eval "%{_rpmdir}") -name "*.rpm" | xargs rm -f
