| 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: |
|---|
| 33 | TMPDIR='..' |
|---|
| 34 | PW=`pwd` |
|---|
| 35 | DIST=$TMPDIR/mcstas-$1 |
|---|
| 36 | |
|---|
| 37 | # Create the doc's from tex |
|---|
| 38 | cd $PW/../tex |
|---|
| 39 | ./build $1 |
|---|
| 40 | mv *.ps.gz $PW/.. |
|---|
| 41 | mv *.pdf $PW/.. |
|---|
| 42 | |
|---|
| 43 | # Copy current PW checkout to DIST |
|---|
| 44 | cd $PW |
|---|
| 45 | cp -rp $PW $DIST |
|---|
| 46 | # copy the doc in DIST/lib/doc |
|---|
| 47 | cp $PW/../mcstas-$1-manual.ps.gz $DIST/lib/doc/mcstas-manual.ps.gz |
|---|
| 48 | cp $PW/../mcstas-$1-manual.pdf $DIST/lib/doc/mcstas-manual.pdf |
|---|
| 49 | cp $PW/../mcstas-$1-components.ps.gz $DIST/lib/doc/mcstas-components.ps.gz |
|---|
| 50 | cp $PW/../mcstas-$1-components.pdf $DIST/lib/doc/mcstas-components.pdf |
|---|
| 51 | |
|---|
| 52 | # Go in DIST, clean up CVS and svn information |
|---|
| 53 | cd $DIST |
|---|
| 54 | find . -name CVS -exec rm -r \{\} \; 2> /dev/null |
|---|
| 55 | find . -name .svn -exec rm -r \{\} \; 2> /dev/null |
|---|
| 56 | # Remove other unneeded stuff |
|---|
| 57 | rm -rf support/Syntax-Highlight-Perl-1.0 |
|---|
| 58 | rm -rf preCVStest* |
|---|
| 59 | # Make sure that all comps and instrs have unix linefeeds |
|---|
| 60 | find . -name \*.comp -exec dos2unix \{\} \; |
|---|
| 61 | find . -name \*.instr -exec dos2unix \{\} \; |
|---|
| 62 | |
|---|
| 63 | # Put in new version info: |
|---|
| 64 | find . -wholename './setversion' -prune -o -type d -o -exec ./setversion \{\} $1 \; |
|---|
| 65 | find . -wholename './setyear' -prune -o -type d -o -exec ./setyear \{\} \; |
|---|
| 66 | |
|---|
| 67 | sed 's/MCSTAS_VERSION/'$1'/' build.bat > build.bat.new |
|---|
| 68 | mv build.bat.new build.bat |
|---|
| 69 | sed 's/MCSTAS_VERSION/'$1'/' mcstas.nsi > mcstas.nsi.new |
|---|
| 70 | mv mcstas.nsi.new mcstas.nsi |
|---|
| 71 | sed 's/MCSTAS_VERSION/'$1'/' deb/control > deb/control.new |
|---|
| 72 | mv deb/control.new deb/control |
|---|
| 73 | |
|---|
| 74 | # Create ps/pdf/html based install info |
|---|
| 75 | cd install_docs/tex |
|---|
| 76 | latex install |
|---|
| 77 | latex install |
|---|
| 78 | dvips -o install.ps install.dvi |
|---|
| 79 | whichdvipdf=`which dvipdf` |
|---|
| 80 | if [ -e "$whichdvipdf" ] ; |
|---|
| 81 | then |
|---|
| 82 | echo "Generate install PDF files using dvipdf (better quality than ps2pdf)" |
|---|
| 83 | dvipdf install.dvi install.pdf |
|---|
| 84 | else |
|---|
| 85 | echo "Generate install PDF files using ps2pdf" |
|---|
| 86 | ps2pdf install.ps install.pdf |
|---|
| 87 | fi |
|---|
| 88 | |
|---|
| 89 | gzip install.ps |
|---|
| 90 | mkdir ../html |
|---|
| 91 | latex2html -local_icons -dir ../html install.tex |
|---|
| 92 | # clean up |
|---|
| 93 | rm install.aux |
|---|
| 94 | rm install.log |
|---|
| 95 | cd ../.. |
|---|
| 96 | # Update the tutorial files |
|---|
| 97 | cd lib/doc/tutorial |
|---|
| 98 | ./update |
|---|
| 99 | rm update |
|---|
| 100 | cd ../../.. |
|---|
| 101 | |
|---|
| 102 | # A bit ugly with seperate date commands.. |
|---|
| 103 | MONTH=`date +"%b"` |
|---|
| 104 | DAY=`date +"%d"` |
|---|
| 105 | YEAR=`date +"%Y"` |
|---|
| 106 | sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcstas.h > mcstas.h.tmp |
|---|
| 107 | cat mcstas.h.tmp > mcstas.h |
|---|
| 108 | sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcformat.c > mcformat.c.tmp |
|---|
| 109 | cat mcformat.c.tmp > mcformat.c |
|---|
| 110 | sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcstas.1 > mcstas.1.tmp |
|---|
| 111 | cat mcstas.1.tmp > mcstas.1 |
|---|
| 112 | sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcrun.1 > mcrun.1.tmp |
|---|
| 113 | cat mcrun.1.tmp > mcrun.1 |
|---|
| 114 | sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcdoc.1 > mcdoc.1.tmp |
|---|
| 115 | cat mcdoc.1.tmp > mcdoc.1 |
|---|
| 116 | sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcgui.1 > mcgui.1.tmp |
|---|
| 117 | cat mcgui.1.tmp > mcgui.1 |
|---|
| 118 | sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcplot.1 > mcplot.1.tmp |
|---|
| 119 | cat mcplot.1.tmp > mcplot.1 |
|---|
| 120 | sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcdisplay.1 > mcdisplay.1.tmp |
|---|
| 121 | cat mcdisplay.1.tmp > mcdisplay.1 |
|---|
| 122 | sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcconvert.1 > mcconvert.1.tmp |
|---|
| 123 | cat mcconvert.1.tmp > mcconvert.1 |
|---|
| 124 | sed 's/X.Y.Z, Month Day, Year/'$1' - '$MONTH'. '$DAY', '$YEAR'/' mcformat.1 > mcformat.1.tmp |
|---|
| 125 | cat mcformat.1.tmp > mcformat.1 |
|---|
| 126 | sed 's/X.Y.Z/'$1'/' configure.in > configure.in.tmp |
|---|
| 127 | cat configure.in.tmp > configure.in |
|---|
| 128 | sed 's/@RELEASE@/'$1'/' deb/debcreate > deb/debcreate.new |
|---|
| 129 | mv deb/debcreate.new deb/debcreate |
|---|
| 130 | chmod a+x deb/debcreate |
|---|
| 131 | |
|---|
| 132 | # Create configure |
|---|
| 133 | autoconf configure.in > configure |
|---|
| 134 | chmod a+x configure |
|---|
| 135 | autoconf lib/tools/perl/mcstas_reconfigure.in > lib/tools/perl/mcstas_reconfigure |
|---|
| 136 | chmod a+x lib/tools/perl/mcstas_reconfigure |
|---|
| 137 | chmod a+w lib/tools/perl/mcstas_config.perl |
|---|
| 138 | |
|---|
| 139 | # run lex, yacc (assuming linux - flex -i & bison -v -d) |
|---|
| 140 | flex -i instrument.l |
|---|
| 141 | bison -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 |
|---|
| 146 | export 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 |
|---|
| 152 | make pgplot |
|---|
| 153 | |
|---|
| 154 | # Clean up |
|---|
| 155 | rm TODO.txt |
|---|
| 156 | rm mkdist |
|---|
| 157 | rm setversion |
|---|
| 158 | rm setyear |
|---|
| 159 | rm header |
|---|
| 160 | # Make new runs of configure not dependent of this system... |
|---|
| 161 | rm config.* |
|---|
| 162 | cd .. |
|---|
| 163 | |
|---|
| 164 | # Create tar archive |
|---|
| 165 | tar cfz $PW/../mcstas-$1-src.tar.gz mcstas-$1 |
|---|
| 166 | |
|---|
| 167 | # Do a 'make' for creation of binary version (should apply to 'any' Unix) |
|---|
| 168 | cd $PW |
|---|
| 169 | cd $DIST |
|---|
| 170 | |
|---|
| 171 | # Default again to Linux' /usr/bin/install -c (or whatever ./configure finds) |
|---|
| 172 | export INSTALL= |
|---|
| 173 | ./configure |
|---|
| 174 | # Select pgplot as default plotter |
|---|
| 175 | make pgplot |
|---|
| 176 | |
|---|
| 177 | make |
|---|
| 178 | UNAME=`uname` |
|---|
| 179 | MACH=`uname -m` |
|---|
| 180 | # Up to now, this is always done on intel... |
|---|
| 181 | PROC=Intel |
|---|
| 182 | cd .. |
|---|
| 183 | |
|---|
| 184 | # Create tar archive |
|---|
| 185 | tar 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 |
|---|
| 191 | cd $PW |
|---|
| 192 | cd $DIST |
|---|
| 193 | make clean |
|---|
| 194 | flex -i instrument.l |
|---|
| 195 | bison -v -d instrument.y |
|---|
| 196 | ./configure |
|---|
| 197 | sed 's/DOZIP="0"/DOZIP="1"/' build.bat > build.bat.new |
|---|
| 198 | sed 's/DONSIS="0"/DONSIS="1"/' build.bat.new > build.bat |
|---|
| 199 | cp support/Win32/which.exe . |
|---|
| 200 | cd .. |
|---|
| 201 | tar cfz $PW/../mcstas-$1-Win32-src.tar.gz mcstas-$1 |
|---|
| 202 | if [ `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` |
|---|
| 217 | else |
|---|
| 218 | echo Binary versions for Win32 NOT created |
|---|
| 219 | fi |
|---|
| 220 | echo |
|---|
| 221 | echo |
|---|
| 222 | echo Your mcstas dist packages are placed in |
|---|
| 223 | echo ../mcstas-$1-src.tar.gz |
|---|
| 224 | echo ../mcstas-$1-$MACH-$PROC-$UNAME.tar.gz |
|---|
| 225 | echo ../mcstas-$1-Win32-src.tar.gz |
|---|
| 226 | echo |
|---|
| 227 | echo NOTE: Win32 version must be built using \'build.bat\' of the Win32-src package |
|---|
| 228 | echo |
|---|
| 229 | echo Your mcstas doc packages are placed in |
|---|
| 230 | echo ../mcstas-$1-manual.ps.gz |
|---|
| 231 | echo ../mcstas-$1-manual.pdf |
|---|
| 232 | echo ../mcstas-$1-components.ps.gz |
|---|
| 233 | echo ../mcstas-$1-components.pdf |
|---|
| 234 | echo |
|---|
| 235 | echo WARNING: Please install to a test system and run the following tools |
|---|
| 236 | echo before release: |
|---|
| 237 | echo |
|---|
| 238 | echo compiletest.sh \(check if all examples compile\) |
|---|
| 239 | echo mcrun --test \(validation test of selected instruments\) |
|---|
| 240 | echo |
|---|
| 241 | echo Follow instructions in ../adm to publish on the web. |
|---|
| 242 | echo |
|---|
| 243 | |
|---|
| 244 | # In case of mkfs.hfsplus available in /sbin we'll create the |
|---|
| 245 | # DMG file for Mac OS X |
|---|
| 246 | if [ -e /sbin/mkfs.hfsplus ] |
|---|
| 247 | then |
|---|
| 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 |
|---|
| 266 | fi |
|---|
| 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) |
|---|
| 271 | if [ -e /etc/debian_version ] |
|---|
| 272 | then |
|---|
| 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 |
|---|
| 319 | fi |
|---|