From 8043fdf755ee86903b0b6af0ba3b98a6d027e9d2 Mon Sep 17 00:00:00 2001 From: Philip Prindeville Date: Mon, 20 Feb 2017 12:34:16 -0700 Subject: [PATCH] beanstalkd: add package 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 --- net/beanstalkd/Makefile | 48 ++++++++ net/beanstalkd/files/beanstalkd.init | 14 +++ net/beanstalkd/patches/900-makefile.patch | 116 ++++++++++++++++++ net/beanstalkd/patches/901-fix-headers.patch | 11 ++ .../patches/902-replace-posix_fallocate.patch | 18 +++ 5 files changed, 207 insertions(+) create mode 100644 net/beanstalkd/Makefile create mode 100644 net/beanstalkd/files/beanstalkd.init create mode 100644 net/beanstalkd/patches/900-makefile.patch create mode 100644 net/beanstalkd/patches/901-fix-headers.patch create mode 100644 net/beanstalkd/patches/902-replace-posix_fallocate.patch diff --git a/net/beanstalkd/Makefile b/net/beanstalkd/Makefile new file mode 100644 index 000000000..53749a917 --- /dev/null +++ b/net/beanstalkd/Makefile @@ -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 +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 index 000000000..992076d3a --- /dev/null +++ b/net/beanstalkd/files/beanstalkd.init @@ -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 index 000000000..f948851e2 --- /dev/null +++ b/net/beanstalkd/patches/900-makefile.patch @@ -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 index 000000000..ba6de6d78 --- /dev/null +++ b/net/beanstalkd/patches/901-fix-headers.patch @@ -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 + #include + #include +-#include ++#include + #include + #include + #include diff --git a/net/beanstalkd/patches/902-replace-posix_fallocate.patch b/net/beanstalkd/patches/902-replace-posix_fallocate.patch new file mode 100644 index 000000000..18b07c188 --- /dev/null +++ b/net/beanstalkd/patches/902-replace-posix_fallocate.patch @@ -0,0 +1,18 @@ +--- a/linux.c ++++ b/linux.c +@@ -1,4 +1,6 @@ + #define _XOPEN_SOURCE 600 ++#include ++#include + #include + #include + #include +@@ -19,7 +19,7 @@ static int epfd; + int + rawfalloc(int fd, int len) + { +- return posix_fallocate(fd, 0, len); ++ return ftruncate(fd, len); + } + +