#!/bin/sh
# Copyright 2007 Frederick Emmott <mail@fredemmott.co.uk>
# Distributed under the GNU General Public License, version 2,
# as published by the Free Software foundation, NOT any other
# version.

pkghelpers_fixup() {
	##### STRIP BINARIES #####
	find -type f | xargs file | grep ELF | cut -f1 -d: | xargs strip --strip-unneeded 2> /dev/null

	##### COMPRESS MAN PAGES #####
	if [ -d usr/man ]; then
		(
			cd usr/man
			find -type f -exec gzip -9 {} \;
			for deadlink in $(find -type l ! -iname "*.gz"); do
				ln -s $(readlink $deadlink).gz $deadlink.gz
				rm $deadlink
			done
		)
	fi

	##### COMPRESS INFO PAGES #####
	if [ -d usr/info ]; then
		rm -f usr/info/dir
		gzip -9 usr/info/*
	fi

	##### DELETE UNNECESSARY PERL DOCUMENTATION #####
	find . -name perllocal.pod | xargs rm -f
}
