summaryrefslogtreecommitdiff
blob: 0eff66bdffd989b4bcb1beb3bf47c8059c924f42 (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
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/busybox-0.60.5-r2.ebuild,v 1.7 2004/06/11 20:13:18 kugelfang Exp $

inherit flag-o-matic eutils

DESCRIPTION="Utilities for rescue and embedded systems"
HOMEPAGE="http://www.busybox.net/"
SRC_URI="http://www.busybox.net/downloads/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 arm -amd64 -alpha"
IUSE="static uclibc diet devfs"

DEPEND="virtual/glibc
	diet? ( dev-libs/dietlibc )
	>=sys-apps/sed-4"
RDEPEND="!static? (
		!diet? ( virtual/glibc )
		diet? ( dev-libs/dietlibc )
	)"

src_unpack() {
	unpack ${A}
	cp ${FILESDIR}/Config.h-${PV}-cd ${S}/Config.h
	# I did not include the msh patch since I don't know if it will
	# break stuff, I compile ash anyway, and it's in CVS

	if [ `use devfs` ]; then
		einfo "Disabling devfs in busybox"
		sed -i -e "s:#define.*BB_FEATURE_DEVFS://#define BB_FEATURE_DEVFS:g" \
			 ${S}/Config.h
	fi

	# Add support for dietlibc - solar@gentoo.org
	if [ `use diet` ]; then
		[ "${PV}" == "0.60.5" ] &&
		sed -i \
			-e "s://#define.*BB_TTY:#define BB_TTY:g" \
			-e "s://#define.*BB_WATCH:#define BB_WATCH:g" \
			-e "s:BB_TRACEROUTE:BB_TRACEROUTE_${RANDOM}:g" \
			${S}/Config.h
		[ -f ${FILESDIR}/${PN}-${PV}-dietlibc.diff ] &&
			epatch ${FILESDIR}/${PN}-${PV}-dietlibc.diff ||
			ewarn "No dietlibc patch found for ${PN}-${PV}"
	fi
}

src_compile() {
	local myconf

	use static && myconf="${myconf} DOSTATIC=true"
	if [ `use uclibc` ]; then
		myconf="${myconf} \
			CC=/usr/i386-linux-uclibc/bin/i386-uclibc-gcc \
			USE_SYSTEM_PWD=false"
		unset CFLAGS
	fi

	if [ `use diet` ] ; then
		append-flags -D_BSD_SOURCE
		emake CC="diet ${CC}" CLFAGS="${CFLAGS}" ${myconf} ||
			die "Failed to make diet ${PN}"
	else
		emake ${myconf} || die
	fi
}

src_install() {
	into /
	dobin busybox
	into /usr
	dodoc AUTHORS Changelog LICENSE README TODO

	cd docs
	doman *.1
	docinto txt
	dodoc *.txt
	docinto pod
	dodoc *.pod
	dohtml *.html
	dohtml *.sgml

	cd ../scripts
	docinto scripts
	dodoc inittab
	dodoc depmod.pl
}

pkg_postinst() {
	einfo ""
	einfo "Edit /usr/portage/sys-apps/busybox/files/Config.h-${PV}-cd and"
	einfo "re-emerge if you need to add/remove functionality in "
	einfo "BusyBox."
	einfo ""
}