summaryrefslogtreecommitdiff
blob: c1e8031fa7ff83bc4caf293cccc52b9664e732f7 (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
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# Maintainer: Donny Davies <woodchip@gentoo.org>
# $Header: /var/cvsroot/gentoo-x86/net-fs/samba/samba-2.2.3a.ebuild,v 1.1 2002/03/05 03:04:54 woodchip Exp $

DESCRIPTION="SAMBA is a suite of SMB and CIFS client/server programs for UNIX"
HOMEPAGE="http://samba.org http://www.amherst.edu/~bbstone/howto/samba.html"

S=${WORKDIR}/${P}
SRC_URI="http://us1.samba.org/samba/ftp/${P}.tar.gz
	http://www.amherst.edu/~bbstone/recycle_bin/${PV/a/}/loadparm.c.patch
	http://www.amherst.edu/~bbstone/recycle_bin/${PV/a/}/proto.h.patch
	http://www.amherst.edu/~bbstone/recycle_bin/${PV/a/}/reply.c.patch"

RDEPEND="virtual/glibc
	>=sys-libs/pam-0.72
	acl? ( sys-apps/acl )
	cups? ( net-print/cups )"
	# needs testing -- ssl? ( >=dev-libs/openssl-0.9.6 )
DEPEND="${RDEPEND}
	sys-devel/autoconf
	tcpd? ( >=sys-apps/tcp-wrappers-7.6 )"

src_unpack() {

	unpack ${P}.tar.gz ; cd ${S}
	use afs && ( patch -p0 < ${FILESDIR}/samba-2.2.1a-afs.diff || die )
	patch -p0 < ${FILESDIR}/samba-2.2.2-smbmount.diff || die
	patch -p1 < ${FILESDIR}/samba-2.2.3a-pam_smbpass.diff || die
	patch -p1 < ${FILESDIR}/samba-2.2.3a-cli_spoolss_notify.diff || die

	# network recycle bin must be enabled in your smb.conf per share
	cd ${S}/source
	patch -p0 < ${DISTDIR}/loadparm.c.patch || die
	patch -p0 < ${DISTDIR}/proto.h.patch || die
	patch -p0 < ${DISTDIR}/reply.c.patch || die

	# makes cups not absolutely required
	if [ ! "`use cups`" ] ; then
		cd ${S}/source
		cp configure.in configure.in.orig
		sed -e "s:AC_CHECK_LIB(cups,httpConnect)::" configure.in.orig > configure.in
	fi

	# fix kerberos include file collision
	cd ${S}/source/include
	mv profile.h smbprofile.h
	sed -e "s:profile\.h:smbprofile.h:" includes.h > includes.h.new
	mv includes.h.new includes.h

	cd ${S}/source
	autoconf || die
}

src_compile() {

	local myconf
	use afs && myconf="${myconf} --with-afs"
	use acl && myconf="${myconf} --with-acl-support"
	# ssl needs testing...
	myconf="${myconf} --without-ssl"

	export CFLAGS="${CFLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
	cd ${S}/source
	./configure \
		--prefix=/usr \
		--libdir=/etc/smb \
		--sbindir=/usr/sbin \
		--sysconfdir=/etc/smb \
		--localstatedir=/var/log \
		--with-lockdir=/var/run/smb \
		--with-mandir=/usr/share/man \
		--with-swatdir=/usr/share/swat \
		--with-privatedir=/etc/smb/private \
		--with-pam --with-pam_smbpass \
		--without-sambabook \
		--without-automount \
		--without-spinlocks \
		--with-netatalk \
		--with-smbmount \
		--with-profile \
		--with-quotas \
		--with-syslog \
		--with-msdfs \
		--with-utmp \
		--with-vfs \
		--host=${CHOST} ${myconf} || die "bad ./configure"

	emake || die "compile problem"
}

src_install() {

	cd ${S}/source
	dodir /sbin /etc/smb /usr/share/swat /var/log /var/run/smb /lib/security

	make install \
		prefix=${D}/usr \
		BASEDIR=${D}/usr \
		LIBDIR=${D}/etc/smb \
		VARDIR=${D}/var/log \
		LOCKDIR=${D}/var/lock \
		SBINDIR=${D}/usr/sbin \
		MANDIR=${D}/usr/share/man \
		SWATDIR=${D}/usr/share/swat \
		PRIVATEDIR=${D}/etc/smb/private || die

	# we specified PRIVATEDIR=/etc/smb/private
	rm -rf ${D}/usr/private
	diropts -m 0700 ; dodir /etc/smb/private

	# link /usr/bin/smbmount to /sbin/mount.smbfs which allows it
	# to work transparently with standard 'mount' command
	dosym /usr/bin/smbmount /sbin/mount.smbfs

	# handy scripts for user management
	cd ${S}/source/script
	exeinto /usr/sbin
	doexe convert_smbpasswd mknissmbpasswd.sh mknissmbpwdtbl.sh mksmbpasswd.sh

	# place this correctly
	mv ${D}/usr/bin/pam_smbpass.so ${D}/lib/security/pam_smbpass.so

	# make the smb backend symlink for smb printing support with cups
	if [ "`use cups`" ] ; then
		dodir /usr/lib/cups/backend
		dosym /usr/bin/smbspool /usr/lib/cups/backend/smb
	fi

	# too many docs to sort through -- install them all :)
	cd ${S}
	dodoc COPYING Manifest README Roadmap WHATSNEW.txt
	docinto full_docs ; cp -a docs/* ${D}/usr/share/doc/${PF}/full_docs
	docinto examples ; cp -a examples/* ${D}/usr/share/doc/${PF}/examples
	prepalldocs

	insinto /etc/pam.d ; newins ${FILESDIR}/samba.pam samba
	insinto /etc/smb ; newins examples/smb.conf.default smb.conf.example
	exeinto /etc/init.d ; newexe ${FILESDIR}/samba.rc6 samba
}

pkg_preinst() {
	if [ "$ROOT" = "/" ] && [ -e /dev/shm/.init.d/started/samba ] ; then
		/etc/init.d/samba stop
	fi
}

pkg_prerm() {
	if [ "$ROOT" = "/" ] && [ -e /dev/shm/.init.d/started/samba ] ; then
		/etc/init.d/samba stop
	fi
}

pkg_postinst() {

	# we touch ${D}/etc/smb/smb.conf so that people installing samba
	# just to mount smb shares don't get annoying warnings all the time.
	if [ ! -e ${ROOT}etc/smb/smb.conf ] ; then
		touch ${ROOT}etc/smb/smb.conf
	fi

	echo "##"
	echo " If you had samba running earlier, you'll need to start it again. Also, please note"
	echo " that you must configure /etc/smb/smb.conf before samba (the server) will work properly."
	echo " Mounting smb shares and the smbclient program should work immediately.  To accomplish"
	echo " this there is an empty /etc/smb/smb.conf file installed."
	echo
	echo " To mount smb shares, type something like this. You will need kernel SMB support first:"
	echo " % mount -t smbfs -o username=drobbins,password=foo,ip=192.168.1.1 //mybox/drobbins /mnt/foo"
	echo " If you wish to allow normal users to mount smb shares, type the following as root:"
	echo " % chmod u+s /usr/bin/smbmnt"
	echo "##"
}