summaryrefslogtreecommitdiff
blob: 863cd6802de126f5349f65bf9d7838435067addc (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/coreutils-darwin/coreutils-darwin-5.3.0.ebuild,v 1.7 2005/06/26 03:44:59 j4rg0n Exp $

inherit eutils

DESCRIPTION="Standard GNU file utilities, text utilities, and shell utilities missing from Darwin."
HOMEPAGE="http://www.gnu.org/software/coreutils/"
SRC_URI="mirror://gentoo/coreutils-5.3.0.tar.bz2
	http://meyering.free.fr/coreutils/coreutils-5.3.0.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~ppc-macos"
IUSE="nls build static"
PROVIDES="virtual/coreutils"

DEPEND=">=sys-apps/portage-2.0.49
	sys-devel/automake
	sys-devel/autoconf
	sys-apps/help2man
	nls? ( sys-devel/gettext )"

S=${WORKDIR}/coreutils-${PV}

# Existing utils

EXISTINGUSR="basename chgrp cksum comm cut dirname \
	du env expand false fmt fold groups head install id join \
	logname mkfifo nice nohup od paste pr printenv \
	printf sort split stat su sum tail tee touch tr true \
	tsort tty uname unexpand uniq uptime users wc who whoami yes"
EXISTINGBIN="cat chmod cp date dd df echo expr ln ls mkdir \
			 mv pwd rm rmdir sleep stty sync test"
EXISTINGUSBIN="chown chroot"
EXISTINGSBIN="mknod"
DONTLINK="[ kill hostname"
TENFOURBIN="link unlink csplit nl"
TENFOURUSBIN="pathchk readlink"

src_compile() {
	cd ${S}

	econf \
		--bindir=/bin \
		`use_enable nls` || die

	if use static; then
		append-ldflags -static
	fi
	emake || die
}

src_install() {

	# Install the utils
	cd ${S}
	make install infodir=${D}usr/share/info mandir=${D}usr/share/man bindir=${D}bin || die

	cd ${D}
	dodir /usr/bin
	rm -rf usr/lib

	cd ${D}/bin
	if [ "$MACOSX_DEPLOYMENT_TARGET" == "10.4" ]; then
		rm ${TENFOURBIN} ${TENFOURUSBIN}
	fi

	rm ${EXISTINGBIN} ${EXISTINGUSR} ${EXISTINGUSBIN} ${EXISTINGSBIN} ${DONTLINK}

	# Move the non-critical pacakges to /usr/bin
	if [ "$MACOSX_DEPLOYMENT_TARGET" != "10.4" ]; then
		mv csplit nl pathchk ${D}usr/bin
	fi
	mv factor md5sum pinky sha1sum tac ${D}usr/bin

	# Link binaries
	cd ${D}/usr/bin
	for BINS in `ls ${D}/bin` ; do
		dosym ../../bin/${BINS} /usr/bin/${BINS}
	done

	for BINS in ${EXISTINGUSR} ; do
		dosym /usr/bin/${BINS} /bin/${BINS}
	done

	for BINS in ${EXISTINGBIN} ; do
		dosym /bin/${BINS} /usr/bin/${BINS}
	done

	for BINS in ${EXISTINGUSBIN} ; do
		dosym /usr/sbin/${BINS} /bin/${BINS}
		dosym /usr/sbin/${BINS} /usr/bin/${BINS}
	done

	for BINS in ${EXISTINGSBIN} ; do
		dosym /sbin/${BINS} /bin/${BINS}
		dosym /sbin/${BINS} /usr/bin/${BINS}
	done

	# Remove the redundant man pages
	cd ${D}/usr/share/man/man1
	for BINS in ${EXISTINGBIN} ${EXISTINGUSR} ${EXISTINGUSBIN} ${EXISTINGSBIN} ${DONTLINK}; do
		if [ -f ${BINS}.1 ]; then
			rm ${BINS}.1
		fi
	done

	if [ "$MACOSX_DEPLOYMENT_TARGET" == "10.4" ]; then
		for BINS in ${TENFOURBIN} ${TENFOURUSBIN}; do
			if [ -f ${BINS}.1 ]; then
				rm ${BINS}.1
			fi
		done
	fi

	if ! use build
	then
		cd ${S}
		dodoc AUTHORS ChangeLog* NEWS README* THANKS TODO
	else
		rm -rf ${D}/usr/share
	fi
}

pkg_postrm() {
	# Unlink binaries
	for BINS in ${EXISTINGUSR} ; do
		rm /bin/${BINS}
	done

	for BINS in ${EXISTINGBIN} ; do
		rm /usr/bin/${BINS}
	done

	for BINS in ${EXISTINGUSBIN} ; do
		rm /bin/${BINS}
		rm /usr/bin/${BINS}
	done

	for BINS in ${EXISTINGSBIN} ; do
		rm /bin/${BINS}
		rm /usr/bin/${BINS}
	done
}