| 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 |
|---|
| 33 | if [ "y$2" = "ymcxtrace" ]; then |
|---|
| 34 | MCCODE_TARNAME=mcxtrace |
|---|
| 35 | MCCODE_NAME=McXtrace |
|---|
| 36 | else |
|---|
| 37 | MCCODE_TARNAME=mcstas |
|---|
| 38 | MCCODE_NAME=McStas |
|---|
| 39 | fi |
|---|
| 40 | MCCODE_VERSION=$1 |
|---|
| 41 | MONTH=`date +"%b"` |
|---|
| 42 | DAY=`date +"%d"` |
|---|
| 43 | YEAR=`date +"%Y"` |
|---|
| 44 | MCCODE_DATE="$MONTH. $DAY, $YEAR" |
|---|
| 45 | MCCODE_STRING="$MCCODE_NAME $MCCODE_VERSION - $MONTH. $DAY, $YEAR" |
|---|
| 46 | |
|---|
| 47 | # Create temporary workdir: |
|---|
| 48 | PW=`pwd` |
|---|
| 49 | TMPDIR=$PWD/.. |
|---|
| 50 | DIST=$TMPDIR/$MCCODE_TARNAME-$MCCODE_VERSION |
|---|
| 51 | |
|---|
| 52 | # Copy current PW checkout to DIST |
|---|
| 53 | cp -rp $PW $DIST |
|---|
| 54 | |
|---|
| 55 | # Create the doc's from tex - if a checkout is avail. |
|---|
| 56 | if [ -d $PW/../../McStasTeX/trunk ] ; |
|---|
| 57 | then |
|---|
| 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 |
|---|
| 65 | fi |
|---|
| 66 | |
|---|
| 67 | # Go in DIST, clean up CVS/SVN information |
|---|
| 68 | cd $DIST |
|---|
| 69 | echo "Clean up SVN and git info" |
|---|
| 70 | find . -name .svn -exec rm -rf \{\} \; 2> /dev/null |
|---|
| 71 | find . -name .git -exec rm -rf \{\} \; 2> /dev/null |
|---|
| 72 | # Make sure that all comps and instrs have unix linefeeds |
|---|
| 73 | echo "Apply dos2unix" |
|---|
| 74 | find . -name \*.comp -exec dos2unix \{\} \; |
|---|
| 75 | find . -name \*.instr -exec dos2unix \{\} \; |
|---|
| 76 | |
|---|
| 77 | # Put in new version info: |
|---|
| 78 | # MCCODE_STRING="MCCODE_NAME MCCODE_VERSION - MCCODE_DATE" |
|---|
| 79 | echo "Set version $MCCODE_VERSION and date" |
|---|
| 80 | find . -wholename './setversion' -prune -o -type d -prune -o -path ./src/McStasTest -exec ./setversion \{\} $MCCODE_VERSION \; |
|---|
| 81 | find . -wholename './setyear' -prune -o -type d -prune -o -path ./src/McStasTest -exec ./setyear \{\} \; |
|---|
| 82 | |
|---|
| 83 | # we update all package/version strings |
|---|
| 84 | echo "Set package $MCCODE_VERSION information" |
|---|
| 85 | for iter in 1 2 3; |
|---|
| 86 | do |
|---|
| 87 | for 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 |
|---|
| 96 | done |
|---|
| 97 | chmod a+x support/deb/debcreate |
|---|
| 98 | |
|---|
| 99 | # Create the doc's from tex - if a checkout is avail. |
|---|
| 100 | cd $DIST |
|---|
| 101 | if [ -d $DIST/doc/install_docs/tex ] ; |
|---|
| 102 | then |
|---|
| 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/ |
|---|
| 133 | fi |
|---|
| 134 | cd $DIST |
|---|
| 135 | |
|---|
| 136 | # Create configure (which will itself create mccode_config.perl and mccode_reconfigure) |
|---|
| 137 | autoconf |
|---|
| 138 | |
|---|
| 139 | #-o configure $CONFIGURE_IN |
|---|
| 140 | |
|---|
| 141 | # run lex, yacc (assuming linux - flex -i & bison -v -d) |
|---|
| 142 | cd src |
|---|
| 143 | flex -i instrument.l |
|---|
| 144 | bison -v -d instrument.y |
|---|
| 145 | cd .. |
|---|
| 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 |
|---|
| 151 | export 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 | |
|---|
| 157 | cd lib/tools/perl |
|---|
| 158 | autoconf mccode_reconfigure > ${MCCODE_TARNAME}_reconfigure |
|---|
| 159 | chmod a+x ${MCCODE_TARNAME}_reconfigure |
|---|
| 160 | cd - |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | # Select scilab as default plotter |
|---|
| 164 | make pgplot |
|---|
| 165 | |
|---|
| 166 | # Clean up |
|---|
| 167 | rm TODO.txt |
|---|
| 168 | rm mkdist |
|---|
| 169 | rm setversion |
|---|
| 170 | rm setyear |
|---|
| 171 | rm header |
|---|
| 172 | # Make new runs of configure not dependent of this system... |
|---|
| 173 | rm config.* |
|---|
| 174 | cd .. |
|---|
| 175 | |
|---|
| 176 | # Create tar archive |
|---|
| 177 | tar 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) |
|---|
| 180 | cd $PW |
|---|
| 181 | cd $DIST |
|---|
| 182 | |
|---|
| 183 | # Default again to Linux' /usr/bin/install -c (or whatever ./configure finds) |
|---|
| 184 | export INSTALL= |
|---|
| 185 | ./configure |
|---|
| 186 | # Select pgplot as default plotter |
|---|
| 187 | make pgplot |
|---|
| 188 | |
|---|
| 189 | make |
|---|
| 190 | UNAME=`uname` |
|---|
| 191 | MACH=`uname -m` |
|---|
| 192 | # Up to now, this is always done on intel... |
|---|
| 193 | PROC=Intel |
|---|
| 194 | cd .. |
|---|
| 195 | |
|---|
| 196 | # Create tar archive |
|---|
| 197 | tar 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 |
|---|
| 203 | cd $PW |
|---|
| 204 | cd $DIST |
|---|
| 205 | make clean |
|---|
| 206 | cd src |
|---|
| 207 | flex -i instrument.l |
|---|
| 208 | bison -v -d instrument.y |
|---|
| 209 | cd .. |
|---|
| 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 |
|---|
| 214 | cp support/Win32/install/which.exe . |
|---|
| 215 | cd .. |
|---|
| 216 | tar cfz $PW/../$MCCODE_TARNAME-$MCCODE_VERSION-Win32-src.tar.gz $MCCODE_TARNAME-$MCCODE_VERSION |
|---|
| 217 | echo " " |
|---|
| 218 | echo "=========================================================================" |
|---|
| 219 | echo "mkdist: Distro creation for $MCCODE_STRING" |
|---|
| 220 | if [ `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` |
|---|
| 235 | else |
|---|
| 236 | echo Binary versions for Win32 NOT created |
|---|
| 237 | fi |
|---|
| 238 | echo |
|---|
| 239 | echo |
|---|
| 240 | echo Your $MCCODE_STRING dist packages are placed in |
|---|
| 241 | echo ../$MCCODE_TARNAME-$MCCODE_VERSION-src.tar.gz |
|---|
| 242 | echo ../$MCCODE_TARNAME-$MCCODE_VERSION-$MACH-$PROC-$UNAME.tar.gz |
|---|
| 243 | echo ../$MCCODE_TARNAME-$MCCODE_VERSION-Win32-src.tar.gz |
|---|
| 244 | echo |
|---|
| 245 | echo NOTE: Win32 version must be built using \'build.bat\' of the Win32-src package |
|---|
| 246 | echo |
|---|
| 247 | if [ -d $PW/../../McStasTeX/trunk ] ; |
|---|
| 248 | then |
|---|
| 249 | echo Your $MCCODE_STRING doc packages are placed in |
|---|
| 250 | echo ../$MCCODE_TARNAME-$MCCODE_VERSION-manual.ps.gz |
|---|
| 251 | echo ../$MCCODE_TARNAME-$MCCODE_VERSION-manual.pdf |
|---|
| 252 | echo ../$MCCODE_TARNAME-$MCCODE_VERSION-components.ps.gz |
|---|
| 253 | echo ../$MCCODE_TARNAME-$MCCODE_VERSION-components.pdf |
|---|
| 254 | fi |
|---|
| 255 | echo |
|---|
| 256 | echo WARNING: Please install to a test system and run the following tools |
|---|
| 257 | echo before release: |
|---|
| 258 | echo |
|---|
| 259 | echo compiletest.sh \(check if all examples compile\) |
|---|
| 260 | echo mcrun --test \(validation test of selected instruments\) |
|---|
| 261 | echo |
|---|
| 262 | echo Follow instructions in ../adm to publish on the web. |
|---|
| 263 | echo |
|---|
| 264 | |
|---|
| 265 | echo Build packages from `pwd` |
|---|
| 266 | # In case of mkfs.hfsplus available in /sbin we'll create the |
|---|
| 267 | # DMG file for Mac OS X |
|---|
| 268 | if [ -e /sbin/mkfs.hfsplus ] |
|---|
| 269 | then |
|---|
| 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 |
|---|
| 288 | fi |
|---|
| 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) |
|---|
| 293 | if [ -e /etc/debian_version ] |
|---|
| 294 | then |
|---|
| 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 |
|---|
| 343 | fi |
|---|
| 344 | |
|---|