[Pkg-vsquare-changes] r212 - in vde2/trunk/debian: . patches

filippo at alioth.debian.org filippo at alioth.debian.org
Wed Oct 1 12:33:34 UTC 2008


Author: filippo
Date: 2008-10-01 12:33:33 +0000 (Wed, 01 Oct 2008)
New Revision: 212

Added:
   vde2/trunk/debian/patches/
   vde2/trunk/debian/patches/allow_mgmtgroup.patch
   vde2/trunk/debian/patches/dbgout_prototype_change.patch
   vde2/trunk/debian/patches/fix_loop_noarg.patch
   vde2/trunk/debian/patches/fix_output_cosmetic.patch
   vde2/trunk/debian/patches/plugin_fixes.patch
   vde2/trunk/debian/patches/remove_numports_limit.patch
   vde2/trunk/debian/patches/vde_kvdeswitchfix.patch
Modified:
   vde2/trunk/debian/changelog
   vde2/trunk/debian/rules
Log:
backport some patches from upcoming 2.2.3

Modified: vde2/trunk/debian/changelog
===================================================================
--- vde2/trunk/debian/changelog	2008-08-19 08:57:40 UTC (rev 211)
+++ vde2/trunk/debian/changelog	2008-10-01 12:33:33 UTC (rev 212)
@@ -1,10 +1,10 @@
 vde2 (2.2.2-2) UNRELEASED; urgency=low
 
-  * NOT RELEASED YET
   * Add DM-Upload-Allowed field
   * Add Luca Bigliardi as Uploader/DM
+  * Backport fixes from upstream 2.2.3 into debian/patches 
 
- -- Filippo Giunchedi <filippo at debian.org>  Sat, 26 Jul 2008 20:51:03 +0200
+ -- Filippo Giunchedi <filippo at debian.org>  Wed, 01 Oct 2008 14:00:40 +0200
 
 vde2 (2.2.2-1) unstable; urgency=low
 

Added: vde2/trunk/debian/patches/allow_mgmtgroup.patch
===================================================================
--- vde2/trunk/debian/patches/allow_mgmtgroup.patch	                        (rev 0)
+++ vde2/trunk/debian/patches/allow_mgmtgroup.patch	2008-10-01 12:33:33 UTC (rev 212)
@@ -0,0 +1,538 @@
+--- vde-2.2.2/man/vdetaplib.1.in	(revision 301)
++++ vde-2.2.2/man/vdetaplib.1.in	(working copy)
+@@ -40,8 +41,9 @@
+ setenv VDEALLTAP /tmp/vde.ctl
+ .RE
+ 
+-It is also possible to set each single interface to different vde_switches
++It is possible to set each single interface to different vde_switches
+ by setting the environment variable with the same name of the interface.
++.br
+ (sh, ksh or bash syntax):
+ .RS
+ .br
+@@ -68,6 +70,35 @@
+ .RE
+ .br
+ 
++It is also possible to specify \fBport\fP, \fBgroup\fP or \fBmode\fP for a given
++interface setting environment variables as in the following example.
++.br
++(sh, ksh or bash syntax):
++.RS
++.br
++.B
++export tap0_port=5
++.br
++.B
++export tap0_group=vde-net
++.br
++.B
++export tap0_mode=0660
++.RE
++(csh, tchs, syntax):
++.RS
++.br
++.B
++setenv tap0_port 5
++.br
++.B
++setenv tap0_group vde-net
++.br
++.B
++setenv tap0_mode 0660
++.RE
++.br
++
+ The variable to set the specific interface is checked first then
+ VDEALLTAP. VDEALLTAP thus works as a default choice for the vde switch
+ to be used.
+--- vde-2.2.2/src/vdetaplib/libvdetap.c	(revision 301)
++++ vde-2.2.2/src/vdetaplib/libvdetap.c	(working copy)
+@@ -104,7 +104,6 @@
+ 
+ int open(const char *path, int flags, ...)
+ {
+-	/* static char buf[PATH_MAX]; */
+ 	va_list ap;
+ 	int data;
+ 
+@@ -113,9 +112,8 @@
+ 	va_end(ap);
+ 
+ 	if (strcmp(path,TUNTAPPATH)==0 && tapfd[0] == -1) {
+-		if (socketpair(PF_UNIX, SOCK_DGRAM, 0,tapfd) == 0) {
++		if (socketpair(PF_UNIX, SOCK_DGRAM, 0,tapfd) == 0)
+ 			return tapfd[0];
+-		}
+ 		else
+ 			return -1;
+ 
+@@ -125,7 +123,6 @@
+ 
+ int open64(const char *path, int flags, ...)
+ {
+-	/* static char buf[PATH_MAX]; */
+ 	va_list ap;
+ 	int data;
+ 
+@@ -134,9 +131,8 @@
+ 	va_end(ap);
+ 
+ 	if (strcmp(path,TUNTAPPATH)==0 && tapfd[0] == -1) {
+-		if (socketpair(PF_UNIX, SOCK_DGRAM, 0,tapfd) == 0) {
++		if (socketpair(PF_UNIX, SOCK_DGRAM, 0,tapfd) == 0) 
+ 			return tapfd[0];
+-		}
+ 		else
+ 			return -1;
+ 
+@@ -144,12 +140,27 @@
+ 		return native_open64(path, flags | O_LARGEFILE, data);
+ }
+ 
++static char *getvdeopt(struct ifreq *ifr,char *suffix)
++{
++	static char buf[16];
++	char *rv;
++	snprintf(buf,16,"%s_%s",ifr->ifr_name,suffix);
++	if ((rv=getenv(buf)) != NULL)
++		return rv;
++	snprintf(buf,16,"VDEALLTAP_%s",ifr->ifr_name,suffix);
++	if ((rv=getenv(buf)) != NULL)
++		return rv;
++	else
++		return "";
++}
++
+ int ioctl(int fd, unsigned long int command, ...)
+ {
+ 	va_list ap;
+ 	char *data;
+ 	char *vdesock;
+ 	int pid;
++	int callerpid=getpid();
+ 
+ 	va_start(ap, command);
+ 	data = va_arg(ap, char *);
+@@ -160,6 +171,7 @@
+ 			struct ifreq *ifr = (struct ifreq *) data;
+ 			char num[5];
+ 			char name[10];
++			char scallerpid[6];
+ 
+ 			ifr->ifr_name[IFNAMSIZ-1] = '\0';
+ 			if (ifr->ifr_name[0] == 0) {
+@@ -177,7 +189,7 @@
+ 					/* from env: single interface or VDEALLTAP */
+ 					((vdesock=getenv(ifr->ifr_name)) != NULL) ||
+ 						(vdesock=getenv(VDEALLTAP)) != NULL)
+-				){
++				 ){
+ 				if ((pid=fork()) < 0) { 
+ 					close(tapfd[1]);
+ 					errno=EINVAL;
+@@ -195,7 +207,13 @@
+ 					plh=NULL;
+ 					close(tapfd[0]);
+ 					sprintf(num,"%d",tapfd[1]);
+-					return execlp(VDETAPEXEC,"-",num,vdesock,name,(char *) 0);
++					sprintf(scallerpid,"%d",callerpid);
++					return execlp(VDETAPEXEC,"-",num,vdesock,ifr->ifr_name,
++							scallerpid,
++							getvdeopt(ifr,"port"),
++							getvdeopt(ifr,"group"),
++							getvdeopt(ifr,"mode"),
++							(char *) 0);
+ 				}
+ 			}
+ 			else /*roll back to the native tuntap*/
+--- vde-2.2.2/src/vdetaplib/vdetap.c	(revision 301)
++++ vde-2.2.2/src/vdetaplib/vdetap.c	(working copy)
+@@ -1,6 +1,7 @@
+ /* Copyright 2004 Renzo Davoli
+  * Reseased under the GPLv2 */
+ 
++#define _GNU_SOURCE
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+@@ -34,10 +35,11 @@
+ 	int result,nx;
+ 	register int i;
+ 	struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700};
++	char *descr;
+ 	/*printf("argc = %d\n",argc);
+ 	for (i=0;i<argc;i++)
+ 		printf("argv %d -%s-\n",i,argv[i]);*/
+-	if (argc != 4 && argv[0][0] != '-') {
++	if (argc < 4 && argv[0][0] != '-') {
+ 		fprintf(stderr,"vdetap must be activated by libvdetap e.g.\n"
+ 				"   sh%% export LD_PRELOAD=%s/libvdetap.so\n"
+ 				"   csh%% setenv LD_PRELOAD %s/libvdetap.so\n", LIBEXECDIR, LIBEXECDIR);
+@@ -52,8 +54,15 @@
+ 		perror("socket");
+ 		exit(1);
+ 	}
+-	/* TODO insert argv[3] in descr */
+-	conn=vde_open(argv[2],"tuntaplib",&open_args);
++	if (argc == 8) {
++		open_args.port=atoi(argv[5]);
++		open_args.group=argv[6];
++	  sscanf(argv[7],"%i",&open_args.mode);
++		//fprintf(stderr,"|%d|%s|%o|\n",open_args.port,open_args.group,open_args.mode);
++		asprintf(&descr,"tuntaplib %s/%s",argv[4],argv[3]);
++	} else
++		descr="tuntaplib";
++	conn=vde_open(argv[2],descr,&open_args);
+ 	pollv[0].fd=fd;
+ 	pollv[1].fd=vde_datafd(conn);
+ 	for(;;) {
+--- vde-2.2.2/src/vde_switch/datasock.c	(revision 301)
++++ vde-2.2.2/src/vde_switch/datasock.c	(working copy)
+@@ -23,6 +23,7 @@
+ #include <sys/un.h>
+ #include <net/if.h>
+ #include <stdarg.h>
++#include <limits.h>
+ #include <grp.h>
+ #define _GNU_SOURCE
+ #include <getopt.h>
+@@ -41,10 +42,12 @@
+ static unsigned int ctl_type;
+ static unsigned int wd_type;
+ static unsigned int data_type;
+-static int mode = 0700;
+ 
+ static char real_ctl_socket[PATH_MAX];
+ static char *ctl_socket = real_ctl_socket;
++
++static int mode = -1;
++static int dirmode = -1;
+ static gid_t grp_owner = -1;
+ 
+ #define MODULENAME "unix prog"
+@@ -343,11 +346,15 @@
+ 	}
+ }
+ 
++#define DIRMODEARG	0x100
++
+ static struct option long_options[] = {
+ 	{"sock", 1, 0, 's'},
+ 	{"vdesock", 1, 0, 's'},
+ 	{"unix", 1, 0, 's'},
+ 	{"mod", 1, 0, 'm'},
++	{"mode", 1, 0, 'm'},
++	{"dirmode", 1, 0, DIRMODEARG},
+ 	{"group", 1, 0, 'g'},
+ };
+ 
+@@ -360,7 +367,8 @@
+ 			"  -s, --sock SOCK            control directory pathname\n"
+ 			"  -s, --vdesock SOCK         Same as --sock SOCK\n"
+ 			"  -s, --unix SOCK            Same as --sock SOCK\n"
+-			"  -m, --mod MODE             Standard access mode for comm sockets (octal)\n"
++			"  -m, --mode MODE            Permissions for the control socket (octal)\n"
++			"      --dirmode MODE         Permissions for the sockets directory (octal)\n"
+ 			"  -g, --group GROUP          Group owner for comm sockets\n"
+ 			);
+ }
+@@ -385,6 +393,9 @@
+ 			}
+ 			grp_owner=grp->gr_gid;
+ 			break;
++		case DIRMODEARG:
++			sscanf(optarg, "%o", &dirmode);
++			break;
+ 		default:
+ 			outc=c;
+ 	}
+@@ -397,6 +408,32 @@
+ 	struct sockaddr_un sun;
+ 	int one = 1;
+ 
++	/* Set up default modes */
++	if (mode < 0 && dirmode < 0)
++	{
++		/* Default values */
++		mode = 00600;    /* -rw------- for the ctl socket */
++		dirmode = 02700; /* -rwx--S--- for the directory */
++	}
++	else if (mode >= 0 && dirmode < 0)
++	{
++		/* If only mode (-m) has been specified, we guess the dirmode from it,
++		 * adding the executable bit where needed */
++
++#		define ADDBIT(mode, conditionmask, add) ((mode & conditionmask) ? ((mode & conditionmask) | add) : (mode & conditionmask))
++
++		dirmode = 02000 | /* Add also setgid */
++			ADDBIT(mode, 0600, 0100) |
++			ADDBIT(mode, 0060, 0010) |
++			ADDBIT(mode, 0006, 0001);
++	}
++	else if (mode < 0 && dirmode >= 0)
++	{
++		/* If only dirmode (--dirmode) has been specified, we guess the ctl
++		 * socket mode from it, turning off the executable bit everywhere */
++		mode = dirmode & 0666;
++	}
++
+ 	if((connect_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0){
+ 		printlog(LOG_ERR,"Could not obtain a BSD socket: %s", strerror(errno));
+ 		return;
+@@ -414,7 +451,7 @@
+ 		printlog(LOG_ERR,"Could not create the VDE ctl directory '%s': %s", ctl_socket, strerror(errno));
+ 		exit(-1);
+ 	}
+-	if ((chmod(ctl_socket, 02000 | (mode & 0700 ? 0700 : 0) | (mode & 0070 ? 0070 : 0) | (mode & 0007 ? 0005 : 0)) < 0)) {
++	if (chmod(ctl_socket, dirmode) < 0) {
+ 		printlog(LOG_ERR,"Could not set the VDE ctl directory '%s' permissions: %s", ctl_socket, strerror(errno));
+ 		exit(-1);
+ 	}
+--- vde-2.2.2/src/vde_switch/consmgmt.c	(revision 301)
++++ vde-2.2.2/src/vde_switch/consmgmt.c	(working copy)
+@@ -12,6 +12,7 @@
+ #include <unistd.h>
+ #include <syslog.h>
+ #include <stdlib.h>
++#include <grp.h>
+ #include <libgen.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+@@ -23,6 +24,7 @@
+ #include <stdarg.h>
+ #include <getopt.h>
+ #include <dlfcn.h>
++#include <limits.h>
+ 
+ #include <config.h>
+ #include <vde.h>
+@@ -48,6 +50,8 @@
+ static unsigned int mgmt_ctl=-1;
+ static unsigned int mgmt_data=-1;
+ static int mgmt_mode = 0600;
++static gid_t mgmt_group = -1;
++
+ static char *mgmt_socket = NULL;
+ static char header[]="VDE switch V.%s\n(C) Virtual Square Team (coord. R. Davoli) 2005,2006,2007 - GPLv2\n";
+ static char prompt[]="\nvde$ ";
+@@ -164,27 +168,6 @@
+ 	va_end (arg);
+ }
+ 
+-#if 0
+-void printoutc(int fd, const char *format, ...)
+-{
+-	va_list arg;
+-
+-	va_start (arg, format);
+-#if 0
+-	if (fd < 0)
+-		printlog(LOG_INFO,format,arg);
+-	else {
+-#endif
+-		char outbuf[MAXCMD+1];
+-		vsnprintf(outbuf,MAXCMD,format,arg);
+-		strcat(outbuf,"\n");
+-		write(fd,outbuf,strlen(outbuf));
+-#if 0
+-	}
+-#endif
+-}
+-#endif
+-
+ void printoutc(FILE *f, const char *format, ...)
+ {
+ 	va_list arg;
+@@ -227,7 +210,7 @@
+ 	va_list arg;
+ 	for (i=0; i<cl->nfun; i++) {
+ 		va_start (arg, cl);
+-		(cl->fun[i])(cl,arg);
++		(cl->fun[i])(cl,cl->funarg[i],arg);
+ 		va_end(arg);
+ 	}
+ }
+@@ -244,7 +227,7 @@
+ 	va_end(arg);
+ 	for (i=0; i<cl->nfun && len>0; i++) {
+ 		va_start (arg, cl);
+-		int rv=(cl->fun[i])(cl,arg);
++		int rv=(cl->fun[i])(cl,cl->funarg[i],arg);
+ 		va_end (arg);
+ 		if (rv!=0) 
+ 			len=rv;
+@@ -259,6 +242,7 @@
+ void setmgmtperm(char *path)
+ {
+ 	chmod(path,mgmt_mode);
++	chown(path, -1, mgmt_group);
+ }
+ 
+ static int help(FILE *fd,char *arg)
+@@ -281,11 +265,7 @@
+ 	if (*inbuf != '\0' && *inbuf != '#') {
+ 		char *outbuf;
+ 		size_t outbufsize;
+-		FILE *f;
+-		if (fd >= 0)
+-			f=open_memstream(&outbuf,&outbufsize);
+-		else
+-			f=NULL;
++		FILE *f=open_memstream(&outbuf,&outbufsize);
+ 		for (p=clh;p!=NULL && (p->doit==NULL || strncmp(p->path,inbuf,strlen(p->path))!=0); p=p->next)
+ 			;
+ 		if (p!=NULL)
+@@ -293,21 +273,24 @@
+ 			inbuf += strlen(p->path);
+ 			while (*inbuf == ' ' || *inbuf == '\t') inbuf++;
+ 			if (p->type & WITHFD) {
+-				if (p->type & WITHFILE) {
+-					printoutc(f,"0000 DATA END WITH '.'");
+-					switch(p->type & ~(WITHFILE | WITHFD)){
+-						case NOARG: rv=p->doit(f,fd); break;
+-						case INTARG: rv=p->doit(f,fd,atoi(inbuf)); break;
+-						case STRARG: rv=p->doit(f,fd,inbuf); break;
++				if (fd >= 0) {
++					if (p->type & WITHFILE) {
++						printoutc(f,"0000 DATA END WITH '.'");
++						switch(p->type & ~(WITHFILE | WITHFD)){
++							case NOARG: rv=p->doit(f,fd); break;
++							case INTARG: rv=p->doit(f,fd,atoi(inbuf)); break;
++							case STRARG: rv=p->doit(f,fd,inbuf); break;
++						}
++						printoutc(f,".");
++					} else {
++						switch(p->type & ~WITHFD){
++							case NOARG: rv=p->doit(fd); break;
++							case INTARG: rv=p->doit(fd,atoi(inbuf)); break;
++							case STRARG: rv=p->doit(fd,inbuf); break;
++						}
+ 					}
+-					printoutc(f,".");
+-				} else {
+-					switch(p->type & ~WITHFD){
+-						case NOARG: rv=p->doit(fd); break;
+-						case INTARG: rv=p->doit(fd,atoi(inbuf)); break;
+-						case STRARG: rv=p->doit(fd,inbuf); break;
+-					}
+-				}
++				} else
++					rv = EBADF;
+ 			} else if (p->type & WITHFILE) {
+ 				printoutc(f,"0000 DATA END WITH '.'");
+ 				switch(p->type & ~WITHFILE){
+@@ -324,13 +307,12 @@
+ 				}
+ 			}
+ 		}
+-		if (rv >= 0 && (rv > 0 || fd >= 0))
++		if (rv >=0)
+ 			printoutc(f,"1%03d %s",rv,strerror(rv));
+-		if (f) {
+-			fclose(f);
++		fclose(f);
++		if (fd >= 0)
+ 			write(fd,outbuf,outbufsize);
+-			free(outbuf);
+-		}
++		free(outbuf);
+ 	}
+ 	return rv;
+ }
+@@ -346,7 +328,7 @@
+ 			if (strlen(buf) > 1 && buf[strlen(buf)-1]=='\n') buf[strlen(buf)-1]= '\0';
+ 			if (fd >= 0) {
+ 				char *scriptprompt=NULL;
+-				asprintf(&scriptprompt,"vde[%s]: %s",path,buf);
++				asprintf(&scriptprompt,"vde[%s]: %s\n",path,buf);
+ 				write(fd,scriptprompt,strlen(scriptprompt));
+ 				free(scriptprompt);
+ 			}
+@@ -505,6 +487,7 @@
+ }
+ 
+ #define MGMTMODEARG 0x100
++#define MGMTGROUPARG 0x101
+ 
+ static struct option long_options[] = {
+ 	{"daemon", 0, 0, 'd'},
+@@ -512,6 +495,7 @@
+ 	{"rcfile", 1, 0, 'f'},
+ 	{"mgmt", 1, 0, 'M'},
+ 	{"mgmtmode", 1, 0, MGMTMODEARG},
++	{"mgmtgroup", 1, 0, MGMTGROUPARG},
+ #ifdef DEBUGOPT
+ 	{"debugclients",1,0,'D'},
+ #endif
+@@ -528,8 +512,9 @@
+ 			"  -f, --rcfile               Configuration file (overrides %s and ~/.vderc)\n"
+ 			"  -M, --mgmt SOCK            path of the management UNIX socket\n"
+ 			"      --mgmtmode MODE        management UNIX socket access mode (octal)\n"
++			"      --mgmtgroup GROUP      management UNIX socket group name\n"
+ #ifdef DEBUGOPT
+-			"  -D, --debugclients #        number of debug clients allowed\n"
++			"  -D, --debugclients #       number of debug clients allowed\n"
+ #endif
+ 			,STDRCFILE);
+ }
+@@ -537,6 +522,7 @@
+ static int parseopt(int c, char *optarg)
+ {
+ 	int outc=0;
++	struct group *grp;
+ 	switch (c) {
+ 		case 'd':
+ 			daemonize=1;
+@@ -553,6 +539,15 @@
+ 		case MGMTMODEARG:
+ 			sscanf(optarg,"%o",&mgmt_mode);
+ 			break;
++		case MGMTGROUPARG:
++			if (!(grp = getgrnam(optarg)))
++			{
++				fprintf(stderr, "No such group '%s'\n", optarg);
++				exit(1);
++			}
++			mgmt_group = grp->gr_gid;
++			break;
++
+ 		default:
+ 			outc=c;
+ 	}
+@@ -617,7 +612,7 @@
+ 				return;
+ 			}
+ 		}
+-		chmod(sun.sun_path,mgmt_mode);
++		setmgmtperm(sun.sun_path);
+ 		if(listen(mgmtconnfd, 15) < 0){
+ 			printlog(LOG_ERR,"mgmt listen: %s",strerror(errno));
+ 			return;
+@@ -825,19 +820,21 @@
+ }
+ 
+ static int plugindel(char *arg) {
+-	int rv=ENOENT;
+ 	struct plugin **p=&pluginh;
+ 	while (*p!=NULL){
++		void *handle;
+ 		if (strncmp((*p)->name, arg, strlen(arg)) == 0
+ 				&& ((*p)->handle != NULL)) {
+ 			struct plugin *this=*p;
+ 			delplugin(this);
+-			dlclose(this->handle);
+-			rv=0;
++			handle=this->handle;
++			this->handle=NULL;
++			dlclose(handle);
++			return 0;
+ 		} else
+ 			p=&(*p)->next;
+ 	}
+-	return rv;
++	return ENOENT;
+ }
+ #endif
+ 

Added: vde2/trunk/debian/patches/dbgout_prototype_change.patch
===================================================================
--- vde2/trunk/debian/patches/dbgout_prototype_change.patch	                        (rev 0)
+++ vde2/trunk/debian/patches/dbgout_prototype_change.patch	2008-10-01 12:33:33 UTC (rev 212)
@@ -0,0 +1,83 @@
+--- vde-2.2.2/src/vde_switch/hash.c	(revision 301)
++++ vde-2.2.2/src/vde_switch/hash.c	(working copy)
+@@ -100,8 +100,8 @@
+ 			return -1;
+ 		}
+ 
+-		DBGOUT(DBGHASHNEW,"%02x:%02x:%02x:%02x:%02x:%02x VLAN %02x:%02x",
+-				     esrc[0], esrc[1], esrc[2], esrc[3], esrc[4], esrc[5], esrc[6], esrc[7]);
++		DBGOUT(DBGHASHNEW,"%02x:%02x:%02x:%02x:%02x:%02x VLAN %02x:%02x Port %d",
++				     esrc[0], esrc[1], esrc[2], esrc[3], esrc[4], esrc[5], esrc[6], esrc[7], port);
+ 		EVENTOUT(DBGHASHNEW,esrc);
+ 		memcpy(&e->dst, esrc, ETH_ALEN+2);
+ 		if(h[k] != NULL) h[k]->prev = &(e->next);
+@@ -125,7 +125,7 @@
+ 
+ #define delete_hash_entry(OLD) \
+ 	({ \
+-	 DBGOUT(DBGHASHDEL,"%02x:%02x:%02x:%02x:%02x:%02x VLAN %02x:%02x", OLD->dst[0], OLD->dst[1], OLD->dst[2], OLD->dst[3], OLD->dst[4], OLD->dst[5], OLD->dst[6], OLD->dst[7]);\
++	 DBGOUT(DBGHASHDEL,"%02x:%02x:%02x:%02x:%02x:%02x VLAN %02x:%02x Port %d", OLD->dst[0], OLD->dst[1], OLD->dst[2], OLD->dst[3], OLD->dst[4], OLD->dst[5], OLD->dst[6], OLD->dst[7], OLD->port);\
+ 	 EVENTOUT(DBGHASHDEL,OLD->dst);\
+ 	 *((OLD)->prev)=(OLD)->next; \
+ 	 if((OLD)->next != NULL) (OLD)->next->prev = (OLD)->prev; \
+--- vde-2.2.2/src/vde_switch/consmgmt.h	(revision 301)
++++ vde-2.2.2/src/vde_switch/consmgmt.h	(working copy)
+@@ -49,7 +49,7 @@
+ 	char *help; /* help string. just event mgmt when NULL */
+ 	int tag;    /* tag for event mgmt and simple parsing */
+ 	int *fds;   /* file descriptors for debug */
+-	intfun (*fun); /* function call dor plugin events */
++	intfun (*fun); /* function call or plugin events */
+ 	void **funarg; /* arg for function calls */
+ 	unsigned short nfds; /* number of active fds */
+ 	unsigned short nfun; /* number of active fun */
+@@ -62,8 +62,8 @@
+ void debugout(struct dbgcl* cl, const char *format, ...);
+ void eventout(struct dbgcl* cl, ...);
+ int packetfilter(struct dbgcl* cl, ...);
+-#define DBGOUT(CL, ...) \
+-	if (__builtin_expect(((CL)->nfds) > 0, 0)) debugout((CL), __VA_ARGS__)
++#define DBGOUT(CL, FORMAT, ...) \
++	if (__builtin_expect(((CL)->nfds) > 0, 0)) debugout((CL), (FORMAT), __VA_ARGS__)
+ #define EVENTOUT(CL, ...) \
+ 	if (__builtin_expect(((CL)->nfun) > 0, 0)) eventout((CL), __VA_ARGS__)
+ #define PACKETFILTER(CL, PORT, BUF, LEN) \
+--- vde-2.2.2/include/vdeplugin.h	(revision 301)
++++ vde-2.2.2/include/vdeplugin.h	(working copy)
+@@ -3,16 +3,13 @@
+ #include <stdarg.h>
+ #include <stdio.h>
+ 
+-#include <config.h>
+-#include <vde.h>
+-
+ /* command type constants */
+ /* doit signature:
+  * int doit (
+  *            FILE *f,        *** only when WITHFILE
+  *            int fd,         *** only when WITHFD
+  *            int|char *arg)  *** when INTARG or STRARG */
+-/* if type==NOARG  int doit()
++/* if type==NOARG  int doit(void)
+  * if type==INTARG   int doit(int arg)
+  * if type==WITHFILE|WITHFD|STRARG int doit(FILE *f,int fd,char *arg)
+  * doit returns 0 on success otherwise it returns a valid errno code */
+@@ -95,14 +92,14 @@
+ #define ADDDBGCL(CL) adddbgcl(sizeof(CL)/sizeof(struct dbgcl),(CL))
+ #define DELCL(CL) delcl(sizeof(CL)/sizeof(struct comlist),(CL))
+ #define DELDBGCL(CL) deldbgcl(sizeof(CL)/sizeof(struct dbgcl),(CL))
+-#define DBGOUT(CL, ...) \
+-	  if (__builtin_expect(((CL)->nfds) > 0, 0)) debugout((CL), __VA_ARGS__)
++#define DBGOUT(CL, FORMAT, ...) \
++	  if (__builtin_expect(((CL)->nfds) > 0, 0)) debugout((CL), (FORMAT), __VA_ARGS__)
+ #define EVENTOUT(CL, ...) \
+ 	  if (__builtin_expect(((CL)->nfun) > 0, 0)) eventout((CL), __VA_ARGS__)
+ 
+ 
+-int eventadd(int (*fun)(),char *path,void *arg);
+-int eventdel(int (*fun)(),char *path,void *arg);
++int eventadd(int (*fun)(struct dbgcl *event,void *arg,va_list v),char *path,void *arg);
++int eventdel(int (*fun)(struct dbgcl *event,void *arg,va_list v),char *path,void *arg);
+ 
+ void debugout(struct dbgcl* cl, const char *format, ...);
+ 

Added: vde2/trunk/debian/patches/fix_loop_noarg.patch
===================================================================
--- vde2/trunk/debian/patches/fix_loop_noarg.patch	                        (rev 0)
+++ vde2/trunk/debian/patches/fix_loop_noarg.patch	2008-10-01 12:33:33 UTC (rev 212)
@@ -0,0 +1,13 @@
+--- vde-2.2.2/src/vdeq.c	(revision 301)
++++ vde-2.2.2/src/vdeq.c	(working copy)
+@@ -264,6 +264,10 @@
+ 			while (*arg != 0 && *arg != ',')
+ 				arg++;
+ 		}
++		else {
++		  printf("WARNING: unknown parameter in argument %s\n", arg);
++			exit(-1);
++	  }
+ 	}
+ 
+ 	snprintf(newarg,128,"tap,vlan=%d,fd=%d%s%s",vlan,fd,(*arg == 0)?"":",",arg);

Added: vde2/trunk/debian/patches/fix_output_cosmetic.patch
===================================================================
--- vde2/trunk/debian/patches/fix_output_cosmetic.patch	                        (rev 0)
+++ vde2/trunk/debian/patches/fix_output_cosmetic.patch	2008-10-01 12:33:33 UTC (rev 212)
@@ -0,0 +1,55 @@
+--- vde-2.2.2/src/wirefilter.c	(revision 301)
++++ vde-2.2.2/src/wirefilter.c	(working copy)
+@@ -26,6 +26,7 @@
+ #include <signal.h>
+ #include <math.h>
+ #include <stdarg.h>
++#include <limits.h>
+ #include <sys/time.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+@@ -38,7 +39,6 @@
+ #include <libvdeplug.h>
+ 
+ #if defined(VDE_DARWIN) || defined(VDE_FREEBSD)
+-#	include <limits.h>
+ #	if defined HAVE_SYSLIMITS_H
+ #		include <syslimits.h>
+ #	elif defined HAVE_SYS_SYSLIMITS_H
+@@ -872,20 +872,22 @@
+ 
+ static int help(int fd,char *s)
+ {
+-	printoutc(fd, "help:      print a summary of mgmt commands");
+-	printoutc(fd, "showinfo:  show status and parameter values");
+-	printoutc(fd, "loss:      set loss percentage");
+-	printoutc(fd, "lostburst: mean length of lost packet bursts");
+-	printoutc(fd, "delay:     set delay ms");
+-	printoutc(fd, "dup:       set dup packet percentage");
+-	printoutc(fd, "bandwidth: set channel bandwidth bytes/sec");
+-	printoutc(fd, "speed:     set interface speed bytes/sec");
+-	printoutc(fd, "noise:     set noise factor bits/Mbyte");
+-	printoutc(fd, "mtu:       set channel MTU (bytes)");
+-	printoutc(fd, "capacity:  set channel capacity (bytes)");
+-	printoutc(fd, "fifo:      set channel fifoness");
+-	printoutc(fd, "shutdown:  shut the channel down");
+-	printoutc(fd, "logout:    log out from this mgmt session");
++	printoutc(fd, "COMMAND      HELP");
++	printoutc(fd, "------------ ------------");
++	printoutc(fd, "help         print a summary of mgmt commands");
++	printoutc(fd, "showinfo     show status and parameter values");
++	printoutc(fd, "loss         set loss percentage");
++	printoutc(fd, "lostburst    mean length of lost packet bursts");
++	printoutc(fd, "delay        set delay ms");
++	printoutc(fd, "dup          set dup packet percentage");
++	printoutc(fd, "bandwidth    set channel bandwidth bytes/sec");
++	printoutc(fd, "speed        set interface speed bytes/sec");
++	printoutc(fd, "noise        set noise factor bits/Mbyte");
++	printoutc(fd, "mtu          set channel MTU (bytes)");
++	printoutc(fd, "capacity     set channel capacity (bytes)");
++	printoutc(fd, "fifo         set channel fifoness");
++	printoutc(fd, "shutdown     shut the channel down");
++	printoutc(fd, "logout       log out from this mgmt session");
+ 	return 0;
+ }
+ 

Added: vde2/trunk/debian/patches/plugin_fixes.patch
===================================================================
--- vde2/trunk/debian/patches/plugin_fixes.patch	                        (rev 0)
+++ vde2/trunk/debian/patches/plugin_fixes.patch	2008-10-01 12:33:33 UTC (rev 212)
@@ -0,0 +1,260 @@
+--- vde-2.2.2/src/vde_switch/plugins/dump.c	(revision 301)
++++ vde-2.2.2/src/vde_switch/plugins/dump.c	(working copy)
+@@ -10,23 +10,14 @@
+ #include <vdeplugin.h>
+ 
+ 
+-int testevent(struct dbgcl *tag,va_list v);
++static int testevent(struct dbgcl *tag,void *arg,va_list v);
++static int dump(char *arg);
++
+ struct plugin vde_plugin_data={
+ 	.name="dump",
+ 	.help="dump packets",
+ };
+ 
+-static int dump(char *arg)
+-{
+-	int active=atoi(arg);
+-	int rv;
+-	if (active)
+-		rv=eventadd(testevent,"packet",NULL);
+-	else
+-		rv=eventdel(testevent,"packet",NULL);
+-	return 0;
+-}
+-
+ static struct comlist cl[]={
+ 	{"dump","============","DUMP Packets",NULL,NOARG},
+ 	{"dump/active","0/1","start dumping data",dump,STRARG},
+@@ -38,17 +29,27 @@
+ 	 {"dump/packetout","dump outgoing packet",D_DUMP|D_OUT},
+ };
+ 
++static int dump(char *arg)
++{
++	int active=atoi(arg);
++	int rv;
++	if (active)
++		rv=eventadd(testevent,"packet",dl);
++	else
++		rv=eventdel(testevent,"packet",dl);
++	return 0;
++}
+ 
+-int testevent(struct dbgcl *event,va_list v)
++static int testevent(struct dbgcl *event,void *arg,va_list v)
+ {
+-	struct dbgcl *this=dl;
++	struct dbgcl *this=arg;
+ 	switch (event->tag) {
+ 		case D_PACKET|D_OUT: 
+ 			this++;
+ 		case D_PACKET|D_IN: 
+ 			{
+ 				int port=va_arg(v,int);
+-				char *buf=va_arg(v,char *);
++				unsigned char *buf=va_arg(v,unsigned char *);
+ 				int len=va_arg(v,int);
+ 				char *pktdump;
+ 				size_t dumplen;
+--- vde-2.2.2/src/vde_switch/plugins/pdump.c	(revision 301)
++++ vde-2.2.2/src/vde_switch/plugins/pdump.c	(working copy)
+@@ -3,6 +3,8 @@
+ #include <pcap.h>
+ #include <string.h>
+ #include <stdlib.h>
++#include <fcntl.h>
++#include <errno.h>
+ 
+ #include <config.h>
+ #include <vde.h>
+@@ -10,6 +12,8 @@
+ 
+ #include <vdeplugin.h>
+ 
++#define DEFAULT_DUMPFILE "vde_dump.cap"
++
+ /* usage:
+  *
+  * plugin/add pdump.so
+@@ -18,53 +22,74 @@
+  * pdump/active 1
+  */
+ 
+-// TODO per-port dump(file?)
+-int pktevent(struct dbgcl *tag,va_list v);
++/*
++ * TODO(godog):
++ *  - configurable snaplen
++ *  - per-port dump(file?)
++ *  TODO(shammash):
++ *  - configurable size for buffered dump
++ */
++static int pktevent(struct dbgcl *tag, void *arg, va_list v);
+ 
+ char errbuf[PCAP_ERRBUF_SIZE];
+ pcap_t *desc = NULL;
+ pcap_dumper_t *dumper = NULL;
+-char *dumpfile = "vde_dump.cap";
++char *dumpfile = NULL;
++static int buffered_dump = 0;
+ 
+ struct plugin vde_plugin_data={
+ 	.name="pdump",
+ 	.help="dump packets to file, in pcap format",
+ };
+ 
++static int set_dumper(FILE *console) {
++	int fd;
++	FILE *fp;
++	if ((fd = open(dumpfile, O_WRONLY | O_CREAT, 0600)) < 0) {
++		printoutc(console, "%s() open(%s): %s", __FUNCTION__, dumpfile, strerror(errno));
++		return -1;
++	}
++	if ((fp = fdopen(fd, "w")) == NULL) {
++		printoutc(console, "%s() fdopen(): %s", __FUNCTION__, strerror(errno));
++		return -1;
++	}
++	if ((dumper = pcap_dump_fopen(desc, fp)) == NULL) {
++		printoutc(console, "%s() pcap_dump_fopen(): %s", __FUNCTION__, pcap_geterr(desc));
++		return -1;
++	}
++	return 0;
++}
++
+ // FIXME check if dumpfile exists, it will be trucated 
+-static int dump(char *arg)
++static int dump(FILE *fd, char *arg)
+ {
+ 	int active=atoi(arg);
+ 	int rv;
+ 	if (active){
+-		// TODO configurable snaplen 
+-		if(!desc)
+-			desc = pcap_open_dead(DLT_EN10MB, 96);
+-		
+-		if(!dumper)
+-			dumper = pcap_dump_open(desc, dumpfile);
+-		
++		if(!dumper && set_dumper(fd)) {
++			printoutc(fd, "ERROR: cannot dump to %s", dumpfile);
++			return EINVAL;
++		}
+ 		rv=eventadd(pktevent,"packet",NULL);
+ 	}else{
+ 		rv=eventdel(pktevent,"packet",NULL);
+-
+ 		if(dumper)
+ 			pcap_dump_flush(dumper);	
+ 	}
+-	
+ 	return rv;
+ }
+ 
+ static int setfname(FILE *fd, char *arg)
+ {
+ 	if(strlen(arg)){
++		free(dumpfile);
++		dumpfile = strdup(arg);
+ 		if(dumper)
+-			pcap_dump_close(dumper);	
+-
+-		dumpfile = strdup(arg);
+-		if(!desc)
+-			desc = pcap_open_dead(DLT_EN10MB, 96);
+-		dumper = pcap_dump_open(desc, dumpfile);
++			pcap_dump_close(dumper);
++		if (set_dumper(fd)) {
++			printoutc(fd, "ERROR: cannot dump to %s", dumpfile);
++			return EINVAL;
++		}
+ 	}
+ 	
+ 	printoutc(fd, "dumpfile=%s", dumpfile);	
+@@ -72,10 +97,21 @@
+ 	return 0;
+ }
+ 
++static int setbuffered(char *arg)
++{
++	int b = atoi(arg);
++	if (b)
++		buffered_dump = 1;
++	else
++		buffered_dump = 0;
++	return 0;
++}
++
+ static struct comlist cl[]={
+ 	{"pdump","============","DUMP Packets to file",NULL,NOARG},
+-	{"pdump/active","0/1","start dumping data",dump,STRARG},
++	{"pdump/active","0/1","start dumping data",dump,STRARG|WITHFILE},
+ 	{"pdump/filename", "<file>", "set/show output filename (default: vde_dump.cap)", setfname, STRARG|WITHFILE},
++	{"pdump/buffered", "0/1", "set buffered/unbuffered dump", setbuffered, STRARG},
+ };
+ 
+ /*
+@@ -86,7 +122,7 @@
+  *        void pcap_freecode(struct bpf_program *)
+  */
+ 
+-// TODO activate debug as well when activated? 
++/* TODO(godog): activate debug as well when activated? */
+ #define D_DUMP 0100 
+ static struct dbgcl dl[]= {
+ 	 {"pdump/packetin","dump incoming packet to file",D_DUMP|D_IN},
+@@ -94,9 +130,9 @@
+ };
+ 
+ 
+-int pktevent(struct dbgcl *event,va_list v)
++static int pktevent(struct dbgcl *event,void * arg,va_list v)
+ {
+-	// forse meglio static? 
++	// is it better to define this static? 
+ 	struct pcap_pkthdr hdr;
+ 
+ 	if( (desc == NULL) || (dumper == NULL) ){
+@@ -107,13 +143,15 @@
+ 		case D_PACKET|D_OUT: 
+ 		case D_PACKET|D_IN: {
+ 							va_arg(v,int); /* port */
+-							unsigned char *buf=va_arg(v,char *);
++							unsigned char *buf=va_arg(v,unsigned char *);
+ 							int len=va_arg(v,int);
+ 
+ 							gettimeofday(&hdr.ts, NULL);
+ 							hdr.caplen = len;
+ 							hdr.len = len;
+ 							pcap_dump((u_char *)dumper, &hdr, buf);
++							if (!buffered_dump)
++								pcap_dump_flush(dumper);	
+ 							}
+ 	}
+ 	return 0;
+@@ -125,14 +163,23 @@
+ {
+ 	ADDCL(cl);
+ 	ADDDBGCL(dl);
++	desc = pcap_open_dead(DLT_EN10MB, 96);
++	dumpfile = strdup(DEFAULT_DUMPFILE);
+ }
+ 
+ 	static void
+ 	__attribute__ ((destructor))
+ fini (void)
+ {
+-	if(dumper)
++	eventdel(pktevent, "packet", NULL);
++	if(dumper) {
++		pcap_dump_flush(dumper);
+ 		pcap_dump_close(dumper);
++		dumper = NULL;
++	}
++	pcap_close(desc);
++	desc = NULL;
++	free(dumpfile);
+ 
+ 	DELCL(cl);
+ 	DELDBGCL(dl);

Added: vde2/trunk/debian/patches/remove_numports_limit.patch
===================================================================
--- vde2/trunk/debian/patches/remove_numports_limit.patch	                        (rev 0)
+++ vde2/trunk/debian/patches/remove_numports_limit.patch	2008-10-01 12:33:33 UTC (rev 212)
@@ -0,0 +1,74 @@
+--- vde-2.2.2/src/vde_plug.c	(revision 301)
++++ vde-2.2.2/src/vde_plug.c	(working copy)
+@@ -365,7 +365,7 @@
+ 
+ 				case 'p':
+ 					open_args.port=atoi(optarg);
+-					if (open_args.port <= 0 || open_args.port > 255 )
++					if (open_args.port <= 0)
+ 						usage(argv[0]); //implies exit
+ 					break;
+ 
+--- vde-2.2.2/src/vde_plug2tap.c	(revision 301)
++++ vde-2.2.2/src/vde_plug2tap.c	(working copy)
+@@ -18,6 +18,7 @@
+ #include <libgen.h>
+ #define _GNU_SOURCE
+ #include <getopt.h>
++#include <limits.h>
+ 
+ #include <config.h>
+ #include <vde.h>
+@@ -39,7 +40,6 @@
+ 
+ #if defined(VDE_DARWIN) || defined(VDE_FREEBSD)
+ #	define TAP_PREFIX "/dev/"
+-#	include <limits.h>
+ #	if defined HAVE_SYSLIMITS_H
+ #		include <syslimits.h>
+ #	elif defined HAVE_SYS_SYSLIMITS_H
+@@ -259,7 +259,7 @@
+ 		switch (c) {
+ 			case 'p':
+ 				open_args.port=atoi(optarg);
+-				if (open_args.port <= 0 || open_args.port > 255 )
++				if (open_args.port <= 0)
+ 					usage(); //implies exit
+ 				break;
+ 
+--- vde-2.2.2/src/vde_switch/port.c	(revision 301)
++++ vde-2.2.2/src/vde_switch/port.c	(working copy)
+@@ -579,6 +579,13 @@
+ 					exit(1);
+ 				}
+ 			}
++			if (vlant[i].bcuntag) {
++				vlant[i].bcuntag=BA_REALLOC(vlant[i].bcuntag,numports,val);
++				if (vlant[i].bcuntag == NULL) {
++					printlog(LOG_ERR,"Numport resize failed vlan tables vlan bctag %s",strerror(errno));
++					exit(1);
++				}
++			}
+ 			if (vlant[i].notlearning) {
+ 				vlant[i].notlearning=BA_REALLOC(vlant[i].notlearning,numports,val);
+ 				if (vlant[i].notlearning == NULL) {
+--- vde-2.2.2/src/vde_switch/bitarray.h	(revision 301)
++++ vde-2.2.2/src/vde_switch/bitarray.h	(working copy)
+@@ -94,7 +94,7 @@
+ 	 if(nb != NULL) \
+ 	 for(__i=__WORDSIZEROUND(N);__i<__WORDSIZEROUND(M);__i++) \
+ 	 nb[__i]=0; \
+-	 nb[__WORDSIZEROUND(N)-1] &= (1L<<(((((N)&__WORDSIZEMASK)-1)&0x1f)+1))-1; \
++	 nb[__WORDSIZEROUND(N)-1] &= (-1UL) >>((0U-(N))%__VDEWORDSIZE); \
+ 	 nb;})
+ 
+ #define BA_CHECK(X,I) ((X) && ((X)[(I)>>__LOG_WORDSIZE] & (1L << ((I) & __WORDSIZEMASK)))) 
+@@ -183,7 +183,7 @@
+ 	 (B)[__WORDSIZEROUND(M)]=__size; \
+ 	 for(__i=__WORDSIZEROUND(N);__i<__WORDSIZEROUND(M);__i++) \
+ 	 nb[__i]=0; }\
+-	 nb[__WORDSIZEROUND(N)-1] &= (1L<<(((((N)&__WORDSIZEMASK)-1)&0x1f)+1))-1; \
++	 nb[__WORDSIZEROUND(N)-1] &= (-1UL) >>((0U-(N))%__VDEWORDSIZE); \
+ 	 nb;})
+ 
+ /* BA_CHECK and BAC_CHECK are the same */

Added: vde2/trunk/debian/patches/vde_kvdeswitchfix.patch
===================================================================
--- vde2/trunk/debian/patches/vde_kvdeswitchfix.patch	                        (rev 0)
+++ vde2/trunk/debian/patches/vde_kvdeswitchfix.patch	2008-10-01 12:33:33 UTC (rev 212)
@@ -0,0 +1,51 @@
+--- vde-2.2.2/src/kvde_switch/consmgmt.c	(revision 301)
++++ vde-2.2.2/src/kvde_switch/consmgmt.c	(working copy)
+@@ -12,6 +12,7 @@
+ #include <unistd.h>
+ #include <syslog.h>
+ #include <stdlib.h>
++#include <limits.h>
+ #include <libgen.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+--- vde-2.2.2/src/kvde_switch/datasock.c	(revision 301)
++++ vde-2.2.2/src/kvde_switch/datasock.c	(working copy)
+@@ -23,6 +23,7 @@
+ #include <sys/un.h>
+ #include <net/if.h>
+ #include <stdarg.h>
++#include <limits.h>
+ #include <grp.h>
+ #define _GNU_SOURCE
+ #include <getopt.h>
+@@ -125,9 +126,9 @@
+ }
+ 
+ struct extinterface {
+-	  char type;
+-		  char *name;
+-			  struct extinterface *next;
++	char type;
++	char *name;
++	struct extinterface *next;
+ };
+ 
+ static struct extinterface *extifhead;
+@@ -177,7 +178,7 @@
+ 	switch (c) {
+ 		case 's':
+ 			/* This should returns NULL as the path probably does not exist */
+-			realpath(optarg, ctl_socket);
++			vde_realpath(optarg, ctl_socket);
+ 			break;
+ 		case 'm':
+ 			sscanf(optarg,"%o",&mode);
+@@ -254,7 +255,7 @@
+ 
+ void start_datasock(void)
+ {
+-	ctl_socket = (geteuid()==0)?VDESTDSOCK:VDETMPSOCK;
++	strcpy(ctl_socket,(geteuid()==0)?VDESTDSOCK:VDETMPSOCK);
+ 	swmi.swmnopts=Nlong_options;
+ 	swmi.swmopts=long_options;
+ 	swmi.usage=usage;

Modified: vde2/trunk/debian/rules
===================================================================
--- vde2/trunk/debian/rules	2008-08-19 08:57:40 UTC (rev 211)
+++ vde2/trunk/debian/rules	2008-10-01 12:33:33 UTC (rev 212)
@@ -33,6 +33,33 @@
 #major=`ls src/.libs/lib*.so.* | \
 # awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
 
+# Apply patches to the package
+patch: patch-stamp
+patch-stamp:
+	dh_testdir
+	@patches=debian/patches/*.patch; for patch in $$patches; do \
+		test -f $$patch || continue; \
+		echo "Applying $$patch"; \
+		patch -stuN -p1 < $$patch || exit 1; \
+	done
+	touch $@
+
+# Remove patches from the package
+unpatch:
+	dh_testdir
+	@if test -f patch-stamp; then \
+		patches=debian/patches/*.patch; \
+		for patch in $$patches; do \
+			reversepatches="$$patch $$reversepatches"; \
+		done; \
+		for patch in $$reversepatches; do \
+			test -f $$patch || continue; \
+			echo "Reversing $$patch"; \
+			patch -suRf -p1 < $$patch || exit 1; \
+		done; \
+		rm -f patch-stamp; \
+	fi
+
 config.status: configure
 	dh_testdir
 	# Add here commands to configure the package.
@@ -40,7 +67,7 @@
 	#LDFLAGS="-Wl,-z,defs"
 
 
-build: build-stamp
+build: patch build-stamp 
 build-stamp:  config.status
 	dh_testdir
 
@@ -49,7 +76,7 @@
 
 	touch $@
 
-clean:
+clean: unpatch
 	dh_testdir
 	dh_testroot
 	rm -f build-stamp 




More information about the Pkg-vsquare-changes mailing list