root/branches/mcstas-1.x/mkdist

Revision 3089, 10.3 KB (checked in by mcstas, 12 months ago)

Correcting typo - next is mkdist...

  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# Simple script for setting up a mcstas distribution package.
4#
5# To be called with one input parameter - distribution tail filename, e.g.
6#
7# ./mkdist 1.7.3c -> ../mcstas-1.7.3c.tar.gz
8#
9# Assumes you have write access to ..
10#
11# PW, risoe, 20030123
12#
13#   This file is part of the McStas neutron ray-trace simulation package
14#   Copyright (C) 1997-2006, All rights reserved
15#   Risoe National Laborartory, Roskilde, Denmark
16#   Institut Laue Langevin, Grenoble, France
17#
18#   This program is free software; you can redistribute it and/or modify
19#   it under the terms of the GNU General Public License as published by
20#   the Free Software Foundation; version 2 of the License.
21#
22#   This program is distributed in the hope that it will be useful,
23#   but WITHOUT ANY WARRANTY; without even the implied warranty of
24#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25#   GNU General Public License for more details.
26#
27#   You should have received a copy of the GNU General Public License
28#   along with this program; if not, write to the Free Software
29#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
30
31
32# Create temporary workdir:
33TMPDIR='..'
34PW=`pwd`
35DIST=$TMPDIR/mcstas-$1
36
37# Create the doc's from tex
38cd $PW/../tex
39./build $1
40mv *.ps.gz $PW/..
41mv *.pdf $PW/..
42
43# Copy current PW checkout to DIST
44cd $PW
45cp -rp $PW $DIST
46# copy the doc in DIST/lib/doc
47cp $PW/../mcstas-$1-manual.ps.gz $DIST/lib/doc/mcstas-manual.ps.gz
48cp $PW/../mcstas-$1-manual.pdf $DIST/lib/doc/mcstas-manual.pdf
49cp $PW/../mcstas-$1-components.ps.gz $DIST/lib/doc/mcstas-components.ps.gz
50cp $PW/../mcstas-$1-components.pdf $DIST/lib/doc/mcstas-components.pdf
51
52# Go in DIST, clean up CVS and svn information
53cd $DIST
54find . -name CVS -exec rm -r \{\} \; 2> /dev/null
55find . -name .svn -exec rm -r \{\} \; 2> /dev/null
56# Remove other unneeded stuff
57rm -rf support/Syntax-Highlight-Perl-1.0
58rm -rf preCVStest*
59# Make sure that all comps and instrs have unix linefeeds
60find . -name \*.comp -exec dos2unix \{\} \;
61find . -name \*.instr -exec dos2unix \{\} \;
62
63# Put in new version info:
64find . -wholename './setversion' -prune -o -type d -o -exec ./setversion \{\} $1 \;
65find . -wholename './setyear' -prune -o -type d -o -exec ./setyear \{\} \;
66
67sed 's/MCSTAS_VERSION/'$1'/' build.bat > build.bat.new
68mv build.bat.new build.bat
69sed 's/MCSTAS_VERSION/'$1'/' mcstas.nsi > mcstas.nsi.new
70mv mcstas.nsi.new mcstas.nsi
71sed 's/MCSTAS_VERSION/'$1'/' deb/control > deb/control.new
72mv deb/control.new deb/control
73
74# Create ps/pdf/html based install info
75cd install_docs/tex
76latex install
77latex install
78dvips -o install.ps install.dvi
79whichdvipdf=`which dvipdf`
80if [ -e "$whichdvipdf" ] ;
81then
82  echo "Generate install PDF files using dvipdf (better quality than ps2pdf)"
83  dvipdf install.dvi install.pdf
84else
85  echo "Generate install PDF files using ps2pdf"
86  ps2pdf install.ps install.pdf
87fi
88
89gzip install.ps
90mkdir ../html
91latex2html -local_icons -dir ../html install.tex
92# clean up
93rm install.aux
94rm install.log
95cd ../..
96# Update the tutorial files
97cd lib/doc/tutorial
98./update
99rm update
100cd ../../..
101
102# A bit ugly with seperate date commands..
103MONTH=`date +"%b"`
104DAY=`date +"%d"`
105YEAR=`date +"%Y"`
106sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcstas.h > mcstas.h.tmp
107cat mcstas.h.tmp > mcstas.h
108sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcformat.c > mcformat.c.tmp
109cat mcformat.c.tmp > mcformat.c
110sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcstas.1 > mcstas.1.tmp
111cat mcstas.1.tmp > mcstas.1
112sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcrun.1 > mcrun.1.tmp
113cat mcrun.1.tmp  > mcrun.1
114sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcdoc.1  > mcdoc.1.tmp
115cat mcdoc.1.tmp > mcdoc.1
116sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcgui.1  > mcgui.1.tmp
117cat mcgui.1.tmp > mcgui.1
118sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcplot.1 > mcplot.1.tmp
119cat mcplot.1.tmp > mcplot.1
120sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcdisplay.1 > mcdisplay.1.tmp
121cat mcdisplay.1.tmp > mcdisplay.1
122sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcconvert.1 > mcconvert.1.tmp
123cat mcconvert.1.tmp > mcconvert.1
124sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcformat.1 > mcformat.1.tmp
125cat mcformat.1.tmp > mcformat.1
126sed 's/X.Y.Z/'$1'/' configure.in > configure.in.tmp
127cat configure.in.tmp > configure.in
128sed 's/@RELEASE@/'$1'/' deb/debcreate > deb/debcreate.new
129mv deb/debcreate.new deb/debcreate
130chmod a+x deb/debcreate
131
132# Create configure
133autoconf configure.in > configure
134chmod a+x configure
135autoconf lib/tools/perl/mcstas_reconfigure.in > lib/tools/perl/mcstas_reconfigure
136chmod a+x lib/tools/perl/mcstas_reconfigure
137chmod a+w lib/tools/perl/mcstas_config.perl
138
139# run lex, yacc (assuming linux - flex -i & bison -v -d)
140flex -i instrument.l
141bison -v -d instrument.y
142
143# Set the INSTALL environment variable to make the src archive
144# default to ./install-sh in the contributed Makefile.
145# Note: the -c is needed to preserve mcdoc.fixpl which is run at make install
146export INSTALL="./install-sh -c"
147
148# Also, do a ./configure to create Makefile and mcstas_config.perl
149# These will be dependent on this system, ofcourse...
150./configure
151# Select scilab as default plotter
152make pgplot
153
154# Clean up
155rm TODO.txt
156rm mkdist
157rm setversion
158rm setyear
159rm header
160# Make new runs of configure not dependent of this system...
161rm config.*
162cd ..
163
164# Create tar archive
165tar cfz $PW/../mcstas-$1-src.tar.gz mcstas-$1
166
167# Do a 'make' for creation of binary version (should apply to 'any' Unix)
168cd $PW
169cd $DIST
170
171# Default again to Linux' /usr/bin/install -c (or whatever ./configure finds)
172export INSTALL=
173./configure
174# Select pgplot as default plotter
175make pgplot
176
177make
178UNAME=`uname`
179MACH=`uname -m`
180# Up to now, this is always done on intel...
181PROC=Intel
182cd ..
183
184# Create tar archive
185tar cfz $PW/../mcstas-$1-$MACH-$PROC-$UNAME.tar.gz mcstas-$1
186
187# Remove temporary dir
188# rm -rf $TMPDIR
189
190# Create .tar.gz archive for building a binary Windows version
191cd $PW
192cd $DIST
193make clean
194flex -i instrument.l
195bison -v -d instrument.y
196./configure
197sed 's/DOZIP="0"/DOZIP="1"/' build.bat > build.bat.new
198sed 's/DONSIS="0"/DONSIS="1"/' build.bat.new > build.bat
199cp support/Win32/which.exe .
200cd ..
201tar cfz $PW/../mcstas-$1-Win32-src.tar.gz mcstas-$1
202if [ `which makensis` ]; then
203    cd -
204    ./configure
205    # Make sure we default to PGPLOT plotter
206    make pgplot
207    make mcstas.win32
208    cp mcstas.ini ..
209    cp mcstas.nsi ..
210    cp mcstas.bmp ..
211    cp LICENSE.rtf ..
212    cd ..
213    zip -r mcstas-$1-i686-Intel-Win32.zip mcstas-$1
214    cp winsupport/* .
215    makensis -X"SetCompressor /FINAL lzma" mcstas.nsi
216    echo Created Win32 binary packages: `ls *zip *exe`
217else
218    echo Binary versions for Win32 NOT created
219fi
220echo
221echo
222echo Your mcstas dist packages are placed in
223echo ../mcstas-$1-src.tar.gz
224echo ../mcstas-$1-$MACH-$PROC-$UNAME.tar.gz
225echo ../mcstas-$1-Win32-src.tar.gz
226echo
227echo NOTE: Win32 version must be built using \'build.bat\' of the Win32-src package
228echo
229echo Your mcstas doc packages are placed in
230echo ../mcstas-$1-manual.ps.gz
231echo ../mcstas-$1-manual.pdf
232echo ../mcstas-$1-components.ps.gz
233echo ../mcstas-$1-components.pdf
234echo
235echo WARNING: Please install to a test system and run the following tools
236echo before release:
237echo
238echo compiletest.sh \(check if all examples compile\)
239echo mcrun --test \(validation test of selected instruments\)
240echo
241echo Follow instructions in ../adm to publish on the web.
242echo
243
244# In case of mkfs.hfsplus available in /sbin we'll create the
245# DMG file for Mac OS X
246if [ -e /sbin/mkfs.hfsplus ]
247then
248    # Note: DMG file needs enough space to hold the support tools plus
249    # our own code. April 2008 this is about 120 megs...
250    dd if=/dev/zero of=./McStas-$1-OSX.dmg bs=1M count=120
251    /sbin/mkfs.hfsplus -v 'McStas' ./McStas-$1-OSX.dmg
252    # Likely needs root level access:
253    sudo mkdir /mnt/dmg
254    sudo mount -t hfsplus -o loop ./McStas-$1-OSX.dmg /mnt/dmg
255    # Copy the ./adm/OSX/DMG stuff to the mountpoint
256    sudo cp -rp ./adm/OSX/DMG/Applications /mnt/dmg
257    sudo cp ./adm/OSX/DMG/README.TXT /mnt/dmg
258    # Clear out CVS stuff
259    sudo find /mnt/dmg -type d -name CVS -exec rm -rf \{\} \;
260    # Copy McStas there
261    sudo cp ./mcstas-$1-src.tar.gz /mnt/dmg/Applications
262    # Unmount
263    sudo umount /mnt/dmg
264    sudo rm -rf /mnt/dmg
265    ls -l ./McStas-$1-OSX.dmg
266fi
267
268
269# In case of a debian build host, we also build an .deb
270# (.rpm was tried using alien - did not work too well)
271if [ -e /etc/debian_version ]
272then
273  if [ -e build-chroot-i386 ]
274  then
275    echo Proceeding to i386 .deb build
276    # First, clean up in case of previous McStas installs in the chrooot
277    sudo rm -f build-chroot-i386/usr/local/bin/*
278    sudo rm -rf build-chroot-i386/usr/local/lib/*
279    sudo cp mcstas-$1/deb/debcreate build-chroot-i386/root
280    sudo cp mcstas-$1/deb/sources.list build-chroot-i386/etc/apt/
281    sudo cp mcstas-$1-src.tar.gz build-chroot-i386/root
282    sudo mkdir build-chroot-i386/build
283    sudo chroot build-chroot-i386 apt-get update
284    sudo chroot build-chroot-i386 /root/debcreate $1 i386
285    echo
286    echo
287    echo Build packages created:
288    echo
289    cp build-chroot-i386/build/*deb .
290    ls -lf mcstas-$1*.* McStas-$1*.*
291    echo
292  else
293    echo You need a chroot environment based on debootstrap in build-chroot-i386 before building the i386 deb package - create using something like
294    echo sudo debootstrap --arch i386 karmic build-chroot
295  fi 
296  if [ -e build-chroot-x86_64 ]
297  then
298    echo Proceeding to .deb build
299    # First, clean up in case of previous McStas installs in the chrooot
300    sudo rm -f build-chroot-x86_64/usr/local/bin/*
301    sudo rm -rf build-chroot-x86_64/usr/local/lib/*
302    sudo cp mcstas-$1/deb/debcreate build-chroot-x86_64/root
303    sudo cp mcstas-$1/deb/sources.list build-chroot-x86_64/etc/apt/
304    sudo cp mcstas-$1-src.tar.gz build-chroot-x86_64/root
305    sudo mkdir build-chroot-x86_64/build
306    sudo chroot build-chroot-x86_64 apt-get update
307    sudo chroot build-chroot-x86_64 /root/debcreate $1 amd64
308    echo
309    echo
310    echo Build packages created:
311    echo
312    cp build-chroot-x86_64/build/*deb .
313    ls -lf mcstas-$1*.* McStas-$1*.*
314    echo
315  else
316    echo You need a chroot environment based on debootstrap in build-chroot-x86_64 before building the x86_64 deb package - create using something like
317    echo sudo debootstrap --arch x86_64 karmic build-chroot-x86_64
318  fi
319fi
Note: See TracBrowser for help on using the browser.