summaryrefslogtreecommitdiff
blob: 34490b3ecbe795ccdaf5d11d49a4570913c00936 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright 2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/profiles/uclibc/profile.bashrc,v 1.5 2005/04/18 19:34:43 solar Exp $

#
# FEATURES="distclean"
# This feature removes unneeded SRC_URI distfiles in the postinst ebuild phase.
# This is useful with ramfs/tmpfs and smaller media such as USB sticks.
#


eecho() {
	[ "$NOCOLOR" = "false" ] && echo -ne '\e[1;34m>\e[1;36m>\e[1;35m>\e[0m ' || echo -n ">>> "
	echo "$*"
}

package_clean_distdir() {
	local a x
	for a in ${FEATURES} ; do 
		if [ "$a" = "distclean" ]; then
			for x in ${SRC_URI}; do
			x=$(basename $x)
				if [[ -w $DISTDIR/$x ]]; then
					size="$(ls -lh ${DISTDIR}/${x} | awk '{print $5}')"
					eecho "Auto removing ${x} to save ${size}"
					rm ${DISTDIR}/${x}
				fi
			done
		fi
	done
}

if [[ $EBUILD_PHASE != "" ]]; then
	PATH="/sbin:/usr/sbin:/usr/lib/portage/bin:/bin:/usr/bin:${ROOTPATH}"
	case "${EBUILD_PHASE}" in
		preinst)
			[[ $ROOT != "" ]] && [[ $ROOT != "/" ]] \
				&& [ -r /etc/portage/root_install_mask ] \
				&& INSTALL_MASK="${INSTALL_MASK} $(< /etc/portage/root_install_mask)"
			;;
		postinst)
			package_clean_distdir
		;;
		# try to stay quiet in depend.
		depend) : ;;
		prerm|postrm|clean) : ;;
		setup|unpack|postinst|compile|*) : ;;
	esac
fi

# Example of per package env variables
# Searches and break in the flat text files of
#	pkgname-pkgver-pkgrevision 
#	pkgname-pkgver 
#	pkgname

#for conf in ${PN}-${PV}-${PR} ${PN}-${PV} ${PN}; do
#	if [[ -r /etc/portage/env/$CATEGORY/${conf} ]]; then
#		. /etc/portage/env/$CATEGORY/${conf}
#		break
#	fi
#done