beanstalkd: add package 4044/head
authorPhilip Prindeville <philipp@redfish-solutions.com>
Mon, 20 Feb 2017 19:34:16 +0000 (12:34 -0700)
committerPhilip Prindeville <philipp@redfish-solutions.com>
Thu, 13 Jul 2017 02:41:19 +0000 (20:41 -0600)
For now building from git using latest SHA (commits are relatively
infrequent).  Set priority to come up immediately after network
interfaces are brought up. Patches have been submitted upstream
(but not yet accepted) to fix:

* a somewhat cross-compile unfriendly makefile;
* a header inclusion issue which causes MUSL compilation warnings;
* using the somewhat arcane posix_fallocate() in favor of the
  more ubiquitous ftruncate() system call instead.

Hopefully the next release will include our submitted fixes and
we can transition to a numbered release.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
net/beanstalkd/Makefile [new file with mode: 0644]
net/beanstalkd/files/beanstalkd.init [new file with mode: 0644]
net/beanstalkd/patches/900-makefile.patch [new file with mode: 0644]
net/beanstalkd/patches/901-fix-headers.patch [new file with mode: 0644]
net/beanstalkd/patches/902-replace-posix_fallocate.patch [new file with mode: 0644]

diff --git a/net/beanstalkd/Makefile b/net/beanstalkd/Makefile
new file mode 100644 (file)
index 0000000..53749a9
--- /dev/null
@@ -0,0 +1,48 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=beanstalkd
+PKG_VERSION:=1.9
+PKG_RELEASE:=1
+
+# for now, build from latest commit since releases are infrequent and
+# useful fixes trickle in...
+PKG_SOURCE_URL:=https://github.com/kr/beanstalkd.git
+PKG_SOURCE_VERSION:=b7b4a6a14b7e8d096dc8cbc255b23be17a228cbb
+
+PKG_SOURCE_PROTO:=git
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-v$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-v$(PKG_VERSION)
+
+PKG_MAINTAINER:=Philip Prindeville <philipp@redfish-solutions.com>
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/beanstalkd
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=Beanstalk
+endef
+
+define Package/beanstalkd/description
+ Beanstalk is a simple, fast work queue.
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+       cd $(PKG_BUILD_DIR) && make CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" PREFIX=/usr
+endef
+
+define Package/beanstalkd/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/beanstalkd $(1)/usr/bin/beanstalkd
+
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/beanstalkd.init $(1)/etc/init.d/beanstalkd
+endef
+
+$(eval $(call BuildPackage,beanstalkd))
diff --git a/net/beanstalkd/files/beanstalkd.init b/net/beanstalkd/files/beanstalkd.init
new file mode 100644 (file)
index 0000000..992076d
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh /etc/rc.common
+# Beanstalk
+START=21
+STOP=11
+
+USE_PROCD=1
+PROG=/usr/bin/beanstalkd
+start_service() {
+    procd_open_instance
+    procd_set_param command $PROG
+    procd_close_instance
+}
diff --git a/net/beanstalkd/patches/900-makefile.patch b/net/beanstalkd/patches/900-makefile.patch
new file mode 100644 (file)
index 0000000..f948851
--- /dev/null
@@ -0,0 +1,116 @@
+diff --git a/Makefile b/Makefile
+index a3f345f..fe5a083 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,17 +1,16 @@
+-PREFIX=/usr/local
+-BINDIR=$(DESTDIR)$(PREFIX)/bin
+-CFLAGS=-Wall -Werror\
+-      -Wformat=2\
+-      -g\
+-
+-LDFLAGS=
+-OS=$(shell uname|tr A-Z a-z)
+-INSTALL=install
+-
+-VERS=$(shell ./vers.sh)
+-TARG=beanstalkd
+-MOFILE=main.o
+-OFILES=\
++PREFIX ?= /usr/local
++BINDIR = $(DESTDIR)$(PREFIX)/bin
++CFLAGS += -Wall -Werror -Wformat=2 -g
++LDFLAGS += 
++LDLIBS ?= 
++
++OS ?= $(shell uname | tr 'A-Z' 'a-z')
++INSTALL ?= install
++
++VERS = $(shell ./vers.sh)
++TARG = beanstalkd
++MOFILE = main.o
++OFILES = \
+       $(OS).o\
+       conn.o\
+       file.o\
+@@ -29,52 +28,44 @@ OFILES=\
+       vers.o\
+       walg.o\
+-TOFILES=\
++TOFILES = \
+       testheap.o\
+       testjobs.o\
+       testserv.o\
+       testutil.o\
+-HFILES=\
++HFILES = \
+       dat.h\
+       sd-daemon.h\
+ ifeq ($(OS),linux)
+-
+-LDLIBS=\
+-      -lrt\
+-
++   LDLIBS += -lrt
+ endif
+-CLEANFILES=\
++CLEANFILES = \
+       vers.c\
+-.PHONY: all
+ all: $(TARG)
+ $(TARG): $(OFILES) $(MOFILE)
+       $(LINK.o) -o $@ $^ $(LDLIBS)
+-.PHONY: install
+ install: $(BINDIR)/$(TARG)
+ $(BINDIR)/%: %
+       $(INSTALL) -d $(dir $@)
+       $(INSTALL) $< $@
+-CLEANFILES:=$(CLEANFILES) $(TARG)
++CLEANFILES := $(CLEANFILES) $(TARG)
+ $(OFILES) $(MOFILE): $(HFILES)
+-.PHONY: clean
+ clean:
+       rm -f *.o $(CLEANFILES)
+-.PHONY: check
+ check: ct/_ctcheck
+       ct/_ctcheck
+-.PHONY: bench
+ bench: ct/_ctcheck
+       ct/_ctcheck -b
+@@ -88,11 +79,8 @@ ct/ct.o ct/_ctcheck.o: ct/ct.h ct/internal.h
+ $(TOFILES): $(HFILES) ct/ct.h
+-CLEANFILES:=$(CLEANFILES) ct/_* ct/*.o
++CLEANFILES += ct/_* ct/*.o
+-ifneq ($(shell ./verc.sh),$(shell cat vers.c 2>/dev/null))
+-.PHONY: vers.c
+-endif
+ vers.c:
+       ./verc.sh >vers.c
+@@ -100,3 +88,9 @@ doc/beanstalkd.1 doc/beanstalkd.1.html: doc/beanstalkd.ronn
+       ronn $<
+ freebsd.o: darwin.c
++
++.PHONY: all install clean check bench
++
++ifneq ($(shell ./verc.sh),$(shell cat vers.c 2>/dev/null))
++.PHONY: vers.c
++endif
diff --git a/net/beanstalkd/patches/901-fix-headers.patch b/net/beanstalkd/patches/901-fix-headers.patch
new file mode 100644 (file)
index 0000000..ba6de6d
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/sd-daemon.c      2017-02-16 18:50:20.000000000 -0700
++++ b/sd-daemon.c      2017-02-16 19:21:09.086008361 -0700
+@@ -32,7 +32,7 @@
+ #include <sys/stat.h>
+ #include <sys/socket.h>
+ #include <sys/un.h>
+-#include <sys/fcntl.h>
++#include <fcntl.h>
+ #include <netinet/in.h>
+ #include <stdlib.h>
+ #include <errno.h>
diff --git a/net/beanstalkd/patches/902-replace-posix_fallocate.patch b/net/beanstalkd/patches/902-replace-posix_fallocate.patch
new file mode 100644 (file)
index 0000000..18b07c1
--- /dev/null
@@ -0,0 +1,18 @@
+--- a/linux.c
++++ b/linux.c
+@@ -1,4 +1,6 @@
+ #define _XOPEN_SOURCE 600
++#include <unistd.h>
++#include <sys/types.h>
+ #include <stdint.h>
+ #include <fcntl.h>
+ #include <stdlib.h>
+@@ -19,7 +19,7 @@ static int epfd;
+ int
+ rawfalloc(int fd, int len)
+ {
+-    return posix_fallocate(fd, 0, len);
++    return ftruncate(fd, len);
+ }