void-packages/common/hooks/post-install/07-cleanup-timestamp-macros.sh
Jürgen Buchmüller 8ce51e70cf timestamp-macros: fix creation and add cleanup
As described in #3765
2016-03-07 09:46:34 +01:00

24 lines
943 B
Bash

# Remove leaked CFLAGS and CXXFLAGS parts which were defined
# by common/hooks/pre-configure/03-timestamp-macros.sh
# from shell scripts, perl scripts, package config files etc.
hook() {
local f mimetype
local strip=" -Wno-builtin-macro-redefined -include${XBPS_BUILDDIR}/\.xbps-.*/timestamp-macros\.h"
[ -n "$XBPS_USE_BUILD_MTIME" ] && return 0
[ -z "$SOURCE_DATE_EPOCH" ] && return 0
# Clean up shell scripts, perl files, pkgconfig files etc.
for f in $(grep -r -l -e "$strip" "$PKGDESTDIR" ); do
mimetype=$(file --mime-type "$f" | awk '{ print $2 }')
if [ "$mimetype" == "text/plain" -o "$mimetype" == "text/x-shellscript" ]; then
sed -i "$f" -e "s;$strip;;"
msg_warn "Cleaned up ${f#${PKGDESTDIR}} ...\n"
else
# Unhandled mime-type file contains the $strip string
# E.g. binaries containing the build environment as a string
msg_warn "Can't clean ${f#${PKGDESTDIR}} (mime-type: $mimetype) ...\n"
fi
done
}