root/trunk/mkdist

Revision 3112, 11.6 KB (checked in by erkn, 11 months ago)

edit copied from mcstas-1.x branch
Now using lzma compression instead. This is more stable on 64 bit build platforms.

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