More tidying.
[yaffs-website] / vendor / drush / drush / misc / windrush_build / windrush_build
1 #!/bin/bash
2
3 ########################################
4 # Configurations
5
6 BINTOOL_GIT=https://github.com/acquia/DevDesktopCommon.git
7 PHP_VER=5.4.41-nts-Win32-VC9-x86
8 # NOTE there in also "5.5" string in the download url. Change it if upgrading to 5.6
9 MYSQL_VER=5.5.41-win32
10 # goes to composer require command
11 DRUSH_VER=7.0.0
12
13 TOPDIR=windrush
14
15 ########################################
16 # Utils
17
18 fail() {
19   echo "$1">&2
20   kill -s TERM $$
21 }
22
23 replace_in_file() {
24   sed "s/$1/$2/" "$3" > aa.tmp
25   mv aa.tmp "$3"
26 }
27
28 enable_php_extension() {
29   for a in $1 ; do
30     replace_in_file ";extension=php_$a.dll" "extension=php_$a.dll" "$2"
31   done
32 }
33
34
35 ########################################
36 # Prepare $TOPDIR dir
37
38 [ -e $TOPDIR ] && ( rm -r -f $TOPDIR || fail "Could not remove $TOPDIR dir" )
39 mkdir $TOPDIR
40
41
42 ########################################
43 # MSYS & other binary tools
44 #
45
46 # msys & stuff from the DD repo
47 #svn export $BINTOOL_SVN $TOPDIR/tools || fail "Svn failed to export from $BINTOOL_SVN"
48 [ -e DevDesktopCommon ] && rm -r -f DevDesktopCommon
49 git clone $BINTOOL_GIT  || fail "Git failed to get $BINTOOL_GIT"
50 mv DevDesktopCommon/bintools-win/msys $TOPDIR/tools
51 rm -r -f DevDesktopCommon
52
53 # mysql
54 MYSQL_ZIP=mysql-$MYSQL_VER.zip
55 MYSQL_URL=http://dev.mysql.com/get/Downloads/MySQL-5.5/$MYSQL_ZIP
56 if [ ! -e $MYSQL_ZIP ]; then
57   wget $MYSQL_URL || fail "Could not download MySQL from $MYSQL_URL"
58 fi
59
60 unzip -o -j $MYSQL_ZIP mysql-$MYSQL_VER/bin/mysql.exe -d $TOPDIR/tools/bin
61 unzip -o -j $MYSQL_ZIP mysql-$MYSQL_VER/bin/mysqldump.exe -d $TOPDIR/tools/bin
62
63 ########################################
64 # PHP
65
66 PHP_ZIP=php-$PHP_VER.zip
67 PHP_URL=http://windows.php.net/downloads/releases/$PHP_ZIP
68 if [ ! -e $PHP_ZIP ]; then
69   wget $PHP_URL || fail "Could not download PHP from $PHP_URL"
70 fi
71
72 unzip $PHP_ZIP -d $TOPDIR/php
73
74 PHP_INI=$TOPDIR/php/php.ini
75
76 cp "$PHP_INI-development" "$PHP_INI"
77 replace_in_file '; extension_dir = "ext"' 'extension_dir = "ext"' "$PHP_INI"
78 enable_php_extension "bz2 curl fileinfo gd2 gettext intl mbstring mysql mysqli openssl pdo_mysql soap sockets tidy xmrpc xsl" "$PHP_INI"
79
80 ########################################
81 # Drush, composer and setenv stuff
82
83 cd $TOPDIR
84 php -r "readfile('https://getcomposer.org/installer');" | php
85 ./composer.phar require drush/drush:$DRUSH_VER || fail "Composer failed"
86 cd ..
87
88 cp assets/drush.bat $TOPDIR
89 cp assets/composer.bat $TOPDIR
90 cp assets/setenv.bat $TOPDIR
91 cp assets/setenv.js $TOPDIR
92 cp assets/notify_env_change.exe $TOPDIR/tools/bin
93
94
95 ########################################
96 # Zip everything up
97
98 [ -e $TOPDIR.zip ] && rm $TOPDIR.zip
99 zip -r $TOPDIR.zip $TOPDIR
100 cd ..
101
102
103 echo "Done."