PATCH: ipvsadm build process

Horms horms at verge.net.au
Wed Jun 5 08:58:40 BST 2002


On Wed, Jun 05, 2002 at 08:48:18AM +0200, Roberto Nibali wrote:
> Hello Horms,

Hey mate,

> I like it. Can we have it, Wensong? It makes maintaining the user space 
> part easier throughout updates in a distro. And I'm maintaining two 
> distros myself.
> 
> >Only in ipvsadm.new/: .Makefile.swp
> >Only in ipvsadm.new/: .done
> 
> Do make distclean next time, ok? :)

The .done shouldn't have been there in the first place.
It was produced in error by make distcheck. I have resolve this
problem.

> >+distclean-1:
> >+		rm -rf "$(NAME)-$(VERSION)/" "$(NAME)-$(VERSION).tar" \
> >+		"$(NAME)-$(VERSION).tar.gz"
> >+distclean: 	distclean-1 clean
> >+		rm -rf "$(NAME)-$(VERSION)/" "$(NAME)-$(VERSION).tar" \
> >+			"$(NAME)-$(VERSION).tar.gz"
> >+
> 
> What is the distclean-1 for? What did I miss?

distclean-1 is a depandancy for distclean and dist. The idea being
that the code is shared. Amusingly I included the code in the
discclean target by mistake. It should read:

distclean-1:
            rm -rf "$(NAME)-$(VERSION)/" "$(NAME)-$(VERSION).tar" \
            "$(NAME)-$(VERSION).tar.gz"

distclean:  distclean-1 clean



Attached is a new version of the patch, which rectifies both or the
problems above as well as a few other trivial problems. This patch
replaces the earlier version of the patch.

-- 
Horms
        
-------------- next part --------------
diff -ruN ipvsadm/Makefile ipvsadm.new/Makefile
--- ipvsadm/Makefile	Wed Jun  5 11:00:23 2002
+++ ipvsadm.new/Makefile	Wed Jun  5 16:54:46 2002
@@ -22,6 +22,14 @@
 #                     :   Added autodetection of libpot
 #                     :   Added BUILD_ROOT support
 #      Wensong        :   Changed the OBJS according to detection
+#      Horms          :   Build recursively
+#                     :   Dist done in place
+#                     :   Install sysconfig file as appropriate
+#                     :   Distcheck tries to build from dist tar ball
+#                     :   Distclean cleans the tree rather than building it
+#                     :   Destination directories can be configured
+#                     :   using environment variables
+#                     :   Include net/ip_vs.h in dest tar ball
 #
 
 NAME	= ipvsadm
@@ -29,16 +37,20 @@
 RELEASE	= 7
 SCHEDULERS = "$(shell cat SCHEDULERS)"
 
-CC	= gcc
-CFLAGS	= -Wall -Wunused -Wstrict-prototypes -g -O2
-SBIN    = $(BUILD_ROOT)/sbin
-MANDIR	= usr/man
-MAN	= $(BUILD_ROOT)/$(MANDIR)/man8
-INIT    = $(BUILD_ROOT)/etc/rc.d/init.d
-MKDIR   = mkdir
-INSTALL = install
-INCLUDE = -I/usr/src/linux/include -I.. -I.
-STATIC_LIBS = libipvs/libipvs.a
+CC	    = gcc
+INCLUDE     = -I/usr/src/linux/include -I. -I./net -I..
+CFLAGS	    = -Wall -Wunused -Wstrict-prototypes -g -O2 $(INCLUDE)
+SBINDIR     = /sbin
+SBIN_DIR    = $(BUILD_ROOT)/$(SBINDIR)
+MANDIR      = /usr/man
+MAN_DIR	    = $(BUILD_ROOT)/$(MANDIR)/man8
+INITDIR     = /etc/init.d
+INIT_DIR    = $(BUILD_ROOT)/$(INITDIR)
+SYSCONFIGDIR  = /etc/sysconfig
+SYSCONFIG_DIR = $(BUILD_ROOT)/$(SYSCONFIGDIR)
+MKDIR       = mkdir
+INSTALL     = install
+
 
 
 #####################################
@@ -64,49 +76,90 @@
 POPT_DEFINE = -DHAVE_POPT
 endif
 
-OBJS = ipvsadm.o config_stream.o dynamic_array.o
+SRC = $(wildcard *.c)
+HDR = $(wildcard *.h)
+MAN = $(wildcard *.8)
+SBIN_SCRIPT = ipvsadm-restore ipvsadm-save 
+BIN = ipvsadm
+OBJS = $(SRC:.c=.o)
+SPEC_IN = ipvsadm.spec.in
+SPEC = $(SPEC_IN:.in=)
 LIBS = $(POPT_LIB)
 DEFINES = -DVERSION=\"$(VERSION)\" -DSCHEDULERS=\"$(SCHEDULERS)\" \
 	  $(POPT_DEFINE) $(IP_VS_H_DEFINE)
+EXTRA_DIST= Makefile README SCHEDULERS VERSION ipvsadm.c ipvsadm.sh \
+ipvsadm.sysconfig
+DIST = $(SRC) $(HDR) $(MAN) $(SBIN_SCRIPT) $(SPEC) $(SPEC_IN) $(EXTRA_DIST)
+STATIC_LIBS = libipvs/libipvs.a
+SUBDIRS     = debian libipvs
 
-.PHONY = all clean install dist distclean rpm rpms
+.PHONY = all clean install dist distclean distclean-1 distcheck \
+rpm rpms deb debs
 
-all:            ipvsadm
+all:            subdir-all $(BIN)
 
-ipvsadm:	$(OBJS) $(STATIC_LIBS)
-		$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+subdir-all:
+		for i in $(SUBDIRS); do \
+			make -C $$i all; \
+		done
+
+$(BIN):		$(OBJS)
+		$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(STATIC_LIBS)
 
 install:        ipvsadm
 		strip ipvsadm
-		if [ ! -d $(SBIN) ]; then $(MKDIR) -p $(SBIN); fi
-		$(INSTALL) -m 0755 ipvsadm $(SBIN)
-		$(INSTALL) -m 0755 ipvsadm-save $(SBIN)
-		$(INSTALL) -m 0755 ipvsadm-restore $(SBIN)
-		[ -d $(MAN) ] || $(MKDIR) -p $(MAN)
-		$(INSTALL) -m 0644 ipvsadm.8 $(MAN)
-		$(INSTALL) -m 0644 ipvsadm-save.8 $(MAN)
-		$(INSTALL) -m 0644 ipvsadm-restore.8 $(MAN)
-		if [ -d $(INIT) ]; then \
-		  $(INSTALL) -m 0755 ipvsadm.sh $(INIT)/ipvsadm; \
+		if [ ! -d $(SBIN_DIR) ]; then $(MKDIR) -p $(SBIN_DIR); fi
+		for i in $(SBIN_SCRIPT) $(BIN); do\
+			$(INSTALL) -m 0755 $$i $(SBIN_DIR);\
+		done
+		if [ ! -d $(MAN_DIR) ]; then $(MKDIR) -p $(MAN_DIR); fi
+		for i in $(MAN); do\
+			$(INSTALL) -m 644 $$i $(MAN_DIR);\
+		done
+		if [ -d $(INIT_DIR) ]; then \
+			$(INSTALL) -m 0755 ipvsadm.sh $(INIT_DIR)/ipvsadm; \
+		fi
+		if [ -d $(SYSCONFIG_DIR) ]; then \
+			$(INSTALL) -m 0644 ipvsadm.sysconfig \
+		  		$(SYSCONFIG_DIR)/ipvsadm;\
 		fi
+		for i in $(SUBDIRS); do \
+			make -C $$i install; \
+		done
 
 clean:
-		rm -f ipvsadm $(NAME).spec $(NAME)-$(VERSION).tar.gz
-		rm -rf debian/tmp
-		find . -name '*.[ao]' -o -name "*~" -o -name "*.orig" \
-		  -o -name "*.rej" -o -name core | xargs rm -f
-
-distclean:	dist
-
-dist:		clean
-		sed -e "s/@@VERSION@@/$(VERSION)/g" \
-		    -e "s/@@RELEASE@@/$(RELEASE)/g" \
-		    < ipvsadm.spec.in > ipvsadm.spec
-		( cd .. ; tar czvf $(NAME)-$(VERSION).tar.gz \
-			--exclude CVS \
-			--exclude $(NAME)-$(VERSION).tar.gz \
-			ipvsadm ; \
-			mv $(NAME)-$(VERSION).tar.gz ipvsadm )
+		rm -f $(BIN) $(NAME).spec $(NAME)-$(VERSION).tar.gz
+		rm -f *.[ao] *~ *.orig *.rej core
+		for i in $(SUBDIRS); do \
+			make -C $$i clean; \
+		done
+
+distclean-1:
+		rm -rf "$(NAME)-$(VERSION)/" "$(NAME)-$(VERSION).tar" \
+		"$(NAME)-$(VERSION).tar.gz"
+
+distclean: 	distclean-1 clean
+
+dist: 		distclean-1 $(SPEC)
+		mkdir "$(NAME)-$(VERSION)/"
+		cp $(DIST) "$(NAME)-$(VERSION)/"
+		mkdir "$(NAME)-$(VERSION)/net/"
+		cp ../ip_vs.h "$(NAME)-$(VERSION)/net/"
+		for i in $(SUBDIRS); do \
+			DISTDIR="../$(NAME)-$(VERSION)/$$i" make -C $$i dist; \
+		done
+		tar -cf "$(NAME)-$(VERSION).tar" "$(NAME)-$(VERSION)/"
+		gzip --best "$(NAME)-$(VERSION).tar"
+		rm -rf "$(NAME)-$(VERSION)/"
+
+distcheck: 	dist
+		tar -zxf "$(NAME)-$(VERSION).tar.gz"
+		( cd "$(NAME)-$(VERSION)";\
+			BUILD_ROOT="`pwd`/.done/" make distclean all install)
+		rm -r "$(NAME)-$(VERSION)/"
+		@echo "#######################################################"
+		@echo "# $(NAME)-$(VERSION).tar.gz is ready for distribution"
+		@echo "#######################################################"
 
 rpm:		rpms
 
@@ -120,7 +173,10 @@
 debs:
 		dpkg-buildpackage
 
-%.o:	%.c
-		$(CC) $(CFLAGS) $(INCLUDE) $(DEFINES) -o $@ -c $<
+%.o:		%.c
+		$(CC) $(CFLAGS) $(DEFINES) -o $@ -c $<
 
-include $(shell echo */Makefile)
+%.spec:		%.spec.in
+		sed -e "s/@@VERSION@@/$(VERSION)/g" \
+		    -e "s/@@RELEASE@@/$(RELEASE)/g" \
+		    < $< > $@
diff -ruN ipvsadm/README ipvsadm.new/README
--- ipvsadm/README	Thu Jan 24 23:23:51 2002
+++ ipvsadm.new/README	Wed Jun  5 16:48:29 2002
@@ -28,7 +28,8 @@
 	/usr/man/man8/ipvsadm.8
 	/usr/man/man8/ipvsadm-save.8
 	/usr/man/man8/ipvsadm-restore.8
-	/etc/rc.d/init.d/ipvsadm
+	/etc/init.d/ipvsadm
+	/etc/sysconfig/ipvsadm
 This will be done automatically when calling
 	make install
 in the source directory.
diff -ruN ipvsadm/debian/Makefile ipvsadm.new/debian/Makefile
--- ipvsadm/debian/Makefile	Thu Jan  1 09:00:00 1970
+++ ipvsadm.new/debian/Makefile	Wed Jun  5 16:38:13 2002
@@ -0,0 +1,34 @@
+#      ipvsadm - IP Virtual Server ADMinistration program
+#                for IPVS NetFilter Module in kernel 2.4
+#
+#      Version: $Id: Makefile,v 1.18 2002/05/30 13:00:24 wensong Exp $
+#
+#      Authors: Wensong Zhang <wensong at linux-vs.org>
+#               Peter Kese <peter.kese at ijs.si>
+#
+#      This file:
+#
+#      ChangeLog
+#
+#      Horms          :   Created
+
+EXTRA_DIST = Makefile changelog control copyright ipvsadm.dirs ipvsadm.files \
+rules
+DIST = $(EXTRA_DIST)
+
+.PHONY = all clean install dist distclean rpm rpms
+
+all:
+
+install:
+
+clean:
+		rm -f *.[ao] *~ *.orig *.rej core
+		rm -f *.substvars *.debhelper files
+		rm -r -f ipvsadm tmp
+
+distclean:	clean
+
+dist:	
+		mkdir "$(DISTDIR)/"
+		cp $(DIST) "$(DISTDIR)/"
Binary files ipvsadm/ipvsadm-1.20.tar.gz and ipvsadm.new/ipvsadm-1.20.tar.gz differ
diff -ruN ipvsadm/ipvsadm.sh ipvsadm.new/ipvsadm.sh
--- ipvsadm/ipvsadm.sh	Thu May 10 23:17:41 2001
+++ ipvsadm.new/ipvsadm.sh	Wed Jun  5 10:38:01 2002
@@ -28,9 +28,9 @@
 fi
 
 # Use the funtions provided by Red Hat or use our own
-if [ -f /etc/rc.d/init.d/functions ]
+if [ -f /etc/init.d/functions ]
 then
-  . /etc/rc.d/init.d/functions
+  . /etc/init.d/functions
 else
   function action {
     echo "$1"
diff -ruN ipvsadm/ipvsadm.spec ipvsadm.new/ipvsadm.spec
--- ipvsadm/ipvsadm.spec	Thu Jan  1 09:00:00 1970
+++ ipvsadm.new/ipvsadm.spec	Wed Jun  5 16:49:57 2002
@@ -0,0 +1,99 @@
+%define prefix   /usr
+
+Summary: Utility to administer the Linux Virtual Server
+Name: ipvsadm
+Version: 1.20
+Release: 7
+Copyright: GNU General Public Licence
+URL: http://www.LinuxVirtualServer.org/
+Group: Applications/System
+Source0: http://www.LinuxVirtualServer.org/software/%{name}-%{version}.tar.gz
+BuildRoot: /var/tmp/%name-%{PACKAGE_VERSION}-root
+Docdir: %{prefix}/doc
+Provides: %{name}-%{version}
+Conflicts: piranha <= 0.4.14
+
+%description
+ipvsadm is a utility to administer the IP Virtual Server services
+offered by the Linux kernel augmented with the IP Virtual Server patch.
+
+
+%prep
+%setup -n %{name}-%{version}
+
+
+%build
+CFLAGS="${RPM_OPT_FLAGS}" make
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p ${RPM_BUILD_ROOT}/{sbin,%{_mandir}/man8,etc/{init.d,sysconfig}}
+make install BUILD_ROOT=${RPM_BUILD_ROOT} MANDIR=%{_mandir} \
+	SBINDIR=/sbin INITDIR=%{_sysconfdir}/init.d \
+	SYSCONFIGDIR=%{_sysconfdir}/sysconfig
+
+
+%files
+%defattr(-,root,root)
+%doc README
+%config /etc/init.d/ipvsadm
+%config /etc/sysconfig/ipvsadm
+/sbin/ipvsadm*
+%{_mandir}/man8/ipvsadm*
+
+%post
+/sbin/chkconfig --add ipvsadm
+
+%preun
+/sbin/chkconfig --del ipvsadm
+
+
+%clean
+rm -rf $RPM_BUILD_DIR/%{name}
+rm -rf $RPM_BUILD_ROOT
+
+
+%changelog
+* Fri Jun 5 2002 Horms <horms at vergenet.net>
+- Include /etc/sysconfig/ipvsadm in RPM
+- Install init script into /etc/init.d instead of /etc/init.d/rc.d
+
+* Thu Dec 16 2001 Wensong Zhang <wensong at linuxvirtualserver.org>
+- Changed to install ipvsadm man pages according to the %{_mandir}
+
+* Thu Dec 30 2000 Wensong Zhang <wensong at linuxvirtualserver.org>
+- update the %file section
+
+* Thu Dec 17 2000 Wensong Zhang <wensong at linuxvirtualserver.org>
+- Added a if-condition to keep both new or old rpm utility building
+  the package happily.
+
+* Tue Dec 12 2000 P.opeland <bryce at redhat.com>
+- Small modifications to make the compiler happy in RH7 and the Alpha
+- Fixed the documentation file that got missed off in building
+  the rpm
+- Made a number of -pedantic mods though popt will not compile with
+  -pedantic
+
+* Wed Aug 9 2000 Horms <horms at vergenet.net>
+- Removed Obseletes tag as ipvsadm is back in /sbin where it belongs 
+  as it is more or less analogous to both route and ipchains both of
+  which reside in /sbin.
+- Create directory to install init script into. Init scripts won't install
+  into build directory unless this is done
+
+* Thu Jul  6 2000 Wensong Zhang <wensong at linuxvirtualserver.org>
+- Changed to build rpms on the ipvsadm tar ball directly
+
+* Wed Jun 21 2000 P.Copeland <copeland at redhat.com>
+- fixed silly install permission settings
+
+* Mon Jun 19 2000 P.Copeland <copeland at redhat.com>
+- Added 'dist' and 'rpms' to the Makefile
+- Added Obsoletes tag since there were early versions
+  of ipvsadm-*.rpm that installed in /sbin
+- Obsolete tag was a bit vicious re: piranha
+
+* Mon Apr 10 2000 Horms <horms at vergenet.net>
+- created for version 1.9
diff -ruN ipvsadm/ipvsadm.spec.in ipvsadm.new/ipvsadm.spec.in
--- ipvsadm/ipvsadm.spec.in	Thu Jan 24 23:23:51 2002
+++ ipvsadm.new/ipvsadm.spec.in	Wed Jun  5 13:55:35 2002
@@ -7,7 +7,7 @@
 Copyright: GNU General Public Licence
 URL: http://www.LinuxVirtualServer.org/
 Group: Applications/System
-Source0: http://www.LinuxVirtualServer.org/software/ipvsadm-%{version}.tar.gz
+Source0: http://www.LinuxVirtualServer.org/software/%{name}-%{version}.tar.gz
 BuildRoot: /var/tmp/%name-%{PACKAGE_VERSION}-root
 Docdir: %{prefix}/doc
 Provides: %{name}-%{version}
@@ -19,7 +19,7 @@
 
 
 %prep
-%setup -n ipvsadm
+%setup -n %{name}-%{version}
 
 
 %build
@@ -28,14 +28,17 @@
 
 %install
 rm -rf $RPM_BUILD_ROOT
-mkdir -p ${RPM_BUILD_ROOT}/{sbin,%{_mandir}/man8,etc/rc.d/init.d}
-make install BUILD_ROOT=${RPM_BUILD_ROOT} MANDIR=%{_mandir}
+mkdir -p ${RPM_BUILD_ROOT}/{sbin,%{_mandir}/man8,etc/{init.d,sysconfig}}
+make install BUILD_ROOT=${RPM_BUILD_ROOT} MANDIR=%{_mandir} \
+	SBINDIR=/sbin INITDIR=%{_sysconfdir}/init.d \
+	SYSCONFIGDIR=%{_sysconfdir}/sysconfig
 
 
 %files
 %defattr(-,root,root)
 %doc README
-%config /etc/rc.d/init.d/ipvsadm
+%config /etc/init.d/ipvsadm
+%config /etc/sysconfig/ipvsadm
 /sbin/ipvsadm*
 %{_mandir}/man8/ipvsadm*
 
@@ -52,6 +55,10 @@
 
 
 %changelog
+* Fri Jun 5 2002 Horms <horms at vergenet.net>
+- Include /etc/sysconfig/ipvsadm in RPM
+- Install init script into /etc/init.d instead of /etc/init.d/rc.d
+
 * Thu Dec 16 2001 Wensong Zhang <wensong at linuxvirtualserver.org>
 - Changed to install ipvsadm man pages according to the %{_mandir}
 
diff -ruN ipvsadm/ipvsadm.sysconfig ipvsadm.new/ipvsadm.sysconfig
--- ipvsadm/ipvsadm.sysconfig	Thu Jan  1 09:00:00 1970
+++ ipvsadm.new/ipvsadm.sysconfig	Wed Jun  5 10:38:01 2002
@@ -0,0 +1,7 @@
+######################################################################
+# /etc/sysconfig/ipvsadm
+#
+# To populate this file configure your LVS virtual services and
+# then run /etc/init.d/ipvsadm save
+######################################################################
+
diff -ruN ipvsadm/libipvs/Makefile ipvsadm.new/libipvs/Makefile
--- ipvsadm/libipvs/Makefile	Wed Sep 19 00:42:54 2001
+++ ipvsadm.new/libipvs/Makefile	Wed Jun  5 16:45:13 2002
@@ -1,2 +1,47 @@
+#      ipvsadm - IP Virtual Server ADMinistration program
+#                for IPVS NetFilter Module in kernel 2.4
+#
+#      Version: $Id: Makefile,v 1.18 2002/05/30 13:00:24 wensong Exp $
+#
+#      Authors: Wensong Zhang <wensong at linux-vs.org>
+#               Peter Kese <peter.kese at ijs.si>
+#
+#      This file:
+#
+#      ChangeLog
+#
+#      Horms          :   Added this file
 
-libipvs/libipvs.a: libipvs/libipvs.a(libipvs/libipvs.o)
+CC          = gcc
+INCLUDE     = -I/usr/src/linux/include -I.. -I../net -I../..
+CFLAGS      = -Wall -Wunused -Wstrict-prototypes -g -O2 $(INCLUDE)
+
+SRC = $(wildcard *.c)
+HDR = $(wildcard *.h)
+OBJ = $(SRC:.c=.o)
+STATIC_LIB = libipvs.a
+EXTRA_DIST = Makefile
+DIST = $(EXTRA_DIST) $(SRC) $(HDR)
+
+.PHONY = all clean install dist distclean rpm rpms
+
+all: 		$(STATIC_LIB)
+
+$(STATIC_LIB):	$(OBJ)
+	ar rv $(STATIC_LIB) $(OBJ)
+
+install:
+
+clean:
+		rm -f *.[ao] *~ *.orig *.rej core
+
+distclean:	clean
+
+dist:	
+		mkdir "$(DISTDIR)/"
+		cp $(DIST) "$(DISTDIR)/"
+
+libipvs.a: 	libipvs.o
+
+%.o:		%.c
+		$(CC) $(CFLAGS) $(DEFINES) -o $@ -c $<


More information about the lvs-users mailing list