xref: /unit/pkg/rpm/Makefile.go (revision 2107:cd075799fad9)
1MODULES+=		go
2MODULE_SUFFIX_go=	go
3
4MODULE_SUMMARY_go=	Go module for NGINX Unit
5
6MODULE_VERSION_go=	$(VERSION)
7MODULE_RELEASE_go=	1
8
9MODULE_CONFARGS_go=	go --go-path=%{gopath}
10MODULE_MAKEARGS_go=	go
11MODULE_INSTARGS_go=	go-install-src
12
13MODULE_SOURCES_go=	unit.example-go-app \
14			unit.example-go-config
15
16ifeq ($(OSVER), centos6)
17BUILD_DEPENDS_go=	epel-release golang
18else ifneq (,$(findstring $(OSVER),opensuse-leap opensuse-tumbleweed))
19BUILD_DEPENDS_go=	go1.9
20else
21BUILD_DEPENDS_go=	golang
22endif
23
24BUILD_DEPENDS+=		$(BUILD_DEPENDS_go)
25
26ifneq (,$(findstring $(OSVER),opensuse-leap opensuse-tumbleweed))
27define MODULE_DEFINITIONS_go
28BuildArch: noarch
29Requires: unit-devel == $(VERSION)-$(RELEASE)%{?dist}.ngx
30BuildRequires: $(BUILD_DEPENDS_go)
31%define gopath /usr/share/go/contrib
32endef
33else
34define MODULE_DEFINITIONS_go
35BuildArch: noarch
36Requires: unit-devel == $(VERSION)-$(RELEASE)%{?dist}.ngx
37BuildRequires: $(BUILD_DEPENDS_go)
38endef
39endif
40export MODULE_DEFINITIONS_go
41
42define MODULE_PREINSTALL_go
43QA_SKIP_BUILD_ROOT=1
44export QA_SKIP_BUILD_ROOT
45
46%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit-go/examples/go-app
47%{__install} -m 644 -p %{SOURCE100} \
48    %{buildroot}%{_datadir}/doc/unit-go/examples/go-app/let-my-people.go
49%{__install} -m 644 -p %{SOURCE101} \
50    %{buildroot}%{_datadir}/doc/unit-go/examples/unit.config
51endef
52export MODULE_PREINSTALL_go
53
54define MODULE_FILES_go
55%dir %{gopath}/src/unit.nginx.org/go
56%{gopath}/src/unit.nginx.org/go/*
57endef
58export MODULE_FILES_go
59
60define MODULE_POST_go
61cat <<BANNER
62----------------------------------------------------------------------
63
64The $(MODULE_SUMMARY_go) has been installed.
65
66To check the sample app, run these commands:
67
68 GOPATH=%{gopath} GO111MODULE=auto go build -o /tmp/go-app /usr/share/doc/unit-go/examples/go-app/let-my-people.go
69 sudo service unit start
70 cd /usr/share/doc/%{name}/examples
71 sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
72 curl http://localhost:8500/
73
74Online documentation is available at https://unit.nginx.org
75
76----------------------------------------------------------------------
77BANNER
78endef
79export MODULE_POST_go
80