diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-09-19 06:24:46 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-09-19 06:24:46 +0400 |
commit | 2916962bab02003857fb332091ff0fbdae25f006 (patch) | |
tree | 52526424a8140dce1b5c12a1f63118f9c699d093 | |
parent | b3eabc90e12e8b91113b77005e442f7bc5eee06d (diff) |
updating build script
-rwxr-xr-x | misc/package/build.sh | 100 |
1 files changed, 82 insertions, 18 deletions
diff --git a/misc/package/build.sh b/misc/package/build.sh index 5978d4b191..57facd3a06 100755 --- a/misc/package/build.sh +++ b/misc/package/build.sh @@ -1,10 +1,19 @@ #!/bin/bash # Syntax: build.sh version|'nightly'|'webtest' +# $ git tag 1.11-b3 +# $ git push origin tags/1.11-b3 + +# SETUP: +# repo should be in DEST_PATH/piwik_last_version eg. /home/piwik-builds/builds/piwik_last_version +# git clone -- https://github.com/piwik/piwik.git /home/piwik-builds/builds/piwik_last_version || die "Problem checking out the last version tag" +# $ curl -sS https://getcomposer.org/installer | php VERSION="$1" -DEST_PATH=/home/piwik/builds +DEST_PATH=/home/piwik-builds/builds URL_REPO=https://github.com/piwik/piwik.git -HTTP_PATH=/home/piwik/www/builds.piwik.org +HTTP_PATH=/home/piwik-builds/www/builds.piwik.org +API_SCP_LATEST=piwik-api@localhost:/home/piwik-api/www/api.piwik.org/ +WWW_SCP_LATEST=piwik@localhost:/home/piwik/www/ # report error and exit function die() { @@ -18,22 +27,38 @@ function cleanupWorkspace() { rm -f *.html rm -f *.xml rm -f *.sql + rm -f *.md + rm -f *.html.* } # organize files for packaging function organizePackage() { + cd piwik/ + + curl -sS https://getcomposer.org/installer | php + php composer.phar install + cd ../ + + rm -rf piwik/composer.phar + rm -rf piwik/vendor/twig/twig/test/ + rm -rf piwik/vendor/twig/twig/doc/ + rm -rf piwik/libs/PhpDocumentor-1.3.2/ rm -rf piwik/libs/FirePHPCore/ rm -f piwik/libs/open-flash-chart/php-ofc-library/ofc_upload_image.php rm -rf piwik/tmp/* - rm -f piwik/misc/db-schema* - rm -f piwik/misc/diagram_general_request* - - cp piwik/tests/README.txt . + rm -rf piwik/tmp/.gitkeep + rm -f piwik/misc/updateLanguageFiles.sh + rm -f piwik/misc/others/db-schema* + rm -f piwik/misc/others/diagram_general_request* + rm -rf piwik/.git* + rm -f piwik/.travis* + + cp piwik/tests/README.md . find piwik -name 'tests' -type d -prune -exec rm -rf {} \; mkdir piwik/tests - mv README.txt piwik/tests/ + mv README.md piwik/tests/ cp piwik/misc/How\ to\ install\ Piwik.html . if [ -e piwik/misc/package ]; then @@ -46,7 +71,8 @@ function organizePackage() { fi fi - find piwik -type f -printf '%s ' -exec md5sum {} \; | fgrep -v 'manifest.inc.php' | sed '1,$ s/\([0-9]*\) \([a-z0-9]*\) *piwik\/\(.*\)/\t\t"\3" => array("\1", "\2"),/;' | sort | sed '1 s/^/<?php\n\/\/ This file is automatically generated during the Piwik build process\nclass Manifest {\n\tstatic $files=array(\n/; $ s/$/\n\t);\n}/' > piwik/config/manifest.inc.php + find piwik -type f -printf '%s ' -exec md5sum {} \; | grep -v "user/.htaccess" | egrep -v 'manifest.inc.php|autoload.php|autoload_real.php' | sed '1,$ s/\([0-9]*\) \([a-z0-9]*\) *piwik\/\(.*\)/\t\t"\3" => array("\1", "\2"),/;' | sort | sed '1 s/^/<?php\n\/\/ This file is automatically generated during the Piwik build process\nnamespace Piwik;\nclass Manifest {\n\tstatic $files=array(\n/; $ s/$/\n\t);\n}/' > piwik/config/manifest.inc.php + } if [ -z "$VERSION" ]; then @@ -100,7 +126,13 @@ GET_LATEST_VERSION echo "ok"; SUBSCRIBE_NEWSLETTER ;; + +# BUILDING RELEASE * ) + # Setting umask so it works for most users, see http://dev.piwik.org/trac/ticket/3869 + UMASK=`umask` + umask 0022 + if [ ! -e $DEST_PATH ] ; then echo "Destination directory does not exist... Creating it!"; mkdir -p $DEST_PATH; @@ -109,16 +141,23 @@ SUBSCRIBE_NEWSLETTER cd $DEST_PATH cleanupWorkspace - echo "checkout repository for tag $VERSION" - rm -rf $DEST_PATH/piwik_last_version - git clone -q -- $URL_REPO $DEST_PATH/piwik_last_version || die "Problem checking out the last version tag" + if [ ! -e $DEST_PATH/piwik_last_version ] ; then + git clone -- $URL_REPO $DEST_PATH/piwik_last_version + fi + echo "checkout repository for tag $VERSION..." cd $DEST_PATH/piwik_last_version - git checkout tags/$VERSION -q - + git pull + + echo "copying files to a new directory..." + cd .. + rm -Rf piwik + cp -R piwik_last_version piwik + cd piwik + git checkout tags/$VERSION cd $DEST_PATH + echo "preparing release $VERSION" - mv piwik_last_version piwik echo `grep "'$VERSION'" piwik/core/Version.php` if [ `grep "'$VERSION'" piwik/core/Version.php | wc -l` -ne 1 ]; then echo "version $VERSION does not match core/Version.php"; @@ -129,16 +168,25 @@ SUBSCRIBE_NEWSLETTER organizePackage echo "packaging release..." - zip -r piwik-$VERSION.zip piwik How\ to\ install\ Piwik.html > /dev/null 2> /dev/null + zip -r piwik-$VERSION.zip piwik How\ to\ install\ Piwik.html > /dev/null tar -czf piwik-$VERSION.tar.gz piwik How\ to\ install\ Piwik.html mv piwik-$VERSION.{zip,tar.gz} $HTTP_PATH zip -r piwik-$VERSION-WAG.zip piwik *.xml *.sql > /dev/null 2> /dev/null + mkdir $HTTP_PATH/WebAppGallery 2> /dev/null mv piwik-$VERSION-WAG.zip $HTTP_PATH/WebAppGallery/piwik-$VERSION.zip + # setting back umask + umask $UMASK + if [ `echo $VERSION | grep -E 'rc|b|a|alpha|beta|dev' -i | wc -l` -eq 1 ]; then - echo "Beta or RC release"; - echo $VERSION > $HTTP_PATH/LATEST_BETA + if [ `echo $VERSION | grep -E 'rc|b|beta' -i | wc -l` -eq 1 ]; then + echo "Beta or RC release"; + echo $VERSION > $HTTP_PATH/LATEST_BETA + fi + + #softwares reads builds.piwik.org/LATEST_BETA directly + echo "build finished! http://builds.piwik.org/piwik-$VERSION.zip" else echo "Stable release"; @@ -148,11 +196,27 @@ SUBSCRIBE_NEWSLETTER ln -sf $HTTP_PATH/piwik-$VERSION.$i $HTTP_PATH/latest.$i done + # record filesize in Mb + ls -l $HTTP_PATH/piwik-$VERSION.zip | awk '/d|-/{printf("%.3f %s\n",$5/(1024*1024),$9)}' > LATEST_SIZE + echo $VERSION > $HTTP_PATH/LATEST echo $VERSION > $HTTP_PATH/LATEST_BETA - echo "build finished! http://piwik.org/latest.zip" + + echo "scp piwik-api@..." + scp $HTTP_PATH/LATEST $API_SCP_LATEST + + echo "scp piwik@... (filesize = " && echo LATEST_SIZE && echo ")" + scp $HTTP_PATH/LATEST LATEST_SIZE $WWW_SCP_LATEST + + echo "In Dec. remove this and restore 301 redirects on piwik.org" + scp $HTTP_PATH/piwik-$VERSION.zip $WWW_SCP_LATEST/piwik.org/latest.zip + rm LATEST_SIZE + + echo "build finished! http://builds.piwik.org/latest.zip" fi ;; esac cleanupWorkspace + + |