From e7d414e233b46e3ede399cb7ef385b0d078cafc9 Mon Sep 17 00:00:00 2001
From: Joanna Hulboj <joanna.hulboj@isode.com>
Date: Thu, 9 Mar 2017 10:31:32 +0000
Subject: Add automatic man generation to the Linux build for Swift

Test-Information:

Tested under CentOS.
Run script to generate a package under Linux, swift-im.1 and swiften-config.1 are generated.

Change-Id: Idf0b159a94e05349b196f019bbc91127095a1d16

diff --git a/Swift/Packaging/Debian/debian/swift-im.1 b/Swift/Packaging/Debian/debian/swift-im.1
deleted file mode 100644
index b7262bf..0000000
--- a/Swift/Packaging/Debian/debian/swift-im.1
+++ /dev/null
@@ -1,33 +0,0 @@
-.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.38.4.
-.TH SWIFT "1" "June 2011" "Swift" "Swift Manual"
-.SH NAME
-swift-im \- Swift
-.SH SYNOPSIS
-.B swift-im
-[\fIOPTIONS\fR]...
-.SH DESCRIPTION
-Swift is an instant messaging client for the XMPP network.
-.SH OPTIONS
-.TP
-\fB\-\-debug\fR
-Turn on debug logging
-.TP
-\fB\-\-help\fR
-Show this help message
-.TP
-\fB\-\-version\fR
-Show version information
-.TP
-\fB\-\-netbook\-mode\fR
-Use netbook mode display (unsupported)
-.TP
-\fB\-\-no\-tabs\fR
-Don't manage chat windows in tabs (unsupported)
-.TP
-\fB\-\-latency\-debug\fR
-Use latency debugging (unsupported)
-.HP
-\fB\-\-multi\-account\fR arg (=1) Number of accounts to open windows for (unsupported)
-.TP
-\fB\-\-start\-minimized\fR
-Don't show the login/roster window at startup
diff --git a/Swift/Packaging/Debian/debian/swiften-config.1 b/Swift/Packaging/Debian/debian/swiften-config.1
deleted file mode 100644
index 3717df6..0000000
--- a/Swift/Packaging/Debian/debian/swiften-config.1
+++ /dev/null
@@ -1,21 +0,0 @@
-.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.38.4.
-.TH SWIFTEN-CONFIG "1" "June 2011" "swiften-config" "Swift Manual"
-.SH NAME
-swiften-config \- swiften-config
-.SH SYNOPSIS
-.B swiften-config
-[\fIOPTIONS\fR]...
-.SH DESCRIPTION
-swiften\-config outputs the Swiften build options.
-.TP
-\fB\-\-help\fR
-Show this help message
-.TP
-\fB\-\-version\fR
-Show version information
-.TP
-\fB\-\-libs\fR
-List the library flags
-.TP
-\fB\-\-cflags\fR
-List the compiler & preprocessor flags
diff --git a/Swift/Packaging/Debian/package.sh b/Swift/Packaging/Debian/package.sh
index 62dfff0..d19f5dc 100755
--- a/Swift/Packaging/Debian/package.sh
+++ b/Swift/Packaging/Debian/package.sh
@@ -95,6 +95,18 @@ cat $DIRNAME/debian/control.in | sed -e "s/%SWIFTEN_SOVERSION%/$SWIFTEN_SOVERSIO
 rm $DIRNAME/debian/control.in
 mv $DIRNAME/debian/libswiften.install $DIRNAME/debian/libswiften$SWIFTEN_SOVERSION.install
 cat ../../../COPYING.thirdparty | tail -n +3 >> $DIRNAME/debian/copyright
+# Generate updated man-page if possible
+if type "help2man" > /dev/null 2>&1; then
+	if [ -f ../../QtUI/swift-im ]; then 
+		help2man -m "Swift Manual" -S "Swift" -n "swift-im" -N ../../QtUI/swift-im > $DIRNAME/debian/swift-im.1
+	fi
+	if [ -f ../../../Swiften/Config/swiften-config ]; then
+		help2man -m "Swift Manual" -S "swiften-config" -n "swiften-config" -N ../../../Swiften/Config/swiften-config > $DIRNAME/debian/swiften-config.1
+	fi
+else
+	>2& echo "Unable to generate man pages. Please ensure that help2man is installed"
+	exit 1;
+fi
 
 # Build
 cd $DIRNAME
-- 
cgit v0.10.2-6-g49f6