Port quagga to -ng
authorFlorian Fainelli <florian@openwrt.org>
Mon, 7 Aug 2006 09:53:12 +0000 (09:53 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Mon, 7 Aug 2006 09:53:12 +0000 (09:53 +0000)
SVN-Revision: 4502

net/quagga/Makefile [new file with mode: 0644]
net/quagga/files/quagga.init [new file with mode: 0644]
net/quagga/patches/quagga-cross.patch [new file with mode: 0644]
net/quagga/patches/quagga-readline.patch [new file with mode: 0644]

diff --git a/net/quagga/Makefile b/net/quagga/Makefile
new file mode 100644 (file)
index 0000000..4236842
--- /dev/null
@@ -0,0 +1,188 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id$
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=quagga
+PKG_VERSION:=0.98.5
+PKG_RELEASE:=1
+PKG_MD5SUM:=ec09c1ec624aea98e18aa19282666784
+
+PKG_SOURCE_URL:=http://www.quagga.net/download/ \
+                http://www.de.quagga.net/download/ \
+                http://www.uk.quagga.net/download/
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_CAT:=zcat
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/quagga
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=The Quagga Software Routing Suite
+  DESCRIPTION:=A routing software package that provides TCP/IP based routing services\\\
+       with routing protocols support such as RIPv1, RIPv2, RIPng, OSPFv2,\\\
+       OSPFv3, BGP-4, and BGP-4+\\\
+  URL:=http://www.quagga.net
+  MENU:=1
+endef
+
+define Package/quagga-libzebra
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=quagga
+  TITLE:=zebra library
+endef
+
+define Package/quagga-libospf
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=quagga
+  TITLE:=OSPF library
+endef
+
+define Package/quagga-bgpd
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=quagga
+  TITLE:=BGPv4, BGPv4+, BGPv4- routing engine
+endef
+
+define Package/quagga-isisd
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=quagga
+  TITLE:=IS-IS routing engine
+endef
+
+define Package/quagga-ospfd
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=quagga quagga-libospf
+  TITLE:=OSPFv2 routing engine
+endef
+
+define Package/quagga-ospf6d
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=quagga quagga-libospf
+  TITLE:=OSPFv3 routing engine
+endef
+
+define Package/quagga-ripd
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=quagga
+  TITLE:=RIP routing engine
+endef
+
+define Package/quagga-ripngd
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=quagga
+  TITLE:=RIPNG routing engine
+endef
+
+define Package/quagga-vtysh
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=quagga +libreadline +libncurses
+  TITLE:=integrated shell for Quagga routing software
+endef
+
+define Build/Configure
+$(call Build/Configure/Default, --enable-shared \
+               --disable-static \
+               --enable-ipv6 \
+               --enable-vtysh \
+               --enable-user=quagga \
+               --enable-group=quagga \
+               --enable-multipath=8 \
+               --enable-isisd)
+endef
+
+define Build/Compile   
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               DESTDIR=$(PKG_INSTALL_DIR) \
+               all install
+endef
+
+define Package/quagga/install  
+       install -d -m0755 $(1)/usr/sbin
+       $(CP) $(PKG_INSTALL_DIR)/usr/sbin/zebra $(1)/usr/sbin/
+       $(CP) $(PKG_INSTALL_DIR)/usr/sbin/watchquagga $(1)/usr/sbin/
+       # avoid /etc being set to 0750
+       install -d -m0755 $(1)/etc/quagga/
+       chmod 0750 $(1)/etc/quagga/
+       install -d -m0755 $(1)/etc/init.d/
+       install -m0755 ./files/quagga.init $(1)/etc/init.d/quagga
+       ln -sf quagga $(1)/etc/init.d/S49quagga
+       install -d -m0755 $(1)/var/run/quagga
+endef
+
+define Package/quagga-bgpd/install     
+       install -d -m0755 $(1)/usr/sbin
+       $(CP) $(PKG_INSTALL_DIR)/usr/sbin/bgpd $(1)/usr/sbin/
+endef
+
+define Package/quagga-isisd/install
+       install -d -m0755 $(1)/usr/sbin
+       $(CP) $(PKG_INSTALL_DIR)/usr/sbin/isisd $(1)/usr/sbin
+endef
+
+define Package/quagga-ospfd/install    
+       install -d -m0755 $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libospf.so.* $(1)/usr/lib/
+       install -d -m0755 $(1)/usr/sbin
+       $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ospfd $(1)/usr/sbin/
+endef
+
+define Package/quagga-ospf6d/install   
+       install -d -m0755 $(1)/usr/sbin
+       $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ospf6d $(1)/usr/sbin/
+endef
+
+define Package/quagga-ripd/install     
+       install -d -m0755 $(1)/usr/sbin
+       $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ripd $(1)/usr/sbin/
+endef
+
+define Package/quagga-ripngd/install   
+       install -d -m0755 $(1)/usr/sbin
+       $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ripngd $(1)/usr/sbin/
+endef
+
+define Package/quagga-vtysh/install    
+       install -d -m0755 $(1)/usr/bin
+       $(CP) $(PKG_INSTALL_DIR)/usr/bin/vtysh $(1)/usr/bin/
+endef
+
+define Package/quagga-libospf/install
+       install -d -m0755 $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libospf.so.* $(1)/usr/lib/
+endef
+
+define Package/quagga-libzebra/install
+       install -d -m0755 $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libzebra.so.* $(1)/usr/lib
+endef
+
+$(eval $(call BuildPackage,quagga))
+$(eval $(call BuildPackage,quagga-libzebra))
+$(eval $(call BuildPackage,quagga-libospf))
+$(eval $(call BuildPackage,quagga-bgpd))
+$(eval $(call BuildPackage,quagga-isisd))
+$(eval $(call BuildPackage,quagga-ospfd))
+$(eval $(call BuildPackage,quagga-ospf6d))
+$(eval $(call BuildPackage,quagga-ripd))
+$(eval $(call BuildPackage,quagga-ripngd))
+$(eval $(call BuildPackage,quagga-vtysh))
diff --git a/net/quagga/files/quagga.init b/net/quagga/files/quagga.init
new file mode 100644 (file)
index 0000000..01f8d71
--- /dev/null
@@ -0,0 +1,333 @@
+#!/bin/sh
+#
+# quagga       Starts/stops quagga daemons and watchquagga.
+#              Create a daemon.conf file to have that routing daemon
+#              started/stopped automagically when using this script
+#              without any daemon names as args.
+#              If watchquagga is available, it will also be
+#              started/stopped if the script is called without
+#              any daemon names.
+#
+
+ME=$(basename $0)
+
+usage() {
+       echo "Usage: ${ME} {start|stop|restart} [daemon ...]"
+       exit 2
+}
+
+if [ -z "$1" ]
+then
+       usage
+else
+       COMMAND=$1
+fi
+shift
+ARG_DAEMONS=$*
+BINDIR=/usr/sbin
+CONFDIR=/etc/quagga
+STATEDIR=/var/run/quagga
+DAEMONS="zebra ripd ripngd ospfd ospf6d bgpd"
+DAEMON_FLAGS=-d
+WATCHQUAGGA_FLAGS="-d -z -T 60 -R"
+WATCHQUAGGA_CMD="$0 watchrestart"
+if [ ${COMMAND} != "watchrestart" ]
+then
+       DAEMONS="${DAEMONS} watchquagga"
+fi
+DAEMONS_STARTSEQ=${DAEMONS}
+
+reverse()
+{
+       local revlist r
+        revlist=
+        for r
+       do
+                revlist="$r $revlist"
+        done
+        echo $revlist
+}
+
+DAEMONS_STOPSEQ=$(reverse ${DAEMONS_STARTSEQ})
+
+#pidof() {
+#      ps ax | awk 'match($5, "(^|/)'"$1"'$") > 0 { printf " %s", $1 }'
+#}
+
+quit() {
+       echo "${ME}: $1"
+       exit 0
+}
+
+die() {
+       echo "${ME}: $1"
+       exit 1
+}
+
+is_in() {
+       local i
+       for i in $2
+       do
+               [ "$1" = "$i" ] && return 0
+       done
+       return 1
+}
+
+select_subset() {
+       local unknown i j
+       unknown=
+       RESULT=
+       for i in $1
+       do
+               is_in $i "$2" || unknown="$unknown $i"
+       done
+       if [ -n "$unknown" ]
+       then
+               RESULT=$unknown
+               return 1
+       else
+               for j in $2
+               do
+                       is_in $j "$1" && RESULT="$RESULT $j"
+               done
+               return 0
+       fi
+}
+
+# check command
+
+case ${COMMAND}
+in
+       start|stop|restart)
+               ;;
+       watchrestart)
+               if [ -n "$ARG_DAEMONS" ]
+               then
+                       echo "${ME}: watchrestart mode is only for use by watchquagga"
+                       exit 2
+               fi
+               ;;
+       *)
+               usage
+               ;;
+esac
+
+# select daemons to start
+
+case ${COMMAND}
+in
+       start|restart|watchrestart)
+               START_DAEMONS=
+               for d in ${DAEMONS_STARTSEQ}
+               do
+                       [ -x "${BINDIR}/${d}" -a -f "${CONFDIR}/${d}.conf" ] \
+                       && START_DAEMONS="${START_DAEMONS}${d} "
+               done
+               WATCHQUAGGA_DAEMONS=${START_DAEMONS}
+               if is_in watchquagga "${DAEMONS_STARTSEQ}"
+               then
+                       START_DAEMONS="${START_DAEMONS} watchquagga"
+               fi
+               if [ -n "${ARG_DAEMONS}" ]
+               then
+                       if select_subset "${ARG_DAEMONS}" "${DAEMONS}"
+                       then
+                               if select_subset "${ARG_DAEMONS}" "${START_DAEMONS}"
+                               then
+                                       START_DAEMONS=${RESULT}
+                               else
+                                       die "these daemons are not startable:${RESULT}."
+                               fi
+                       else
+                               die "unknown daemons:${RESULT}; choose from: ${DAEMONS}."
+                       fi
+               fi
+               ;;
+esac
+
+# select daemons to stop
+
+case ${COMMAND}
+in
+       stop|restart|watchrestart)
+               STOP_DAEMONS=${DAEMONS_STOPSEQ}
+               if [ -n "${ARG_DAEMONS}" ]
+               then
+                       if select_subset "${ARG_DAEMONS}" "${STOP_DAEMONS}"
+                       then
+                               STOP_DAEMONS=${RESULT}
+                       else
+                               die "unknown daemons:${RESULT}; choose from: ${DAEMONS}."
+                       fi
+               fi
+               stop_daemons=
+               for d in ${STOP_DAEMONS}
+               do
+                       pidfile=${STATEDIR}/${d}.pid
+                       if [ -f "${pidfile}" -o -n "$(pidof ${d})" ]
+                       then
+                               stop_daemons="${stop_daemons}${d} "
+                       elif [ -n "${ARG_DAEMONS}" ]
+                       then
+                               echo "${ME}: found no ${d} process running."
+                       fi
+               done
+               STOP_DAEMONS=${stop_daemons}
+               ;;
+esac
+
+# stop daemons
+
+for d in $STOP_DAEMONS
+do
+       echo -n "${ME}: Stopping ${d} ... "
+       pidfile=${STATEDIR}/${d}.pid
+       if [ -f "${pidfile}" ]
+       then
+               file_pid=$(cat ${pidfile})
+               if [ -z "${file_pid}" ]
+               then
+                       echo -n "no pid file entry found ... "
+               fi
+       else
+               file_pid=
+               echo -n "no pid file found ... "
+       fi
+       proc_pid=$(pidof ${d})
+       if [ -z "${proc_pid}" ]
+       then
+               echo -n "found no ${d} process running ... "
+       else
+               count=0
+               notinpidfile=
+               for p in ${proc_pid}
+               do
+                       count=$((${count}+1))
+                       if kill ${p}
+                       then
+                               echo -n "killed ${p} ... "
+                       else
+                               echo -n "failed to kill ${p} ... "
+                       fi
+                       [ "${p}" = "${file_pid}" ] \
+                       || notinpidfile="${notinpidfile} ${p}"
+               done
+               [ ${count} -le 1 ] \
+               || echo -n "WARNING: ${count} ${d} processes were found running ... "
+               for n in ${notinpidfile}
+               do
+                       echo -n "WARNING: process ${n} was not in pid file ... "
+               done
+       fi
+       count=0
+       survivors=$(pidof ${d})
+       while [ -n "${survivors}" ]
+       do
+               sleep 1
+               count=$((${count}+1))
+               survivors=$(pidof ${d})
+               [ -z "${survivors}" -o ${count} -gt 5 ] && break
+               for p in ${survivors}
+               do
+                       sleep 1
+                       echo -n "${p} "
+                       kill ${p}
+               done
+       done
+       survivors=$(pidof ${d})
+       [ -n "${survivors}" ] && \
+       if kill -KILL ${survivors}
+       then
+               echo -n "KILLed ${survivors} ... "
+       else
+               echo -n "failed to KILL ${survivors} ... "
+       fi
+       sleep 1
+       survivors=$(pidof ${d})
+       if [ -z "${survivors}" ]
+       then
+               echo -n "done."
+               if [ -f "${pidfile}" ]
+               then
+                       rm -f ${pidfile} \
+                       || echo -n " Failed to remove pidfile."
+               fi
+       else
+               echo -n "failed to stop ${survivors} - giving up."
+               if [ "${survivors}" != "${file_pid}" ]
+               then
+                       if echo "${survivors}" > ${pidfile}
+                       then
+                               chown quagga:quagga ${pidfile}
+                               echo -n " Wrote ${survivors} to pidfile."
+                       else
+                               echo -n " Failed to write ${survivors} to pidfile."
+                       fi
+               fi
+       fi
+       echo
+done
+
+# start daemons
+
+if [ -n "$START_DAEMONS" ]
+then
+       [ -d ${CONFDIR} ] \
+       || quit "${ME}: no config directory ${CONFDIR} - exiting."
+       chown -R quagga:quagga ${CONFDIR}
+       [ -d ${STATEDIR} ] || mkdir -p ${STATEDIR} \
+       || die "${ME}: could not create state directory ${STATEDIR} - exiting."
+       chown -R quagga:quagga ${STATEDIR}
+
+       for d in $START_DAEMONS
+       do
+               echo -n "${ME}: Starting ${d} ... "
+               proc_pid=$(pidof ${d})
+               pidfile=${STATEDIR}/${d}.pid
+               file_pid=
+               if [ -f "${pidfile}" ]
+               then
+                       file_pid=$(cat ${pidfile})
+                       if [ -n "${file_pid}" ]
+                       then
+                               echo -n "found old pid file entry ${file_pid} ... "
+                       fi
+               fi
+               if [ -n "${proc_pid}" ]
+               then
+                       echo -n "found ${d} running (${proc_pid}) - skipping ${d}."
+                       if [ "${proc_pid}" != "${file_pid}" ]
+                       then
+                               if echo "${proc_pid}" > ${pidfile}
+                               then
+                                       chown quagga:quagga ${pidfile}
+                                       echo -n " Wrote ${proc_pid} to pidfile."
+                               else
+                                       echo -n " Failed to write ${proc_pid} to pidfile."
+                               fi
+                       fi
+               elif rm -f "${pidfile}"
+               then
+                       if [ "${d}" = "watchquagga" ]
+                       then
+                               $("${BINDIR}/${d}" \
+                                       ${WATCHQUAGGA_FLAGS} \
+                                       "${WATCHQUAGGA_CMD}" \
+                                       ${WATCHQUAGGA_DAEMONS})
+                               status=$?
+                       else
+                               $("${BINDIR}/${d}" ${DAEMON_FLAGS})
+                               status=$?
+                       fi
+                       if [ $status -eq 0 ]
+                       then
+                               echo -n "done."
+                       else
+                               echo -n "failed."
+                       fi
+               else
+                       echo -n " failed to remove pidfile."
+               fi
+               echo
+       done
+fi
diff --git a/net/quagga/patches/quagga-cross.patch b/net/quagga/patches/quagga-cross.patch
new file mode 100644 (file)
index 0000000..5b8276b
--- /dev/null
@@ -0,0 +1,84 @@
+--- quagga-0.98.4/configure.orig       Mon Jun 27 19:05:31 2005
++++ quagga-0.98.4/configure    Mon Jul 11 20:32:07 2005
+@@ -12623,69 +12623,6 @@
+-echo "$as_me:$LINENO: checking for broken CMSG_FIRSTHDR" >&5
+-echo $ECHO_N "checking for broken CMSG_FIRSTHDR... $ECHO_C" >&6
+-if test "$cross_compiling" = yes; then
+-  echo "$as_me:$LINENO: result: no" >&5
+-echo "${ECHO_T}no" >&6
+-else
+-  cat >conftest.$ac_ext <<_ACEOF
+-/* confdefs.h.  */
+-_ACEOF
+-cat confdefs.h >>conftest.$ac_ext
+-cat >>conftest.$ac_ext <<_ACEOF
+-/* end confdefs.h.  */
+-
+-#ifdef SUNOS_5
+-#define _XPG4_2
+-#define __EXTENSIONS__
+-#endif
+-#include <stdlib.h>
+-#include <sys/types.h>
+-#include <sys/socket.h>
+-
+-main()
+-{
+-  struct msghdr msg;
+-  char buf[4];
+-
+-  msg.msg_control = buf;
+-  msg.msg_controllen = 0;
+-
+-  if (CMSG_FIRSTHDR(&msg) != NULL)
+-    exit(0);
+-  exit (1);
+-}
+-_ACEOF
+-rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+-  (eval $ac_link) 2>&5
+-  ac_status=$?
+-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  echo "$as_me:$LINENO: result: yes - using workaround" >&5
+-echo "${ECHO_T}yes - using workaround" >&6
+-cat >>confdefs.h <<\_ACEOF
+-#define HAVE_BROKEN_CMSG_FIRSTHDR
+-_ACEOF
+-
+-else
+-  echo "$as_me: program exited with status $ac_status" >&5
+-echo "$as_me: failed program was:" >&5
+-sed 's/^/| /' conftest.$ac_ext >&5
+-
+-( exit $ac_status )
+-echo "$as_me:$LINENO: result: no" >&5
+-echo "${ECHO_T}no" >&6
+-fi
+-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+-fi
+-
+ echo "$as_me:$LINENO: checking route read method check" >&5
+ echo $ECHO_N "checking route read method check... $ECHO_C" >&6
+ if test "${zebra_rtread+set}" = set; then
+@@ -12783,10 +12720,7 @@
+ if test "${zebra_ipforward_path+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+-  for zebra_ipforward_path in /proc/net/snmp /dev/ip /dev/null;
+-do
+-  test x`ls $zebra_ipforward_path 2>/dev/null` = x"$zebra_ipforward_path" && break
+-done
++  zebra_ipforward_path="/proc/net/snmp"
+ case $zebra_ipforward_path in
+   "/proc/net/snmp")  IPFORWARD=ipforward_proc.o
+                      zebra_ipforward_path="proc";;
diff --git a/net/quagga/patches/quagga-readline.patch b/net/quagga/patches/quagga-readline.patch
new file mode 100644 (file)
index 0000000..8e3b805
--- /dev/null
@@ -0,0 +1,58 @@
+--- quagga-0.98.4/configure.orig       Mon Jun 27 19:05:31 2005
++++ quagga-0.98.4/configure    Thu Jul 28 07:02:12 2005
+@@ -10937,7 +10937,7 @@
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lcurses  $LIBS"
++#LIBS="-lcurses  $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+@@ -11071,7 +11071,8 @@
+ #define HAVE_LIBNCURSES 1
+ _ACEOF
+-  LIBS="-lncurses $LIBS"
++#  LIBS="-lncurses $LIBS"
++CURSES=-lncurses
+ fi
+@@ -11088,7 +11089,7 @@
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline  $LIBS"
++LIBS="-lreadline $CURSES $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+@@ -11144,7 +11145,8 @@
+ #define HAVE_LIBREADLINE 1
+ _ACEOF
+-  LIBS="-lreadline $LIBS"
++#  LIBS="-lreadline $LIBS"
++CURSES="$CURSES -lreadline"
+ fi
+@@ -11303,7 +11305,7 @@
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline  $LIBS"
++LIBS="-lreadline $CURSES $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+@@ -11365,7 +11367,7 @@
+ #define HAVE_LIBREADLINE 1
+ _ACEOF
+-  LIBS="-lreadline $LIBS"
++#  LIBS="-lreadline $LIBS"
+ fi