Browse Source

Basic Debian package support in buildinstaller.sh

Adam Ierymenko 10 years ago
parent
commit
4bf2fa3edb

+ 2 - 0
.gitignore

@@ -27,6 +27,8 @@
 *.obj
 *.tlog
 *.pid
+/*.deb
+/*.rpm
 /build-*
 /ZeroTierOneInstaller-*
 .qmake.stash

+ 21 - 0
buildinstaller.sh

@@ -31,12 +31,15 @@ case "$system" in
 		# Canonicalize $machine for some architectures... we use x86
 		# and x64 for Intel stuff. ARM and others should be fine if
 		# we ever ship officially for those.
+		debian_arch=$machine
 		case "$machine" in
 			i386|i486|i586|i686)
 				machine="x86"
+				debian_arch="i386"
 				;;
 			x86_64|amd64|x64)
 				machine="x64"
+				debian_arch="amd64"
 				;;
 		esac
 
@@ -61,6 +64,22 @@ case "$system" in
 		rm -f build-installer-tmp.tar.gz
 		ls -l $targ
 
+		if [ -f /usr/bin/dpkg-deb -a "$UID" -eq 0 ]; then
+			echo
+			echo Found dpkg-deb and you are root, trying to build Debian package.
+			rm -rf build-installer-deb
+			debbase="build-installer-deb/zerotier-one_${vmajor}.${vminor}.${revision}_$debian_arch"
+			debfolder="${debbase}/DEBIAN"
+			mkdir -p $debfolder
+			cat 'ext/installfiles/linux/DEBIAN/control.in' | sed "s/__VERSION__/${vmajor}.${vminor}.${revision}/" >$debfolder/control
+			cp -f 'ext/installfiles/linux/DEBIAN/conffiles' "${debfolder}/conffiles"
+			mkdir -p "${debbase}/var/lib/zerotier-one"
+			cp -f $targ "${debbase}/var/lib/zerotier-one"
+			dpkg-deb --build $debbase
+			mv -f build-installer-deb/*.deb .
+			rm -rf build-installer-deb
+		fi
+
 		;;
 
 	Darwin)
@@ -96,4 +115,6 @@ case "$system" in
 
 esac
 
+rm -rf build-installer
+
 exit 0

+ 0 - 0
ext/installfiles/linux/DEBIAN/conffiles


+ 11 - 0
ext/installfiles/linux/DEBIAN/control.in

@@ -0,0 +1,11 @@
+Package: zerotier-one
+Architecture: any
+Maintainer: ZeroTier Networks
+Depends: curl
+Priority: optional
+Version: __VERSION__
+Homepage: https://github.com/zerotier/ZeroTierOne
+Description: ZeroTier One network virtualization service
+ ZeroTier One is a fast, secure, and easy to use peer to peer network
+ virtualization engine. Visit https://www.zerotier.com/ for more
+ information.

+ 1 - 1
make-linux.mk

@@ -82,7 +82,7 @@ installer: one FORCE
 	./buildinstaller.sh
 
 clean:
-	rm -rf $(OBJS) $(TESTNET_OBJS) node/*.o osnet/*.o control/*.o testnet/*.o *.o zerotier-* build-* ZeroTierOneInstaller-*
+	rm -rf $(OBJS) $(TESTNET_OBJS) node/*.o osnet/*.o control/*.o testnet/*.o *.o zerotier-* build-* ZeroTierOneInstaller-* *.deb *.rpm
 
 debug:	FORCE
 	make -j 4 ZT_DEBUG=1