Package-Name: samba
Gentoo-Package: net-fs/samba
Suggests: readline openssl
Rebuild-For: cups
Homepage: http://www.samba.org/
#Source: ftp://www.jp.samba.org/pub/samba/samba-(\d+.\d+(.\d+)?\w*).tar.gz $1
Source: ftp://ftp.ring.gr.jp/pub/net/samba/samba-(\d+.\d+(.\d+)?\w*).tar.gz $1
Zap-Before-Install: 1
Repack:
	tar xzvfp "$(SOURCE)"
Compile:
	cp -pf COPYING README Roadmap WHATSNEW.txt "$(PREFIX)/"
	if packager c openssl ; then SSL=--with-ssl=`cd "$(PREFIX)"/..;pwd`/openssl ; else SSL= ; fi ; \
	$(MAKE) -C source -f ../../Makefile configure CONFIGURE_OPTS="--with-privatedir='$(PREFIX)/etc' --with-lockdir=/var/lock --with-piddir=/var/run --with-swatdir='$(PREFIX)/swat' --with-configdir='$(PREFIX)/etc' --with-codepagedir='$(PREFIX)/lib/codepages' --with-logfilebase=/var/log/samba --with-smbmount --with-included-popt $$SSL"
	$(MAKE) -C source
	rm -rf "$(PREFIX)"/swat
	$(MAKE) -C source install
	rm -f "$(PREFIX)"/{bin,sbin}/*.old
Install:
	chmod 4755 "$(PREFIX)"/bin/smbmnt
	$(MAKE) instbin BIN="findsmb make_printerdef make_smbcodepage make_unicodemap nmblookup rpcclient smbcacls smbclient smbcontrol smbmnt smbmount smbpasswd smbspool smbstatus smbtar smbumount tdbbackup testparm testprns wbinfo"
	$(MAKE) instsbin SBIN="nmbd smbd swat winbindd"
	$(MAKE) instman SECTION=1 MAN="editreg findsmb log2pcap nmblookup ntlm_auth profiles rpcclient smbcacls smbclient smbcontrol smbcquotas smbget smbsh smbstatus smbtar smbtree testparm testprns vfstest wbinfo"
	$(MAKE) instman SECTION=5 MAN="lmhosts smb.conf smbpasswd"
	$(MAKE) instman SECTION=7 MAN=samba
	$(MAKE) instman SECTION=8 MAN="nmbd pdbedit smbd smbmnt smbmount smbpasswd smbspool smbumount swat winbindd"
	rm -rf "$(PREFIX)"/{etc,private,var}
	umask 066 ; mkdir -p /etc/samba
	ln -s /etc/samba "$(PREFIX)"/etc
	umask 027 ; mkdir -p /var/log/samba
	chgrp adm /var/log/samba
	ln -fs "$(PREFIX)"/bin/smbmount /sbin/mount.smbfs
NoPatch: <<EOT
######## begin pidfile option patch
diff -urN ../samba-3.0.24-orig/source/lib/pidfile.c source/lib/pidfile.c
--- ../samba-3.0.24-orig/source/lib/pidfile.c	2007-02-05 03:59:17 +0900
+++ source/lib/pidfile.c	2007-02-27 09:35:32 +0900
@@ -28,15 +28,12 @@
 
 /* return the pid in a pidfile. return 0 if the process (or pidfile)
    does not exist */
-pid_t pidfile_pid(const char *name)
+static pid_t _pidfile_pid(pstring pidFile)
 {
 	int fd;
 	char pidstr[20];
 	pid_t pid;
 	unsigned int ret;
-	pstring pidFile;
-
-	slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name);
 
 	fd = sys_open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
 	if (fd == -1) {
@@ -77,31 +74,28 @@
 	return 0;
 }
 
-/* create a pid file in the pid directory. open it and leave it locked */
-void pidfile_create(const char *program_name)
+/* return the pid in a pidfile in the lock directory. return 0 if the process
+   (or pidfile) does not exist */
+pid_t pidfile_pid(const char *name)
 {
-	int     fd;
-	char    buf[20];
-	char    *short_configfile;
-	pstring name;
 	pstring pidFile;
-	pid_t pid;
-
-	/* Add a suffix to the program name if this is a process with a
-	 * none default configuration file name. */
-	if (strcmp( CONFIGFILE, dyn_CONFIGFILE) == 0) {
-		strncpy( name, program_name, sizeof( name)-1);
-	} else {
-		short_configfile = strrchr( dyn_CONFIGFILE, '/');
-		slprintf( name, sizeof( name)-1, "%s-%s", program_name, short_configfile+1);
-	}
 
 	slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name);
 
-	pid = pidfile_pid(name);
+	return _pidfile_pid(pidFile);
+}
+
+/* create a pid file that can be anywhere. open it and leave it locked */
+void _pidfile_create(pstring pidFile)
+{
+	int     fd;
+	char    buf[20];
+	pid_t pid;
+
+	pid = _pidfile_pid(pidFile);
 	if (pid != 0) {
-		DEBUG(0,("ERROR: %s is already running. File %s exists and process id %d is running.\n", 
-			 name, pidFile, (int)pid));
+		DEBUG(0,("ERROR: Already running. File %s exists and process id %d is running.\n", 
+			 pidFile, (int)pid));
 		exit(1);
 	}
 
@@ -113,8 +107,8 @@
 	}
 
 	if (fcntl_lock(fd,SMB_F_SETLK,0,1,F_WRLCK)==False) {
-		DEBUG(0,("ERROR: %s : fcntl lock of file %s failed. Error was %s\n",  
-              name, pidFile, strerror(errno)));
+		DEBUG(0,("ERROR: fcntl lock of file %s failed. Error was %s\n",  
+              pidFile, strerror(errno)));
 		exit(1);
 	}
 
@@ -127,3 +121,24 @@
 	}
 	/* Leave pid file open & locked for the duration... */
 }
+
+/* create a pid file in the lock directory. open it and leave it locked */
+void pidfile_create(const char *program_name)
+{
+	char    *short_configfile;
+	pstring name;
+	pstring pidFile;
+
+	/* Add a suffix to the program name if this is a process with a
+	 * none default configuration file name. */
+	if (strcmp( CONFIGFILE, dyn_CONFIGFILE) == 0) {
+		strncpy( name, program_name, sizeof( name)-1);
+	} else {
+		short_configfile = strrchr( dyn_CONFIGFILE, '/');
+		slprintf( name, sizeof( name)-1, "%s-%s", program_name, short_configfile+1);
+	}
+
+	slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name);
+
+	return _pidfile_create(pidFile);
+}
diff -urN ../samba-3.0.24-orig/source/nmbd/nmbd.c source/nmbd/nmbd.c
--- ../samba-3.0.24-orig/source/nmbd/nmbd.c	2007-02-05 03:59:23 +0900
+++ source/nmbd/nmbd.c	2007-02-27 09:26:12 +0900
@@ -627,6 +627,7 @@
 	static BOOL opt_interactive;
 	poptContext pc;
 	static char *p_lmhosts = dyn_LMHOSTSFILE;
+	char const *pidfile;
 	static BOOL no_process_group = False;
 	struct poptOption long_options[] = {
 	POPT_AUTOHELP
@@ -637,6 +638,7 @@
 	{"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
 	{"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 'H', "Load a netbios hosts file"},
 	{"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" },
+	{"pidfile", 'f', POPT_ARG_STRING, &pidfile, 0, "Use a specific pidfile\n" },
 	POPT_COMMON_SAMBA
 	{ NULL }
 	};
@@ -644,6 +646,7 @@
 	load_case_tables();
 
 	global_nmb_port = NMB_PORT;
+	pidfile = NULL;
 
 	pc = poptGetContext("nmbd", argc, argv, long_options, 0);
 	while (poptGetNextOpt(pc) != -1) {};
@@ -745,7 +748,11 @@
 		mkdir(lp_lockdir(), 0755);
 	}
 
-	pidfile_create("nmbd");
+	if (pidfile) {
+		_pidfile_create(pidfile);
+	} else {
+		pidfile_create("nmbd");
+	}
 	message_init();
 	message_register(MSG_FORCE_ELECTION, nmbd_message_election);
 #if 0
diff -urN ../samba-3.0.24-orig/source/smbd/server.c source/smbd/server.c
--- ../samba-3.0.24-orig/source/smbd/server.c	2007-02-05 03:59:13 +0900
+++ source/smbd/server.c	2007-02-27 09:26:12 +0900
@@ -740,6 +740,7 @@
 	static BOOL no_process_group = False;
 	static BOOL log_stdout = False;
 	static char *ports = NULL;
+	char const *pidfile = NULL;
 	int opt;
 	poptContext pc;
 
@@ -752,6 +753,7 @@
 	{"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
 	{"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" },
 	{"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"},
+	{"pidfile", 'f', POPT_ARG_STRING, &pidfile, 0, "Use a specific pidfile\n" },
 	POPT_COMMON_SAMBA
 	POPT_COMMON_DYNCONFIG
 	POPT_TABLEEND
@@ -905,8 +907,13 @@
 	if (!directory_exist(lp_lockdir(), NULL))
 		mkdir(lp_lockdir(), 0755);
 
-	if (is_daemon)
-		pidfile_create("smbd");
+	if (is_daemon) {
+		if (pidfile) {
+			_pidfile_create(pidfile);
+		} else {
+			pidfile_create("smbd");
+		}
+  	}
 
 	/* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
 	if (!message_init())
######## end pidfile option patch
EOT
NoPatch: <<EOT
diff -urN ../samba-3.0.23c-orig/source/lib/pidfile.c ../samba-3.0.23c/source/lib/pidfile.c
--- ../samba-3.0.23c-orig/source/lib/pidfile.c	2006-04-20 11:29:23 +0900
+++ source/lib/pidfile.c	2006-11-08 14:48:13 +0900
@@ -28,15 +28,12 @@
 
 /* return the pid in a pidfile. return 0 if the process (or pidfile)
    does not exist */
-pid_t pidfile_pid(const char *name)
+static pid_t _pidfile_pid(pstring pidFile)
 {
 	int fd;
 	char pidstr[20];
 	pid_t pid;
 	unsigned int ret;
-	pstring pidFile;
-
-	slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name);
 
 	fd = sys_open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
 	if (fd == -1) {
@@ -77,20 +74,28 @@
 	return 0;
 }
 
-/* create a pid file in the pid directory. open it and leave it locked */
-void pidfile_create(const char *name)
+/* return the pid in a pidfile in the lock directory. return 0 if the process
+   (or pidfile) does not exist */
+pid_t pidfile_pid(const char *name)
 {
-	int     fd;
-	char    buf[20];
 	pstring pidFile;
-	pid_t pid;
 
 	slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name);
 
-	pid = pidfile_pid(name);
+	return _pidfile_pid(pidFile);
+}
+
+/* create a pid file that can be anywhere. open it and leave it locked */
+void _pidfile_create(pstring pidFile)
+{
+	int     fd;
+	char    buf[20];
+	pid_t pid;
+
+	pid = _pidfile_pid(pidFile);
 	if (pid != 0) {
-		DEBUG(0,("ERROR: %s is already running. File %s exists and process id %d is running.\n", 
-			 name, pidFile, (int)pid));
+      DEBUG(0,("ERROR: Already running. File %s exists and process id %d is running.\n", 
+      pidFile, (int)pid));
 		exit(1);
 	}
 
@@ -102,8 +107,8 @@
 	}
 
 	if (fcntl_lock(fd,SMB_F_SETLK,0,1,F_WRLCK)==False) {
-		DEBUG(0,("ERROR: %s : fcntl lock of file %s failed. Error was %s\n",  
-              name, pidFile, strerror(errno)));
+		DEBUG(0,("ERROR: fcntl lock of file %s failed. Error was %s\n",  
+              pidFile, strerror(errno)));
 		exit(1);
 	}
 
@@ -116,3 +121,13 @@
 	}
 	/* Leave pid file open & locked for the duration... */
 }
+
+/* create a pid file in the lock directory. open it and leave it locked */
+void pidfile_create(const char *name)
+{
+	pstring pidFile;
+
+	slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_lockdir(), name);
+
+	return _pidfile_create(pidFile);
+}
diff -urN ../samba-3.0.23c-orig/source/nmbd/nmbd.c ../samba-3.0.23c/source/nmbd/nmbd.c
--- ../samba-3.0.23c-orig/source/nmbd/nmbd.c	2006-07-11 01:27:52 +0900
+++ source/nmbd/nmbd.c	2006-11-08 14:44:16 +0900
@@ -627,6 +627,7 @@
 	static BOOL opt_interactive;
 	poptContext pc;
 	static char *p_lmhosts = dyn_LMHOSTSFILE;
+	char const *pidfile;
 	static BOOL no_process_group = False;
 	struct poptOption long_options[] = {
 	POPT_AUTOHELP
@@ -637,6 +638,7 @@
 	{"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
 	{"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 'H', "Load a netbios hosts file"},
 	{"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" },
+	{"pidfile", 'f', POPT_ARG_STRING, &pidfile, 0, "Use a specific pidfile\n" },
 	POPT_COMMON_SAMBA
 	{ NULL }
 	};
@@ -644,6 +646,7 @@
 	load_case_tables();
 
 	global_nmb_port = NMB_PORT;
+	pidfile = NULL;
 
 	pc = poptGetContext("nmbd", argc, argv, long_options, 0);
 	while (poptGetNextOpt(pc) != -1) {};
@@ -745,7 +748,11 @@
 		mkdir(lp_lockdir(), 0755);
 	}
 
-	pidfile_create("nmbd");
+	if (pidfile) {
+		_pidfile_create(pidfile);
+	} else {
+		pidfile_create("nmbd");
+	}
 	message_init();
 	message_register(MSG_FORCE_ELECTION, nmbd_message_election);
 #if 0
diff -urN ../samba-3.0.23c-orig/source/smbd/server.c ../samba-3.0.23c/source/smbd/server.c
--- ../samba-3.0.23c-orig/source/smbd/server.c	2006-06-10 04:30:30 +0900
+++ source/smbd/server.c	2006-11-08 14:44:16 +0900
@@ -740,6 +740,7 @@
 	static BOOL no_process_group = False;
 	static BOOL log_stdout = False;
 	static char *ports = NULL;
+	char const *pidfile = NULL;
 	int opt;
 	poptContext pc;
 
@@ -752,6 +753,7 @@
 	{"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
 	{"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" },
 	{"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"},
+	{"pidfile", 'f', POPT_ARG_STRING, &pidfile, 0, "Use a specific pidfile\n" },
 	POPT_COMMON_SAMBA
 	POPT_COMMON_DYNCONFIG
 	POPT_TABLEEND
@@ -905,8 +907,13 @@
 	if (!directory_exist(lp_lockdir(), NULL))
 		mkdir(lp_lockdir(), 0755);
 
-	if (is_daemon)
-		pidfile_create("smbd");
+	if (is_daemon) {
+		if (pidfile) {
+			_pidfile_create(pidfile);
+		} else {
+			pidfile_create("smbd");
+		}
+  	}
 
 	/* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
 	if (!message_init())
EOT

-/etc/samba/
-/var/log/samba/
/etc/samba/
/pkg/samba/
/sbin/mount.smbfs
/usr/bin/findsmb
/usr/bin/make_printerdef
/usr/bin/make_smbcodepage
/usr/bin/make_unicodemap
/usr/bin/nmblookup
/usr/bin/rpcclient
/usr/bin/smbcacls
/usr/bin/smbclient
/usr/bin/smbcontrol
/usr/bin/smbmnt
/usr/bin/smbmount
/usr/bin/smbpasswd
/usr/bin/smbspool
/usr/bin/smbstatus
/usr/bin/smbtar
/usr/bin/smbumount
/usr/bin/tdbbackup
/usr/bin/testparm
/usr/bin/testprns
/usr/bin/wbinfo
/usr/man/man1/editreg.1.gz
/usr/man/man1/findsmb.1.gz
/usr/man/man1/log2pcap.1.gz
/usr/man/man1/nmblookup.1.gz
/usr/man/man1/ntlm_auth.1.gz
/usr/man/man1/profiles.1.gz
/usr/man/man1/rpcclient.1.gz
/usr/man/man1/smbcacls.1.gz
/usr/man/man1/smbclient.1.gz
/usr/man/man1/smbcontrol.1.gz
/usr/man/man1/smbcquotas.1.gz
/usr/man/man1/smbget.1.gz
/usr/man/man1/smbsh.1.gz
/usr/man/man1/smbstatus.1.gz
/usr/man/man1/smbtar.1.gz
/usr/man/man1/smbtree.1.gz
/usr/man/man1/testparm.1.gz
/usr/man/man1/testprns.1.gz
/usr/man/man1/vfstest.1.gz
/usr/man/man1/wbinfo.1.gz
/usr/man/man1/wbinfo.1.gz
/usr/man/man5/lmhosts.5.gz
/usr/man/man5/smb.conf.5.gz
/usr/man/man5/smbpasswd.5.gz
/usr/man/man7/samba.7.gz
/usr/man/man8/nmbd.8.gz
/usr/man/man8/pdbedit.8.gz
/usr/man/man8/smbd.8.gz
/usr/man/man8/smbmnt.8.gz
/usr/man/man8/smbmount.8.gz
/usr/man/man8/smbpasswd.8.gz
/usr/man/man8/smbspool.8.gz
/usr/man/man8/smbumount.8.gz
/usr/man/man8/swat.8.gz
/usr/man/man8/winbindd.8.gz
/usr/sbin/nmbd
/usr/sbin/smbd
/usr/sbin/swat
/usr/sbin/winbindd
/var/log/samba/
