Эх сурвалжийг харах

Files for building CentOS/RHEL RPM.

Dexter Ang 11 жил өмнө
parent
commit
8fe51b74cf

+ 56 - 0
centos/README.md

@@ -0,0 +1,56 @@
+The files here are for building an RPM package installable on CentOS 6.x/RHEL 6.x.
+
+I (Dexter Ang, aka @thepoch) am not affiliated with the SoftEther VPN Project. Any bugs, suggestions, improvements on building an RPM should probably be reported to me.
+
+## Install and run
+
+After the package is built and installed, you can start the service as root:
+
+    service vpnserver start
+
+You can also have it start automatically:
+
+    chkconfig vpnserver on
+
+## Files
+
+This project containts the following files to build an RPM of SoftEther VPN:
+
+* SPEC/softethervpn.spec - The main spec file
+* SOURCES/fix-makefiles.sh - Script that modifies the original makefiles so it properly makes with BUILDROOT.
+* linux_??bit.mak - Makefiles modified using fix-makefiles.sh. You can replace these with the original from source, and rerun the script above.
+* init.d/vpnserver - initscript
+* scripts/* - scripts that are originally generated by the original makefiles.
+
+## To Build on CentOS 6.x
+
+As root, install the following packages:
+
+    yum -y groupinstall "Development Tools"
+    yum -y install ncurses-devel openssl-devel readline-devel
+    yum -y install rpmdevtools
+
+As a regular user, create your rpmbuild directory structure:
+
+    rpmdev-setuptree
+
+Copy over the files from their respective directories in this repository into your rpmbuild directory. Then
+
+    rpmbuild -ba SPECS/softethervpn.spec
+
+The resulting RPM will be in the RPM directory. Install this as root:
+
+    rpm -Uvh RPMS/`arch`/softethervpn-4*rpm
+
+## Known Issues
+
+1. Currently, vpnserver hangs when stopped on CentOS 6.5. Have not had time to debug. Ticket #18 on SoftEtherVPN [https://github.com/SoftEtherVPN/SoftEtherVPN/issues/18](https://github.com/SoftEtherVPN/SoftEtherVPN/issues/18).
+2. Directory structure retained as-is under /usr/vpn*.
+3. Not built into separate packages (ie vpnserver, vpnclient, etc. are all in one).
+4. When uninstalling, if you ran any of the SoftEtherVPN binaries, configuration and other files are generated in /usr/vpn*. So these directories will remain when you uninstall the RPM. You can delete these if you don't plan on using the configurations again.
+
+## Personal Notes
+
+1. This is my first time creating a spec file, creating an RPM, etc. Apologies in advance for any mistakes.
+2. This was tested using sources for version: **4.04.9412**. I'll try and update this as new versions come out.
+

+ 74 - 0
centos/SOURCES/fix-makefile.sh

@@ -0,0 +1,74 @@
+#!/bin/sh
+# Works as of:
+# %define majorversion 4.04
+# %define minorversion 9412
+# %define dateversion 2014.01.15
+#
+# sed commands could be optimized a bit, but I wanted to keep the makefiles exactly the same
+# as the original to minimize issues. May modify this in the future.
+#
+
+# 32-bit
+sed -i -e "s/^INSTALL_BINDIR=/INSTALL_BINDIR=\$\(DESTDIR\)/g" linux_32bit.mak
+sed -i -e "s/^INSTALL_VPNSERVER_DIR=/INSTALL_VPNSERVER_DIR=\$\(DESTDIR\)/g" linux_32bit.mak
+sed -i -e "s/^INSTALL_VPNBRIDGE_DIR=/INSTALL_VPNBRIDGE_DIR=\$\(DESTDIR\)/g" linux_32bit.mak
+sed -i -e "s/^INSTALL_VPNCLIENT_DIR=/INSTALL_VPNCLIENT_DIR=\$\(DESTDIR\)/g" linux_32bit.mak
+sed -i -e "s/^INSTALL_VPNCMD_DIR=/INSTALL_VPNCMD_DIR=\$\(DESTDIR\)/g" linux_32bit.mak
+
+## for the echos
+sed -i -e "s/^\techo/#\techo/g" linux_32bit.mak
+sed -i -e "s/^\tchmod/#\tchmod/g" linux_32bit.mak
+
+## vpnserver
+sed -i -e "s/\@mkdir -p \$(INSTALL_VPNSERVER_DIR)/install -d \$(INSTALL_VPNSERVER_DIR)/g" linux_32bit.mak
+sed -i -e "s/cp bin\/vpnserver\/hamcore.se2 \$(INSTALL_VPNSERVER_DIR)hamcore.se2/install -m 600 bin\/vpnserver\/hamcore.se2 \$(INSTALL_VPNSERVER_DIR)hamcore.se2/g" linux_32bit.mak
+sed -i -e "s/cp bin\/vpnserver\/vpnserver \$(INSTALL_VPNSERVER_DIR)vpnserver/install -m 755 bin\/vpnserver\/vpnserver \$(INSTALL_VPNSERVER_DIR)vpnserver/g" linux_32bit.mak
+
+## vpnbridge
+sed -i -e "s/\@mkdir -p \$(INSTALL_VPNBRIDGE_DIR)/install -d \$(INSTALL_VPNBRIDGE_DIR)/g" linux_32bit.mak
+sed -i -e "s/cp bin\/vpnbridge\/hamcore.se2 \$(INSTALL_VPNBRIDGE_DIR)hamcore.se2/install -m 600 bin\/vpnbridge\/hamcore.se2 \$(INSTALL_VPNBRIDGE_DIR)hamcore.se2/g" linux_32bit.mak
+sed -i -e "s/cp bin\/vpnbridge\/vpnbridge \$(INSTALL_VPNBRIDGE_DIR)vpnbridge/install -m 755 bin\/vpnbridge\/vpnbridge \$(INSTALL_VPNBRIDGE_DIR)vpnbridge/g" linux_32bit.mak
+
+## vpnclient
+sed -i -e "s/\@mkdir -p \$(INSTALL_VPNCLIENT_DIR)/install -d \$(INSTALL_VPNCLIENT_DIR)/g" linux_32bit.mak
+sed -i -e "s/cp bin\/vpnclient\/hamcore.se2 \$(INSTALL_VPNCLIENT_DIR)hamcore.se2/install -m 600 bin\/vpnclient\/hamcore.se2 \$(INSTALL_VPNCLIENT_DIR)hamcore.se2/g" linux_32bit.mak
+sed -i -e "s/cp bin\/vpnclient\/vpnclient \$(INSTALL_VPNCLIENT_DIR)vpnclient/install -m 755 bin\/vpnclient\/vpnclient \$(INSTALL_VPNCLIENT_DIR)vpnclient/g" linux_32bit.mak
+
+## vpncmd
+sed -i -e "s/\@mkdir -p \$(INSTALL_VPNCMD_DIR)/install -d \$(INSTALL_VPNCMD_DIR)/g" linux_32bit.mak
+sed -i -e "s/cp bin\/vpncmd\/hamcore.se2 \$(INSTALL_VPNCMD_DIR)hamcore.se2/install -m 600 bin\/vpncmd\/hamcore.se2 \$(INSTALL_VPNCMD_DIR)hamcore.se2/g" linux_32bit.mak
+sed -i -e "s/cp bin\/vpncmd\/vpncmd \$(INSTALL_VPNCMD_DIR)vpncmd/install -m 755 bin\/vpncmd\/vpncmd \$(INSTALL_VPNCMD_DIR)vpncmd/g" linux_32bit.mak
+
+# --------------------------------------------------
+
+# 64-bit
+sed -i -e "s/^INSTALL_BINDIR=/INSTALL_BINDIR=\$\(DESTDIR\)/g" linux_64bit.mak
+sed -i -e "s/^INSTALL_VPNSERVER_DIR=/INSTALL_VPNSERVER_DIR=\$\(DESTDIR\)/g" linux_64bit.mak
+sed -i -e "s/^INSTALL_VPNBRIDGE_DIR=/INSTALL_VPNBRIDGE_DIR=\$\(DESTDIR\)/g" linux_64bit.mak
+sed -i -e "s/^INSTALL_VPNCLIENT_DIR=/INSTALL_VPNCLIENT_DIR=\$\(DESTDIR\)/g" linux_64bit.mak
+sed -i -e "s/^INSTALL_VPNCMD_DIR=/INSTALL_VPNCMD_DIR=\$\(DESTDIR\)/g" linux_64bit.mak
+
+## for the echos
+sed -i -e "s/^\techo/#\techo/g" linux_64bit.mak
+sed -i -e "s/^\tchmod/#\tchmod/g" linux_64bit.mak
+
+## vpnserver
+sed -i -e "s/\@mkdir -p \$(INSTALL_VPNSERVER_DIR)/install -d \$(INSTALL_VPNSERVER_DIR)/g" linux_64bit.mak
+sed -i -e "s/cp bin\/vpnserver\/hamcore.se2 \$(INSTALL_VPNSERVER_DIR)hamcore.se2/install -m 600 bin\/vpnserver\/hamcore.se2 \$(INSTALL_VPNSERVER_DIR)hamcore.se2/g" linux_64bit.mak
+sed -i -e "s/cp bin\/vpnserver\/vpnserver \$(INSTALL_VPNSERVER_DIR)vpnserver/install -m 755 bin\/vpnserver\/vpnserver \$(INSTALL_VPNSERVER_DIR)vpnserver/g" linux_64bit.mak
+
+## vpnbridge
+sed -i -e "s/\@mkdir -p \$(INSTALL_VPNBRIDGE_DIR)/install -d \$(INSTALL_VPNBRIDGE_DIR)/g" linux_64bit.mak
+sed -i -e "s/cp bin\/vpnbridge\/hamcore.se2 \$(INSTALL_VPNBRIDGE_DIR)hamcore.se2/install -m 600 bin\/vpnbridge\/hamcore.se2 \$(INSTALL_VPNBRIDGE_DIR)hamcore.se2/g" linux_64bit.mak
+sed -i -e "s/cp bin\/vpnbridge\/vpnbridge \$(INSTALL_VPNBRIDGE_DIR)vpnbridge/install -m 755 bin\/vpnbridge\/vpnbridge \$(INSTALL_VPNBRIDGE_DIR)vpnbridge/g" linux_64bit.mak
+
+## vpnclient
+sed -i -e "s/\@mkdir -p \$(INSTALL_VPNCLIENT_DIR)/install -d \$(INSTALL_VPNCLIENT_DIR)/g" linux_64bit.mak
+sed -i -e "s/cp bin\/vpnclient\/hamcore.se2 \$(INSTALL_VPNCLIENT_DIR)hamcore.se2/install -m 600 bin\/vpnclient\/hamcore.se2 \$(INSTALL_VPNCLIENT_DIR)hamcore.se2/g" linux_64bit.mak
+sed -i -e "s/cp bin\/vpnclient\/vpnclient \$(INSTALL_VPNCLIENT_DIR)vpnclient/install -m 755 bin\/vpnclient\/vpnclient \$(INSTALL_VPNCLIENT_DIR)vpnclient/g" linux_64bit.mak
+
+## vpncmd
+sed -i -e "s/\@mkdir -p \$(INSTALL_VPNCMD_DIR)/install -d \$(INSTALL_VPNCMD_DIR)/g" linux_64bit.mak
+sed -i -e "s/cp bin\/vpncmd\/hamcore.se2 \$(INSTALL_VPNCMD_DIR)hamcore.se2/install -m 600 bin\/vpncmd\/hamcore.se2 \$(INSTALL_VPNCMD_DIR)hamcore.se2/g" linux_64bit.mak
+sed -i -e "s/cp bin\/vpncmd\/vpncmd \$(INSTALL_VPNCMD_DIR)vpncmd/install -m 755 bin\/vpncmd\/vpncmd \$(INSTALL_VPNCMD_DIR)vpncmd/g" linux_64bit.mak
+

+ 102 - 0
centos/SOURCES/init.d/vpnserver

@@ -0,0 +1,102 @@
+#!/bin/sh
+#
+# vpnserver	This shell script takes care of starting and stopping
+#		SoftEther VPN server.
+#
+# chkconfig:   - 99 1
+# description: SoftEther VPN server.
+#
+
+### BEGIN INIT INFO
+# Provides: vpnserver
+# Required-Start: $local_fs $network
+# Required-Stop: $local_fs $network
+# Short-Description: start and stop SoftEther VPN server.
+# Description: SoftEther VPN server.
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+exec="/usr/vpnserver/vpnserver"
+prog="vpnserver"
+#config="<path to major config file>"
+
+#[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+pidfile=/usr/vpnserver/.pid_3E649A678269D4A01B73BF9E3388D075
+lockfile=/var/lock/subsys/$prog
+
+start() {
+	[ -x $exec ] || exit 5
+#	[ -f $config ] || exit 6
+	echo -n $"Starting $prog: "
+	$exec start
+	retval=$?
+	echo
+	[ $retval -eq 0 ] && touch $lockfile
+	return $retval
+}
+
+stop() {
+	echo -n $"Stopping $prog: "
+	$exec stop
+	retval=$?
+	echo
+	[ $retval -eq 0 ] && rm -f $lockfile
+	return $retval
+}
+
+restart() {
+	stop
+	start
+}
+
+reload() {
+	restart
+}
+
+force_reload() {
+	restart
+}
+
+rh_status() {
+	status -p $pidfile $prog
+}
+
+rh_status_q() {
+	rh_status >/dev/null 2>&1
+}
+
+
+case "$1" in
+	start)
+		rh_status_q && exit 0
+		$1
+		;;
+	stop)
+		rh_status_q || exit 0
+		$1
+		;;
+	restart)
+		$1
+		;;
+	reload)
+		rh_status_q || exit 7
+		$1
+		;;
+	force-reload)
+		force_reload
+		;;
+	status)
+		rh_status
+		;;
+	condrestart|try-restart)
+		rh_status_q || exit 0
+		restart
+		;;
+	*)
+		echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+		exit 2
+esac
+exit $?

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 50 - 0
centos/SOURCES/linux_32bit.mak


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 50 - 0
centos/SOURCES/linux_64bit.mak


+ 3 - 0
centos/SOURCES/scripts/vpnbridge

@@ -0,0 +1,3 @@
+#!/bin/sh
+/usr/vpnbridge/vpnbridge "$@"
+exit $?

+ 3 - 0
centos/SOURCES/scripts/vpnclient

@@ -0,0 +1,3 @@
+#!/bin/sh
+/usr/vpnclient/vpnclient "$@"
+exit $?

+ 3 - 0
centos/SOURCES/scripts/vpncmd

@@ -0,0 +1,3 @@
+#!/bin/sh
+/usr/vpncmd/vpncmd "$@"
+exit $?

+ 3 - 0
centos/SOURCES/scripts/vpnserver

@@ -0,0 +1,3 @@
+#!/bin/sh
+/usr/vpnserver/vpnserver "$@"
+exit $?

+ 95 - 0
centos/SPECS/softethervpn.spec

@@ -0,0 +1,95 @@
+%define majorversion 4.04
+%define minorversion 9412
+%define dateversion 2014.01.15
+
+Name:           softethervpn
+Version:        %{majorversion}.%{minorversion}
+Release:        2%{?dist}
+Summary:        An Open-Source Free Cross-platform Multi-protocol VPN Program
+
+Group:          Applications/Internet
+License:        GPLv2
+URL:            http://www.softether.org/
+Source0:        http://www.softether-download.com/files/softether/v%{majorversion}-%{minorversion}-rtm-%{dateversion}-tree/Source%20Code/softether-src-v%{majorversion}-%{minorversion}-rtm.tar.gz
+
+BuildRequires:  ncurses-devel
+BuildRequires:	openssl-devel
+BuildRequires:	readline-devel
+
+Requires(post):		chkconfig
+Requires(postun):	initscripts
+Requires(preun):	chkconfig
+Requires(preun):	initscripts
+
+%description
+SoftEther VPN is one of the world's most powerful and easy-to-use multi-protocol VPN software. It runs on Windows, Linux, Mac, FreeBSD, and Solaris.
+
+%prep
+%setup -q -n v%{majorversion}-%{minorversion}
+
+%build
+%ifarch i386 i686
+cp $RPM_SOURCE_DIR/linux_32bit.mak Makefile
+%else
+cp $RPM_SOURCE_DIR/linux_64bit.mak Makefile
+%endif
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT
+install -m 755 -d $RPM_BUILD_ROOT/usr/bin/
+install -m 755 -d $RPM_BUILD_ROOT/etc/rc.d/init.d
+install -m 755 $RPM_SOURCE_DIR/scripts/vpnserver $RPM_BUILD_ROOT/usr/bin/vpnserver
+install -m 755 $RPM_SOURCE_DIR/scripts/vpnbridge $RPM_BUILD_ROOT/usr/bin/vpnbridge
+install -m 755 $RPM_SOURCE_DIR/scripts/vpnclient $RPM_BUILD_ROOT/usr/bin/vpnclient
+install -m 755 $RPM_SOURCE_DIR/scripts/vpncmd $RPM_BUILD_ROOT/usr/bin/vpncmd
+install -m 755 $RPM_SOURCE_DIR/init.d/vpnserver $RPM_BUILD_ROOT/etc/rc.d/init.d/vpnserver
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%{_usr}/bin/vpnserver
+%{_usr}/bin/vpnbridge
+%{_usr}/bin/vpnclient
+%{_usr}/bin/vpncmd
+%{_usr}/vpnserver/hamcore.se2
+%{_usr}/vpnserver/vpnserver
+%{_usr}/vpnbridge/hamcore.se2
+%{_usr}/vpnbridge/vpnbridge
+%{_usr}/vpnclient/hamcore.se2
+%{_usr}/vpnclient/vpnclient
+%{_usr}/vpncmd/hamcore.se2
+%{_usr}/vpncmd/vpncmd
+%{_usr}/vpnserver/
+%{_usr}/vpnbridge/
+%{_usr}/vpnclient/
+%{_usr}/vpncmd/
+%{_initddir}/vpnserver
+%doc AUTHORS.TXT BUILD_UNIX.TXT BUILD_WINDOWS.TXT ChangeLog ChangeLog.txt LICENSE LICENSE.TXT README README.TXT THIRD_PARTY.TXT WARNING.TXT
+
+%post
+/sbin/chkconfig --add vpnserver
+
+#%postun
+#if [ "$1" -ge "1" ]; then
+#	/sbin/service vpnserver condrestart >/dev/null 2>&1 || :
+#fi
+
+%preun
+if [ $1 -eq 0 ]; then
+	/sbin/service vpnserver stop >/dev/null 2>&1
+	/sbin/chkconfig --del vpnserver
+fi
+
+%changelog
+* Wed Jan 29 2014 Dexter Ang <[email protected]> - 4.04.9412-2
+- Made initscript more Fedora/RH-like.
+- initscript currently using killall. Need to fix this.
+
+* Tue Jan 21 2014 Dexter Ang <[email protected]>
+- Initial release
+
+

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно