Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Add support to build for RHEL/CentOS #135

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man

CFLAGS = -O2 -g -std=c99 -fno-strict-aliasing -Wall -W -D_GNU_SOURCE -I/usr/local/include
CFLAGS += -I/usr/include/libev
LDFLAGS = -lssl -lcrypto -lev -L/usr/local/lib
OBJS = stud.o ringbuffer.o configuration.o

Expand Down Expand Up @@ -48,5 +49,18 @@ install: $(ALL)
clean:
rm -f stud $(OBJS)

GIT_VERSION=$(shell git describe)
VERSION_MAJOR=$(firstword $(subst -, ,$(GIT_VERSION)))
TMPDIR=$(shell pwd)/.rpmbuild

rpm:
mkdir -p ${TMPDIR}/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
git archive HEAD . --prefix=stud-$(VERSION_MAJOR)/ \
> ${TMPDIR}/SOURCES/stud-source.tar
sed -re s/GIT_VERSION/$(shell git describe)/ \
rhel/stud.spec > ${TMPDIR}/SPECS/stud.spec
rpmbuild --define "_topdir ${TMPDIR}" \
-bb ${TMPDIR}/SPECS/stud.spec $(if $(USE_SHARED_CACHE),--with cache,)
find ${TMPDIR}/RPMS/ -type f -name "*.rpm" -exec mv {} . \;

.PHONY: all realall
90 changes: 90 additions & 0 deletions rhel/stud.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# The GIT_VERSION token below is automatically changed to the value of
# `git describe` by the top-level Makefile's "rpm" build target
%define git_version GIT_VERSION
#
# The git version is <tag>-#-sha1, where the <tag> is the most recent
# annotated git tag, # is the number of commits since the tag, and the
# sha1 is 'g' plus the first 7 chars of the most recent commit sha1-id
# on the branch being compiled
#
# This will split the version information back into the <tag> (version)
# and the #-sha1 (post_tag) parts
#
%define version %(echo %{git_version} | cut -d- -f1)
%define post_tag %(echo %{git_version} | cut -s -d- -f2- | sed -e s/-/_/g)
%if x%{post_tag} == "x"
%undefine post_tag
%endif

# Use --with cache to build the RPM with the USE_SHARED_CACHE feature
%bcond_with cache

Name: stud
Version: %{version}
Release: %{?post_tag}%{!?post_tag:1}%{?dist}
Summary: The Scalable TLS Unwrapping Daemon

Group: Productivity/Networking/Web/Proxy
License: BSD
URL: https://github.com/bumptech/stud
Source0: stud-source.tar

BuildRequires: libev-devel
Requires: libev openssl

%description
stud is a network proxy that terminates TLS/SSL connections and forwards the
unencrypted traffic to some backend. It's designed to handle 10s of
thousands of connections efficiently on multicore machines.

%prep
%setup -q
%if %{with cache}
mkdir ebtree
curl http://1wt.eu/tools/ebtree/ebtree-6.0.8.tar.gz | tar xzf - -C "ebtree" --strip 1
%endif

%build
make %{?_smp_mflags} %{?_with_cache:USE_SHARED_CACHE=1}


%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot} PREFIX=/usr %{?_with_cache:USE_SHARED_CACHE=1}
install -d %{buildroot}/etc/init.d
install init.stud %{buildroot}/etc/init.d/stud

%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
/usr/bin/stud
/etc/init.d/stud
%doc
/usr/share/man/man8


%preun
if [ "$1" = "0" ]; then
service stud stop 2>/dev/null
true
fi

%postun
if [ "$1" = "0" ]; then
# remove rundir
rm -rf /var/run/stud >/dev/null 2>&1

# remove config dir
rm -rf /etc/stud >/dev/null 2>&1
fi

%post
mkdir -p /var/run/stud
mkdir -p /etc/stud


%changelog