summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKonstantin Pavlov <thresh@nginx.com>2022-11-29 18:12:54 +0400
committerKonstantin Pavlov <thresh@nginx.com>2022-11-29 18:12:54 +0400
commit11c66941ce9146ca85533e8a3169ef3941340896 (patch)
tree3c853fb8e3c7c7a5ee27ddaad4b36d80a4527e7c
parent3778877eb3be3904edadb9f85553f81cdf32ea43 (diff)
downloadunit-11c66941ce9146ca85533e8a3169ef3941340896.tar.gz
unit-11c66941ce9146ca85533e8a3169ef3941340896.tar.bz2
Added contribs and njs.
-rw-r--r--pkg/Makefile4
-rw-r--r--pkg/contrib/Makefile140
-rw-r--r--pkg/contrib/src/njs/Makefile19
-rw-r--r--pkg/contrib/src/njs/SHA512SUMS1
-rw-r--r--pkg/contrib/src/njs/version1
-rw-r--r--pkg/contrib/tarballs/.hgignore3
6 files changed, 168 insertions, 0 deletions
diff --git a/pkg/Makefile b/pkg/Makefile
index 4cf9ff80..c252969b 100644
--- a/pkg/Makefile
+++ b/pkg/Makefile
@@ -29,11 +29,15 @@ docker:
npm:
@cd npm && VERSION=$(VERSION) RELEASE=$(RELEASE) make all
+njs:
+ @cd contrib && make .njs
+
clean:
@cd rpm && make clean
@cd deb && make clean
@cd docker && make clean
@cd npm && make clean
+ @cd contrib && make clean
rm -f unit-$(VERSION).tar.gz
rm -f unit-$(VERSION).tar.gz.sha512
diff --git a/pkg/contrib/Makefile b/pkg/contrib/Makefile
new file mode 100644
index 00000000..7e3b8b97
--- /dev/null
+++ b/pkg/contrib/Makefile
@@ -0,0 +1,140 @@
+all: install
+
+TOPSRC := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
+SRC := $(TOPSRC)/src
+TARBALLS := $(TOPSRC)/tarballs
+VPATH := $(TARBALLS)
+PREFIX = $(TOPSRC)/local
+PREFIX := $(abspath $(PREFIX))
+
+PKGS_ALL := $(patsubst $(SRC)/%/Makefile,%,$(wildcard $(SRC)/*/Makefile))
+
+# Common download locations
+CONTRIB_NGINX := https://packages.nginx.org/contrib
+
+#
+# Tools
+#
+NPROC := $(shell getconf _NPROCESSORS_ONLN)
+_SMP_MFLAGS := -j$(NPROC)
+
+ifndef GIT
+ifeq ($(shell git --version >/dev/null 2>&1 || echo FAIL),)
+GIT = git
+endif
+endif
+GIT ?= $(error git not found)
+
+ifeq ($(shell curl --version >/dev/null 2>&1 || echo FAIL),)
+download = curl -f -L -- "$(1)" > "$@"
+else ifeq ($(shell wget --version >/dev/null 2>&1 || echo FAIL),)
+download = (rm -f $@.tmp && \
+ wget --passive -c -p -O $@.tmp "$(1)" && \
+ touch $@.tmp && \
+ mv $@.tmp $@ )
+else ifeq ($(which fetch >/dev/null 2>&1 || echo FAIL),)
+download = (rm -f $@.tmp && \
+ fetch -p -o $@.tmp "$(1)" && \
+ touch $@.tmp && \
+ mv $@.tmp $@)
+else
+download = $(error Neither curl nor wget found)
+endif
+
+download_pkg = $(call download,$(CONTRIB_NGINX)/$(2)/$(lastword $(subst /, ,$(@)))) || \
+ ( $(call download,$(1)) && echo "Please upload $(lastword $(subst /, ,$(@))) to $(CONTRIB_NGINX)" )
+
+ifeq ($(shell which xz >/dev/null 2>&1 || echo FAIL),)
+XZ = xz
+else
+XZ ?= $(error XZ (LZMA) compressor not found)
+endif
+
+ifeq ($(shell sha512sum --version >/dev/null 2>&1 || echo FAIL),)
+SHA512SUM = sha512sum --check
+else ifeq ($(shell shasum --version >/dev/null 2>&1 || echo FAIL),)
+SHA512SUM = shasum -a 512 --check
+else ifeq ($(shell openssl version >/dev/null 2>&1 || echo FAIL),)
+SHA512SUM = openssl dgst -sha512
+else
+SHA512SUM = $(error SHA-512 checksumming not found)
+endif
+
+#
+# Common helpers
+#
+download_git = \
+ rm -Rf -- "$(@:.tar.xz=)" && \
+ $(GIT) init --bare "$(@:.tar.xz=)" && \
+ (cd "$(@:.tar.xz=)" && \
+ $(GIT) remote add origin "$(1)" && \
+ $(GIT) fetch origin "$(2)") && \
+ (cd "$(@:.tar.xz=)" && \
+ $(GIT) archive --prefix="$(notdir $(@:.tar.xz=))/" \
+ --format=tar "$(3)") > "$(@:.xz=)" && \
+ echo "$(3) $(@)" > "$(@:.tar.xz=.githash)" && \
+ rm -Rf -- "$(@:.tar.xz=)" && \
+ $(XZ) --stdout "$(@:.xz=)" > "$@.tmp" && \
+ rm -f "$(@:.xz=)" && \
+ mv -f -- "$@.tmp" "$@"
+check_githash = \
+ h=`sed -e "s,^\([0-9a-fA-F]\{40\}\) .*/$(notdir $<),\1,g" \
+ < "$(<:.tar.xz=.githash)"` && \
+ test "$$h" = "$1"
+
+checksum = \
+ $(foreach f,$(filter $(TARBALLS)/%,$^), \
+ grep -- " $(f:$(TARBALLS)/%=%)$$" \
+ "$(SRC)/$(patsubst $(3)%,%,$@)/$(2)SUMS" |) \
+ (cd $(TARBALLS) && $(1))
+CHECK_SHA512 = $(call checksum,$(SHA512SUM),SHA512,.sum-)
+UNPACK = $(RM) -R $@ \
+ $(foreach f,$(filter %.tar.gz %.tgz,$^), && tar xvzfo $(f)) \
+ $(foreach f,$(filter %.tar.bz2,$^), && tar xvjfo $(f)) \
+ $(foreach f,$(filter %.tar.xz,$^), && tar xvJfo $(f)) \
+ $(foreach f,$(filter %.zip,$^), && unzip $(f))
+UNPACK_DIR = $(patsubst %.tar,%,$(basename $(notdir $<)))
+APPLY = (cd $(UNPACK_DIR) && patch -fp1) <
+MOVE = mv $(UNPACK_DIR) $@ && touch $@
+
+# Per-package build rules
+include $(SRC)/*/Makefile
+
+# Targets
+PKGS_DEPS := $(sort $(foreach p,$(PKGS),$(DEPS_$(p))))
+
+fetch: $(PKGS:%=.sum-%)
+install: $(PKGS:%=.%)
+
+clean:
+ -$(RM) $(foreach p,$(PKGS),.$(p) .sum-$(p) .dep-$(p))
+ -$(RM) -R $(foreach p,$(PKGS),$(p))
+ -$(RM) -R "$(PREFIX)"
+ -$(RM) $(TARBALLS)/*.*
+
+list:
+ @echo Packages:
+ @echo ' $(PKGS)' | tr " " "\n" | sort | tr "\n" " " |fmt
+ @echo Depended-on packages:
+ @echo ' $(PKGS_DEPS)' | tr " " "\n" | sort | tr "\n" " " |fmt
+
+.PHONY: all fetch install clean list
+
+# Default pattern rules
+.sum-%: $(SRC)/%/SHA512SUMS
+ $(CHECK_SHA512)
+ touch $@
+
+.sum-%:
+ $(error Download and check target not defined for $*)
+
+# Real dependency on missing packages
+$(patsubst %,.dep-%,$(PKGS)): .dep-%: .%
+ touch -r $< $@
+
+.SECONDEXPANSION:
+
+# Dependency propagation (convert 'DEPS_foo = bar' to '.foo: .bar')
+$(foreach p,$(PKGS),.$(p)): .%: $$(foreach d,$$(DEPS_$$*),.dep-$$(d))
+
+.DELETE_ON_ERROR:
diff --git a/pkg/contrib/src/njs/Makefile b/pkg/contrib/src/njs/Makefile
new file mode 100644
index 00000000..54255aef
--- /dev/null
+++ b/pkg/contrib/src/njs/Makefile
@@ -0,0 +1,19 @@
+# njs
+
+include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/version
+NJS_URL := https://hg.nginx.org/njs/archive/$(NJS_VERSION).tar.gz
+
+PKGS += njs
+
+$(TARBALLS)/njs-$(NJS_VERSION).tar.gz:
+ $(call download_pkg,$(NJS_URL),njs)
+
+.sum-njs: njs-$(NJS_VERSION).tar.gz
+
+njs: njs-$(NJS_VERSION).tar.gz .sum-njs
+ $(UNPACK)
+ $(MOVE)
+
+.njs: njs
+ cd $< && ./configure && $(MAKE) libnjs
+ touch $@
diff --git a/pkg/contrib/src/njs/SHA512SUMS b/pkg/contrib/src/njs/SHA512SUMS
new file mode 100644
index 00000000..1bddec9b
--- /dev/null
+++ b/pkg/contrib/src/njs/SHA512SUMS
@@ -0,0 +1 @@
+dc73029e7b570a7fbc94e90deb1e17c9a3d85072dc0e060f11dd96bd173e11b7c823c57115369d3c68af7acd97fabe619b70dfd73280694f8b5dc8b7929d850b njs-0.7.9.tar.gz
diff --git a/pkg/contrib/src/njs/version b/pkg/contrib/src/njs/version
new file mode 100644
index 00000000..511715d0
--- /dev/null
+++ b/pkg/contrib/src/njs/version
@@ -0,0 +1 @@
+NJS_VERSION := 0.7.9
diff --git a/pkg/contrib/tarballs/.hgignore b/pkg/contrib/tarballs/.hgignore
new file mode 100644
index 00000000..8d876d7b
--- /dev/null
+++ b/pkg/contrib/tarballs/.hgignore
@@ -0,0 +1,3 @@
+syntax:glob
+*.tar.*
+*.githash