From 89483a09aff36d319e4f6ec60ef2e14dee6e9ec1 Mon Sep 17 00:00:00 2001
From: Marina Ganeva <m.ganeva@fz-juelich.de>
Date: Mon, 7 Oct 2013 15:41:02 +0200
Subject: [PATCH] New edition of the release deployment script.

---
 Doc/UserManual/CMakeLists.txt      |  15 ++-
 Doc/UserManual/UserManual.tex.in   | 196 +++++++++++++++++++++++++++++
 bin/release.sh.in                  |  54 ++++++--
 cmake/modules/BornAgainCPack.cmake |   6 +-
 4 files changed, 259 insertions(+), 12 deletions(-)
 create mode 100644 Doc/UserManual/UserManual.tex.in

diff --git a/Doc/UserManual/CMakeLists.txt b/Doc/UserManual/CMakeLists.txt
index 73f0f72a7e2..dff006805e7 100644
--- a/Doc/UserManual/CMakeLists.txt
+++ b/Doc/UserManual/CMakeLists.txt
@@ -2,6 +2,19 @@ cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
 
 project(UserManual NONE)
 
+# Please define the UserManual Version here only. 
+# It will automatically propagate to the latex file.
+set(UM_VERSION_MAJOR 0)
+set(UM_VERSION_MINOR 1)
+set(UM_VERSION_PATCH 1)
+
+# --- configure a header file to pass CMake settings to the source code
+configure_file(
+  "${CMAKE_SOURCE_DIR}/Doc/UserManual/UserManual.tex.in"
+  "${CMAKE_SOURCE_DIR}/Doc/UserManual/UserManual-${UM_VERSION_MAJOR}.${UM_VERSION_MINOR}.${UM_VERSION_PATCH}.tex"
+)
+
+
 set(LATEX_COMPILER_FLAGS
 "-interaction=nonstopmode --enable-write18"
 CACHE STRING "Flags passed to latex."
@@ -26,7 +39,7 @@ set(UM_IMAGES
 	Figures/results2_2.png
 )
 
-ADD_LATEX_DOCUMENT(UserManual.tex
+ADD_LATEX_DOCUMENT(UserManual-${UM_VERSION_MAJOR}.${UM_VERSION_MINOR}.${UM_VERSION_PATCH}.tex
 	INPUTS Disclaimer.tex Introduction.tex QuickStart.tex Installation.tex SimulationExamples.tex SoftwareArchitecture.tex
 	BIBFILES jw7.bib 
 	IMAGES ${UM_IMAGES}
diff --git a/Doc/UserManual/UserManual.tex.in b/Doc/UserManual/UserManual.tex.in
new file mode 100644
index 00000000000..0fae6694350
--- /dev/null
+++ b/Doc/UserManual/UserManual.tex.in
@@ -0,0 +1,196 @@
+\documentclass[a4paper,11pt]{report}
+\usepackage{booktabs}
+\renewcommand{\arraystretch}{1.3}
+%-------------------------------------------------------------------------------
+%	FONT
+%-------------------------------------------------------------------------------
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+
+%\usepackage[scaled=0.8]{beramono} % beramono or luximono give very nice ttfamily fonts
+
+%-------------------------------------------------------------------------------
+%	PAGE LAYOUT
+%-------------------------------------------------------------------------------
+\usepackage[toc,page]{appendix}
+
+\textwidth = 410pt
+
+\usepackage{fancyhdr}
+\pagestyle{fancy}
+\fancyhf{}
+
+%\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
+
+%\nouppercase{\rightmark}
+
+\lhead{\bfseries \nouppercase{\leftmark}}
+\rhead{\bfseries \nouppercase{\rightmark}}
+\lfoot{}
+\rfoot{\bfseries Page \thepage}
+
+\headwidth=1.1\textwidth
+\renewcommand{\headrulewidth}{1.5pt}
+\renewcommand{\footrulewidth}{1.5pt}
+\fancyhfoffset[L]{24pt}
+\fancyhfoffset[R]{24pt}
+
+\fancypagestyle{plain}{%
+\fancyhf{} % clear all header and footer fields
+\headwidth=1.1\textwidth
+\renewcommand{\headrulewidth}{1.5pt}
+\renewcommand{\footrulewidth}{1.5pt}
+\lhead{\bfseries \nouppercase{\leftmark}}
+\rhead{\bfseries \nouppercase{\rightmark}}
+%\lhead{\leftmark}
+%\rhead{\rightmark}
+\lfoot{}
+\rfoot{\bfseries Page \thepage}
+%\rfoot{Page \thepage}
+\headwidth=1.1\textwidth
+\fancyhfoffset[L]{24pt}
+\fancyhfoffset[R]{24pt}
+}
+
+\newcommand{\mysection}[2]{%
+                         \sectionmark{#1}%
+                         \section{#2}%
+                         \sectionmark{#1}%
+                       }
+
+%%%%%%%%%
+%\renewcommand{\chaptermark}[1]{\markboth{\uppercase{\thechapter.\ #1}}{}}
+%\renewcommand{\sectionmark}[1]{\markright{\uppercase{\thesection.\ #1}}}
+%\newcommand{\helv}{\fontfamily{phv}\fontseries{b}\fontsize{9}{11}\selectfont}
+%\lhead[\helv \thepage]{\helv \rightmark}
+%\rhead[\helv \leftmark]{\helv \thepage}
+%\cfoot{}
+%-------------------------------------------------------------------------------
+%	OTHER PACKAGES and COMMANDS
+%-------------------------------------------------------------------------------
+\usepackage{graphicx}
+\usepackage{epstopdf}
+
+
+\usepackage{float}
+\usepackage{tikz}
+\usepackage{tikz-uml} 
+\usepackage{amsmath}
+
+\usepackage{pifont}
+\usepackage{fourier}
+\usepackage{dingbat}
+
+\usepackage{hyperref}
+\usepackage{breakurl}
+
+\newcommand{\reffig}[1]{figure \ref{fig:#1}}
+
+\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\}
+%-------------------------------------------------------------------------------
+%	CUSTON LISTING SETTINGS
+%-------------------------------------------------------------------------------
+\usepackage{listings}
+\usepackage{lstcustom}
+\usepackage{enumerate}
+\renewcommand{\lstfontfamily}{\ttfamily}
+%-------------------------------------------------------------------------------
+%	COLORS
+%-------------------------------------------------------------------------------
+
+\definecolor{Lightgray}{gray}{.80}
+\definecolor{lightgrey}{rgb}{0.9,0.9,0.9}
+
+
+%-------------------------------------------------------------------------------
+%       Commands
+%-------------------------------------------------------------------------------
+\newcommand{\Code}[1]{\texttt{#1}}
+\newcommand{\BornAgain}{\Code{BornAgain}}%
+\newcommand{\IsGISAXS}{\Code{IsGISAXS}}%
+\newcommand{\SecLabel}[1]{\label{sec:#1}}%
+\newcommand{\SecRef}[1]{Section~\ref{sec:#1}}% 
+\newcommand{\MakeRemark}[2]
+{ \noindent \smallpencil \colorbox{Lightgray}{\parbox{\dimexpr\linewidth-8\fboxsep}			{\underline{#1} #2 }}
+}
+
+\newcommand{\ImportantPoint}[2]
+{\noindent
+  {\huge\danger}\colorbox{Lightgray}{\parbox{\dimexpr\linewidth-8\fboxsep}
+ {\underline{#1} #2}}}
+
+\newcommand{\mychapter}[2]{
+    \setcounter{chapter}{#1}
+    \setcounter{section}{0}
+    \chapter*{#2}
+    \addcontentsline{toc}{chapter}{#2}
+}
+
+%-------------------------------------------------------------------------------
+%	TITLE PAGE
+%-------------------------------------------------------------------------------
+\title{
+{\Huge\bf BornAgain}\\[10mm]
+Software for simulating and fitting\\
+X-ray and neutron small-angle scattering\\
+at grazing incidence\\
+\vspace*{10mm} User Manual \\
+\large{version @UM_VERSION_MAJOR@.@UM_VERSION_MINOR@.@UM_VERSION_PATCH@\\\today}
+\vspace*{5mm}
+}
+
+\author{ 
+{\LARGE C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke }\\[5mm]
+\large
+Scientific Computing Group\\
+J\"ulich Centre for Neutron Science\\
+outstation at Heinz Maier-Leibnitz Zentrum Garching\\
+Forschungszentrum J\"ulich GmbH
+}
+
+\date{{}}
+%License: Creative Common CC-BY-SA \\
+%\today
+%}
+
+
+%\usepackage{eso-pic}
+%\newcommand\BackgroundPic{%
+%\put(0,0){%
+%\parbox[b][\paperheight]{\paperwidth}{%
+%\vfill
+%\centering
+%\includegraphics[width=\paperwidth,height=\paperheight,%
+%keepaspectratio]{results2_2.png}%
+%\vfill
+%}}}
+
+
+%-------------------------------------------------------------------------------
+%	DOCUMENT
+%-------------------------------------------------------------------------------
+\begin{document}
+
+\maketitle
+
+
+\input{Disclaimer}
+\tableofcontents
+%\lstlistoflistings
+%\listoffigures
+%\listoftables
+\input{Introduction}
+\input{QuickStart}
+\input{Installation}
+\input{SimulationExamples}
+%\input{FittingExamples}
+\input{SoftwareArchitecture}
+%\input{SoftwareDesignOverview}
+%\appendix
+%\input{AppendixListings}
+%\input{AppendixPhysics}
+
+\bibliographystyle{switch}
+\bibliography{jw7}
+
+\end{document}
diff --git a/bin/release.sh.in b/bin/release.sh.in
index c2e3efa9d64..6826267f294 100755
--- a/bin/release.sh.in
+++ b/bin/release.sh.in
@@ -9,6 +9,10 @@ BA_VERSION_MINOR=@BornAgain_VERSION_MINOR@
 BA_VERSION_PATCH=@BornAgain_VERSION_PATCH@
 BA_VERSION=$BA_VERSION_MAJOR.$BA_VERSION_MINOR.$BA_VERSION_PATCH
 
+# path to the mirror-folder of the application server
+# after the release will be produces, we make rsync to syncronize 
+# the contents with the application server 
+RELEASE_DIR="/home/mary/build/bornagain/RELEASE/BornAgain"
 # 1. Making release branch
 # Where is your git source tree? 
 # Set the path here or CMake will set it for you.
@@ -21,22 +25,23 @@ CMAKE_BUILD_DIR="@CMAKE_BINARY_DIR@"
 
 # make a release branch
 RELEASE_BRANCH_NAME="release-$BA_VERSION"
-git --git-dir=$GIT_SOURCE_TREE checkout -b $RELEASE_BRANCH_NAME develop
+#git --git-dir=$GIT_SOURCE_TREE checkout -b $RELEASE_BRANCH_NAME develop
+git --git-dir=$GIT_SOURCE_TREE checkout -b $RELEASE_BRANCH_NAME 
 
 # build BornAgain with App and UserManual
-# cd $CMAKE_BUILD_DIR
+cd $CMAKE_BUILD_DIR
 cmake -D BORNAGAIN_APP=ON -D BORNAGAIN_MAN=ON --build $CMAKE_BUILD_DIR $CMAKE_SOURCE_DIR && make
 
 # Update picture number of lines of code
 # [TODO:] change qqq.png to lines_of_code.png after testing
-python $CMAKE_SOURCE_DIR/dev-tools/git-utils/cl_lines_of_code.py -i $GIT_SOURCE_TREE -o $CMAKE_SOURCE_DIR/dev-tools/git-utils/qqq.png
+python $CMAKE_SOURCE_DIR/dev-tools/git-utils/cl_lines_of_code.py -i $CMAKE_SOURCE_DIR -o $CMAKE_SOURCE_DIR/dev-tools/git-utils/qqq.png
 
 # Measure the performance
 $CMAKE_BUILD_DIR/bin/App --performance --batch --threads=-1
 
 # Modify file dev-tools/log/perf_history.txt
 echo "Please, enter a comment for perf-history.txt [Press Enter if empty]"
-read PERF_COMMENT
+read -t 10 PERF_COMMENT
 if [ "PERF_COMMENT" != "" ]; then
 	echo $PERF_COMMENT >> $CMAKE_SOURCE_DIR/dev-tools/log/perf-history.txt
 fi
@@ -44,14 +49,43 @@ cat perf_history.txt >> $CMAKE_SOURCE_DIR/dev-tools/log/perf-history.txt
 
 # [FUTURE TASK] Modify CHANGELOG (SQL query to get data from the redmine roadmap database)
 PATH_TO_CHANGELOG="$CMAKE_SOURCE_DIR/CHANGELOG"
-# upload CHANGELOG
-#PATH_TO_UPLOAD_CHANGELOG="apps@apps.jcns.fz-juelich.de:/www/apps/src/BornAgain/"
-#scp $PATH_TO_CHANGELOG $PATH_TO_UPLOAD_CHANGELOG
+cp $PATH_TO_CHANGELOG $RELEASE_DIR
 
 # Update UserManual
-# [TODO:] remove old manual
+# remove old manual
+rm -f $RELEASE_DIR/UserManual*.pdf
 # upload new manual
-# PATH_TO_MANUAL=$CMAKE_BUILD_DIR/
+cp $CMAKE_BUILD_DIR/Doc/UserManual/UserManual-*.pdf $RELEASE_DIR
  
+# 2. Prepare package source tarball
+cd $CMAKE_BUILD_DIR
+make package_source
+# [Future Task:] write a validation script
+
+# move the old package 
+mv $RELEASE_DIR/BornAgain*.tar.gz $RELEASE_DIR/old/
+
+# put the package source to RELEASE_DIR for further upload
+cp $CMAKE_BUILD_DIR/BornAgain-$BA_VERSION.tar.gz $RELEASE_DIR
+
+# 3. make rsync to the application server
+# uncomment after you are sure that everything is working properly 
+# rsync -avzhe ssh $RELEASE_DIR apps@apps.jcns.fz-juelich.de:/www/apps/src/BornAgain
+
+# 4. Finalize git
+# finalize master
+git --git-dir=$GIT_SOURCE_TREE commit -a -m "Release $BA_VERSION"
+git --git-dir=$GIT_SOURCE_TREE checkout master
+git --git-dir=$GIT_SOURCE_TREE merge --no-ff $RELEASE_BRANCH_NAME 
+git --git-dir=$GIT_SOURCE_TREE tag -a $BA_VERSION
+# uncomment after you are sure that everything is working properly 
+# git --git-dir=$GIT_SOURCE_TREE push
       
-echo $RELEASE_BRANCH_NAME    
+# finalize develop
+git --git-dir=$GIT_SOURCE_TREE checkout develop
+git --git-dir=$GIT_SOURCE_TREE merge --no-ff $RELEASE_BRANCH_NAME
+# uncomment after you are sure that everything is working properly 
+# git --git-dir=$GIT_SOURCE_TREE push
+git --git-dir=$GIT_SOURCE_TREE branch -d $RELEASE_BRANCH_NAME
+
+echo "Congratulations with new $BA_VERSION release! Great job ;-)"    
diff --git a/cmake/modules/BornAgainCPack.cmake b/cmake/modules/BornAgainCPack.cmake
index 2cb018824ae..e6b0926072e 100644
--- a/cmake/modules/BornAgainCPack.cmake
+++ b/cmake/modules/BornAgainCPack.cmake
@@ -82,6 +82,10 @@ set(CPACK_SOURCE_IGNORE_FILES
     "\\\\.lssrc"
     "\\\\.DS_Store"
     "\\\\.obj"
+    "/bin/release.sh.in" # user will not need it
+    "/cmake/modules/UseLATEX.cmake" # user will not need it
+    "/dev-tools/git-utils/cl_lines_of_code.py"
+    "/dev-tools/git-utils/qqq.png" # remove this line when unneeded
 )
 
 
@@ -113,7 +117,7 @@ set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
 set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
 set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
 set(CPACK_STRIP_FILES "TRUE")
-set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgsl0-dev, libboost-dev(>=1.48), libfftw3-dev, libpython2.7, libc6(>= 2.7)") 
+set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgsl0-dev(>=1.15), libboost-dev(>=1.48), libfftw3-dev(>=3.3.1), python(>=2.7), python-dev(>=2.7), libpython2.7, python-numpy, libc6(>= 2.7)") 
 set(CPACK_DEBIAN_PACKAGE_DESCRIPTION	"${CPACK_PACKAGE_DESCRIPTION}")
 set(CPACK_DEBIAN_PACKAGE_VERSION 1)
 set(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
-- 
GitLab