#!/bin/sh
#
# rpmdev-wipetree
# Erases all files within the rpm build dir
#
# Author:  Warren Togami <warren@togami.com>
# License: GPL

# 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 rpmdev-setuptree 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
