Skip to content

Commit 78b3ec9

Browse files
authored
Merge pull request #9 from mdzidic/patch-1
Fix NO_SUDO=0
2 parents abd66c1 + 68793ea commit 78b3ec9

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

Makefile

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ NO_SUDO?=0
66
USE_PROMETHEUS?=0
77
VERSION=$(shell wget -qO- https://git.haproxy.org/git/haproxy-${MAINVERSION}.git/refs/tags/ | sed -n 's:.*>\(.*\)</a>.*:\1:p' | sed 's/^.//' | sort -rV | head -1)
88
ifeq ("${VERSION}","./")
9-
VERSION="${MAINVERSION}.0"
9+
VERSION="${MAINVERSION}.0"
1010
endif
1111
RELEASE=1
1212

@@ -20,26 +20,43 @@ else
2020
endif
2121

2222
clean:
23+
ifeq ($(NO_SUDO),1)
2324
rm -f ./SOURCES/haproxy-${VERSION}.tar.gz
2425
rm -rf ./rpmbuild
2526
mkdir -p ./rpmbuild/SPECS/ ./rpmbuild/SOURCES/ ./rpmbuild/RPMS/ ./rpmbuild/SRPMS/
2627
rm -rf ./lua-${LUA_VERSION}*
28+
else
29+
sudo rm -f ./SOURCES/haproxy-${VERSION}.tar.gz
30+
sudo rm -rf ./rpmbuild
31+
sudo mkdir -p ./rpmbuild/SPECS/ ./rpmbuild/SOURCES/ ./rpmbuild/RPMS/ ./rpmbuild/SRPMS/
32+
sudo rm -rf ./lua-${LUA_VERSION}*
33+
endif
2734

2835
download-upstream:
36+
ifeq ($(NO_SUDO),1)
2937
wget https://www.haproxy.org/download/${MAINVERSION}/src/haproxy-${VERSION}.tar.gz -O ./SOURCES/haproxy-${VERSION}.tar.gz
38+
else
39+
sudo wget https://www.haproxy.org/download/${MAINVERSION}/src/haproxy-${VERSION}.tar.gz -O ./SOURCES/haproxy-${VERSION}.tar.gz
40+
endif
3041

3142
build_lua:
3243
ifeq ($(NO_SUDO),1)
3344
yum install -y readline-devel
34-
else
35-
sudo yum install -y readline-devel
36-
endif
3745
wget --no-check-certificate https://www.lua.org/ftp/lua-${LUA_VERSION}.tar.gz
3846
tar xzf lua-${LUA_VERSION}.tar.gz
3947
cd lua-${LUA_VERSION}
4048
$(MAKE) -C lua-${LUA_VERSION} clean
4149
$(MAKE) -C lua-${LUA_VERSION} MYCFLAGS=-fPIC linux test # MYCFLAGS=-fPIC is required during linux ld
4250
$(MAKE) -C lua-${LUA_VERSION} install
51+
else
52+
sudo yum install -y readline-devel
53+
sudo wget --no-check-certificate https://www.lua.org/ftp/lua-${LUA_VERSION}.tar.gz
54+
sudo tar xzf lua-${LUA_VERSION}.tar.gz
55+
cd lua-${LUA_VERSION}
56+
sudo $(MAKE) -C lua-${LUA_VERSION} clean
57+
sudo $(MAKE) -C lua-${LUA_VERSION} MYCFLAGS=-fPIC linux test # MYCFLAGS=-fPIC is required during linux ld
58+
sudo $(MAKE) -C lua-${LUA_VERSION} install
59+
endif
4360

4461
build_stages := install_prereq clean download-upstream
4562
ifeq ($(USE_LUA),1)
@@ -54,10 +71,11 @@ run-docker: build-docker
5471
docker run --volume $(HOME)/RPMS:/RPMS --rm haproxy-rpm-builder:latest
5572

5673
build: $(build_stages)
74+
ifeq ($(NO_SUDO),1)
5775
cp -r ./SPECS/* ./rpmbuild/SPECS/ || true
5876
cp -r ./SOURCES/* ./rpmbuild/SOURCES/ || true
5977
rpmbuild -ba SPECS/haproxy.spec \
60-
--define "mainversion ${MAINVERSION}" \
78+
--define "mainversion ${MAINVERSION}" \
6179
--define "version ${VERSION}" \
6280
--define "release ${RELEASE}" \
6381
--define "_topdir %(pwd)/rpmbuild" \
@@ -67,4 +85,18 @@ build: $(build_stages)
6785
--define "_srcrpmdir %{_topdir}/SRPMS" \
6886
--define "_use_lua ${USE_LUA}" \
6987
--define "_use_prometheus ${USE_PROMETHEUS}"
70-
88+
else
89+
sudo cp -r ./SPECS/* ./rpmbuild/SPECS/ || true
90+
sudo cp -r ./SOURCES/* ./rpmbuild/SOURCES/ || true
91+
sudo rpmbuild -ba SPECS/haproxy.spec \
92+
--define "mainversion ${MAINVERSION}" \
93+
--define "version ${VERSION}" \
94+
--define "release ${RELEASE}" \
95+
--define "_topdir %(pwd)/rpmbuild" \
96+
--define "_builddir %{_topdir}/BUILD" \
97+
--define "_buildroot %{_topdir}/BUILDROOT" \
98+
--define "_rpmdir %{_topdir}/RPMS" \
99+
--define "_srcrpmdir %{_topdir}/SRPMS" \
100+
--define "_use_lua ${USE_LUA}" \
101+
--define "_use_prometheus ${USE_PROMETHEUS}"
102+
endif

0 commit comments

Comments
 (0)