summaryrefslogtreecommitdiff
blob: 0bc16bf20ca8609f4a72d3c4df27d78aaccb4934 (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/util-linux/util-linux-2.12r-r8.ebuild,v 1.3 2007/10/11 03:11:06 jer Exp $

inherit eutils flag-o-matic toolchain-funcs

OLD_CRYPT_VER=2.12i
LOOP_AES_VER=3.1f
DESCRIPTION="Various useful Linux utilities"
HOMEPAGE="http://www.kernel.org/pub/linux/utils/util-linux/"
SRC_URI="mirror://kernel/linux/utils/${PN}/${P}.tar.bz2
	old-crypt? (
		mirror://kernel/linux/utils/${PN}/${PN}-${OLD_CRYPT_VER}.tar.gz
		mirror://gentoo/util-linux-${OLD_CRYPT_VER}-cryptoapi-losetup.patch.bz2
	)
	crypt? ( http://loop-aes.sourceforge.net/loop-AES/loop-AES-v${LOOP_AES_VER}.tar.bz2 )"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc x86"
IUSE="crypt old-crypt nls static selinux perl"

RDEPEND=">=sys-libs/ncurses-5.2-r2
	>=sys-fs/e2fsprogs-1.34
	selinux? ( sys-libs/libselinux )
	crypt? ( app-crypt/hashalot )
	perl? ( dev-lang/perl )
	amd64? ( sys-apps/setarch )
	mips? ( sys-apps/setarch )
	ppc? ( sys-apps/setarch )
	ppc64? ( sys-apps/setarch )
	sparc? ( sys-apps/setarch )
	!sys-apps/more"
DEPEND="${RDEPEND}
	nls? ( sys-devel/gettext )
	virtual/os-headers"

OLD_CRYPT_P=${WORKDIR}/${PN}-${OLD_CRYPT_VER}

yesno() { useq $1 && echo yes || echo no; }

src_unpack() {
	unpack ${A}

	# Old crypt support
	if use old-crypt ; then
		cd "${OLD_CRYPT_P}"
		ewarn "You should update your system as USE=old-crypt"
		ewarn "support will be dropped in future versions."
		epatch "${WORKDIR}"/util-linux-${OLD_CRYPT_VER}-cryptoapi-losetup.patch
	fi

	cd "${S}"

	sed -i '/LDFLAGS.*-s/d' configure #191112

	# crypto support
	use crypt && epatch "${WORKDIR}"/loop-AES-v${LOOP_AES_VER}/${P}.diff

	# Fall back to cracklib if default words file doesnt exist #114416
	epatch "${FILESDIR}"/${PN}-2.12r-cracklib-words.patch

	# Fix rare failures with -j4 or higher
	epatch "${FILESDIR}"/${PN}-2.11z-parallel-make.patch

	# Fix -f usage with -a and in general
	epatch "${FILESDIR}"/${PN}-2.12q-more-fake-checks-v2.patch

	# Fix mtab updates with `mount --move /foo /bar` #104697
	epatch "${FILESDIR}"/${PN}-2.12q-update-mtab-when-moving.patch

	# Respect -n with -r and umount #98675
	epatch "${FILESDIR}"/${PN}-2.12q-umount-dont-write-mtab-with-remount.patch

	# A few fixes to beat update_mtab() into submission.
	epatch "${FILESDIR}"/${PN}-2.12q-update_mtab-fixes.patch

	# Use update_mtab() to avoid dups in mtab for 'mount -f'
	epatch "${FILESDIR}"/${PN}-2.12q-use-update_mtab-for-fake.patch

	# Fix unreadable df output when using devfs ... this check is kind of
	# a hack, but whatever, the output isnt critical at all :P
	[[ -e /dev/.devfsd ]] && epatch "${FILESDIR}"/no-symlink-resolve.patch

	# Add the O option to agetty to display DNS domainname in the issue
	# file, thanks to Marius Mauch <genone@genone.de>, bug #22275.
	#
	# NOTE:  Removing this will break future baselayout, so PLEASE
	#        consult with me before doing so.
	epatch "${FILESDIR}"/${PN}-2.11z-agetty-domainname-option.patch

	# Fix french translation typo #75693
	epatch "${FILESDIR}"/${PN}-2.12q-i18n-update.patch

	# Add NFS4 support (kernel 2.5/2.6)
	epatch "${FILESDIR}"/${PN}-2.12i-nfsv4.patch

	# ignore managed/kudzu options #70873
	epatch "${FILESDIR}"/${PN}-2.12i-ignore-managed.patch

	# swapon gets confused by symlinks in /dev #69162
	epatch "${FILESDIR}"/${PN}-2.12p-swapon-check-symlinks.patch

	# fix simple buffer overflow (from Debian)
	epatch "${FILESDIR}"/${PN}-2.12q-debian-10cfdisk.patch

	# don't build fdisk on m68k
	epatch "${FILESDIR}"/${PN}-2.12q-no-m68k-fdisk.patch

	# don't force umask to 022 #93671
	epatch "${FILESDIR}"/${PN}-2.12q-dont-umask.patch

	# fix cal display when using featureless terminals #112406
	epatch "${FILESDIR}"/${PN}-2.12r-cal-dumb-terminal.patch

	# Bug #108988 unable to always seek when omiting frame pointers
	epatch "${FILESDIR}"/${PN}-2.12r-fdisk-frame-pointers.patch

	# don't treat sparc/arm specially
	epatch "${FILESDIR}"/${PN}-2.12r-umount-no-special.patch

	# Patches from Fedora
	epatch "${FILESDIR}"/${PN}-2.12r-umount-nosysfs.patch

	# fix mips n32 (no llseek syscall)
	epatch "${FILESDIR}"/${PN}-2.12-mips-lseek.patch

	epatch "${FILESDIR}"/${PN}-2.13-setuid-checks.patch
	epatch "${FILESDIR}"/${PN}-2.12r-no-_syscall.patch #150852
	epatch "${FILESDIR}"/${PN}-2.12r-HAVE_asm_page_h.patch #168278
	use crypt && epatch "${FILESDIR}"/${PN}-2.12r-HAVE_asm_page_h-loop-aes.patch

	# Enable random features
	local mconfigs="MCONFIG"
	use old-crypt && mconfigs="${mconfigs} ${OLD_CRYPT_P}/MCONFIG"
	sed -i \
		-e "/^HAVE_SELINUX=/s:no:$(yesno selinux):" \
		-e "/^DISABLE_NLS=/s:no:$(yesno !nls):" \
		-e "/^HAVE_KILL=/s:no:yes:" \
		-e "/^HAVE_SLN=/s:no:yes:" \
		-e "/^HAVE_TSORT/s:no:yes:" \
		-e "s:-pipe -O2 \$(CPUOPT) -fomit-frame-pointer:${CFLAGS}:" \
		-e "s:CPU=.*:CPU=${CHOST%%-*}:" \
		-e "s:SUIDMODE=.*4755:SUIDMODE=4711:" \
		${mconfigs} || die "MCONFIG sed"
}

src_compile() {
	use static && append-ldflags -static
	export CC="$(tc-getCC)"

	econf || die "configure failed"
	emake || die "emake failed"

	cd partx
	has_version '>=sys-kernel/linux-headers-2.6' && \
	has_version '<sys-kernel/linux-headers-2.6.18' \
		&& append-flags -include linux/compiler.h
	emake CFLAGS="${CFLAGS}" || die "make partx failed"

	if use old-crypt ; then
		cd "${OLD_CRYPT_P}"
		econf || die "old configure failed"
		emake -C lib || die "old lib failed"
		emake -C mount losetup mount || die "old make failed"
	fi
}

src_install() {
	make install DESTDIR="${D}" || die "install failed"
	dosym ../man8/agetty.8 /usr/share/man/man1/getty.1
	dosbin partx/{addpart,delpart,partx} || die "dosbin"
	use perl || rm -f "${D}"/usr/bin/chkdupexe
	# required by autotools
	dosym /bin/arch /usr/bin/arch

	if use crypt || use old-crypt ; then
		newinitd "${FILESDIR}"/crypto-loop.initd crypto-loop
		newconfd "${FILESDIR}"/crypto-loop.confd crypto-loop
	fi

	# man-pages installs renice(1p) but util-linux does renice(8)
	dosym ../man8/renice.8 /usr/share/man/man1/renice.1
	# nfs-utils provides nfs(5) now
	rm "${D}"/usr/share/man/man5/nfs.5 || die

	dodoc HISTORY MAINTAINER README VERSION
	docinto examples
	dodoc example.files/*

	if use old-crypt ; then
		cd "${OLD_CRYPT_P}"/mount
		into /
		newbin mount mount-old-crypt || die
		newbin losetup losetup-old-crypt || die
		fperms 4711 /bin/{mount,losetup}-old-crypt
	fi
}

pkg_postinst() {
	if ! use old-crypt && use crypt ; then
		ewarn "This version of util-linux includes crypto support"
		ewarn "for loop-aes instead of the old cryptoapi."
		ewarn "If you need the older support, please re-emerge"
		ewarn "util-linux with USE=old-crypt.  This will create"
		ewarn "/sbin/mount-old-crypt and /sbin/losetup-old-crypt."
	fi
}