scripts/build.sh
author Lennard de Rijk <ljvderijk@gmail.com>
Fri, 03 Jul 2009 15:00:00 +0200
changeset 2506 c98bf890156e
parent 2377 8f3771ff383b
child 2599 22e1ec7bd02a
permissions -rwxr-xr-x
Removed getSurveyResponseFromPost from Surveys helper. We will use the power of Django Forms instead of getting our own properties. This fits better into the rest of Melange which also uses this approach.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
158
2d5a7c18f9ea Updated make_release.sh docs and added way for person invoking the script to override script variables such as RELEASE using something like "RELEASE=../testing_release ./make_release.sh".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 157
diff changeset
     1
#!/bin/bash
144
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     2
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
     3
# Script to create a "build" subdirectory.  This is a subdirectory
144
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     4
# containing a bunch of symlinks, from which the app can be updated.
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     5
# The main reason for this is to import Django from a zipfile, which
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     6
# saves dramatically in upload time: statting and computing the SHA1
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     7
# for 1000s of files is slow.  Even if most of those files don't
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     8
# actually need to be uploaded, they still add to the work done for
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     9
# each update.
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    10
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    11
DEFAULT_APP_BUILD=../build
158
2d5a7c18f9ea Updated make_release.sh docs and added way for person invoking the script to override script variables such as RELEASE using something like "RELEASE=../testing_release ./make_release.sh".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 157
diff changeset
    12
DEFAULT_APP_FOLDER="../app"
2335
366e64ecba91 Add web based python shell to Melange.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2328
diff changeset
    13
DEFAULT_APP_FILES="app.yaml cron.yaml index.yaml main.py settings.py shell.py urls.py gae_django.py"
2377
8f3771ff383b Add taggable-mixin and gviz to build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2335
diff changeset
    14
DEFAULT_APP_DIRS="soc ghop gsoc feedparser python25src reflistprop jquery \
8f3771ff383b Add taggable-mixin and gviz to build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2335
diff changeset
    15
    ranklist shell json htmlsanitizer taggable-mixin gviz"
175
9ed9bf2814ef Make django.zip in release/, instead of in app/ with a symlink in release/.
Todd Larsen <tlarsen@google.com>
parents: 160
diff changeset
    16
DEFAULT_ZIP_FILES="tiny_mce.zip"
158
2d5a7c18f9ea Updated make_release.sh docs and added way for person invoking the script to override script variables such as RELEASE using something like "RELEASE=../testing_release ./make_release.sh".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 157
diff changeset
    17
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    18
APP_BUILD=${APP_BUILD:-"${DEFAULT_APP_BUILD}"}
158
2d5a7c18f9ea Updated make_release.sh docs and added way for person invoking the script to override script variables such as RELEASE using something like "RELEASE=../testing_release ./make_release.sh".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 157
diff changeset
    19
APP_FOLDER=${APP_FOLDER:-"${DEFAULT_APP_FOLDER}"}
2d5a7c18f9ea Updated make_release.sh docs and added way for person invoking the script to override script variables such as RELEASE using something like "RELEASE=../testing_release ./make_release.sh".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 157
diff changeset
    20
APP_FILES=${APP_FILES:-"${DEFAULT_APP_FILES}"}
2d5a7c18f9ea Updated make_release.sh docs and added way for person invoking the script to override script variables such as RELEASE using something like "RELEASE=../testing_release ./make_release.sh".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 157
diff changeset
    21
APP_DIRS=${APP_DIRS:-"${DEFAULT_APP_DIRS}"}
159
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    22
ZIP_FILES=${ZIP_FILES:-"${DEFAULT_ZIP_FILES}"}
144
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    23
2328
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    24
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    25
if [ "$1" != "--skip-pylint" ]; then
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    26
  cd pylint
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    27
  bash do_pylint.sh --silent
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    28
  if [ "$?" != "1" ] ; then
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    29
      echo ' Build failed. Build script encountered pylint errors.'
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    30
      exit 1
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    31
  fi
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    32
  cd ..
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    33
fi
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    34
1808
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    35
if [ -e $APP_FOLDER ] ; then
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    36
    cd $APP_FOLDER
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    37
else
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    38
    echo 'This script must be run from within the scripts directory!'
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    39
    exit 1
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    40
fi
175
9ed9bf2814ef Make django.zip in release/, instead of in app/ with a symlink in release/.
Todd Larsen <tlarsen@google.com>
parents: 160
diff changeset
    41
9ed9bf2814ef Make django.zip in release/, instead of in app/ with a symlink in release/.
Todd Larsen <tlarsen@google.com>
parents: 160
diff changeset
    42
# Remove old zip files (and django.zip in its old location)
9ed9bf2814ef Make django.zip in release/, instead of in app/ with a symlink in release/.
Todd Larsen <tlarsen@google.com>
parents: 160
diff changeset
    43
rm -rf $ZIP_FILES django.zip
9ed9bf2814ef Make django.zip in release/, instead of in app/ with a symlink in release/.
Todd Larsen <tlarsen@google.com>
parents: 160
diff changeset
    44
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    45
# Remove old $APP_BUILD directory.
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    46
rm -rf $APP_BUILD
144
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    47
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    48
# Create new $APP_BUILD directory.
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    49
mkdir $APP_BUILD
175
9ed9bf2814ef Make django.zip in release/, instead of in app/ with a symlink in release/.
Todd Larsen <tlarsen@google.com>
parents: 160
diff changeset
    50
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    51
# Create new django.zip file, but directly in the $APP_BUILD directory,
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    52
# rather than in $APP_FOLDER and creating a symlink in $APP_BUILD.  This
175
9ed9bf2814ef Make django.zip in release/, instead of in app/ with a symlink in release/.
Todd Larsen <tlarsen@google.com>
parents: 160
diff changeset
    53
# keeps the presence of a django.zip file in the app/ folder from breaking
9ed9bf2814ef Make django.zip in release/, instead of in app/ with a symlink in release/.
Todd Larsen <tlarsen@google.com>
parents: 160
diff changeset
    54
# debugging into app/django.
9ed9bf2814ef Make django.zip in release/, instead of in app/ with a symlink in release/.
Todd Larsen <tlarsen@google.com>
parents: 160
diff changeset
    55
#
144
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    56
# We prune:
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    57
# - .svn subdirectories for obvious reasons.
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    58
# - contrib/gis/ and related files because it's huge and unneeded.
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    59
# - *.po and *.mo files because they are bulky and unneeded.
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    60
# - *.pyc and *.pyo because they aren't used by App Engine anyway.
150
715b07485c48 Changed ZIPFILE variable to DJANGO_ZIPFILE in make_release.sh script and added 'cd $APP_FOLDER' before we zip django.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 144
diff changeset
    61
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    62
zip -q "$APP_BUILD/django.zip" `find django \
144
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    63
    -name .svn -prune -o \
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    64
    -name gis -prune -o \
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    65
    -name admin -prune -o \
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    66
    -name localflavor -prune -o \
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    67
    -name mysql -prune -o \
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    68
    -name mysql_old -prune -o \
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    69
    -name oracle -prune -o \
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    70
    -name postgresql-prune -o \
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    71
    -name postgresql_psycopg2 -prune -o \
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    72
    -name sqlite3 -prune -o \
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    73
    -name test -prune -o \
150
715b07485c48 Changed ZIPFILE variable to DJANGO_ZIPFILE in make_release.sh script and added 'cd $APP_FOLDER' before we zip django.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 144
diff changeset
    74
    -type f ! -name \*.py[co] ! -name *.[pm]o -print`
144
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    75
159
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    76
# Create new tiny_mce.zip file.
175
9ed9bf2814ef Make django.zip in release/, instead of in app/ with a symlink in release/.
Todd Larsen <tlarsen@google.com>
parents: 160
diff changeset
    77
#
159
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    78
# We prune:
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    79
# - .svn subdirectories for obvious reasons.
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    80
160
269462f166ef Explain why pushd and popd are needed when making tiny_mce.zip.
Todd Larsen <tlarsen@google.com>
parents: 159
diff changeset
    81
# zipserve requires tiny_mce/* to be in root of zip file
159
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    82
pushd tiny_mce > /dev/null
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    83
zip -q ../tiny_mce.zip `find . \
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    84
    -name .svn -prune -o \
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    85
    -type f -print`
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    86
popd > /dev/null
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    87
144
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    88
# Create symbolic links.
159
451f39c0e1aa Use zip to compress tiny_mce, and use zipserve to serve it in Google App
Todd Larsen <tlarsen@google.com>
parents: 158
diff changeset
    89
for x in $APP_FILES $APP_DIRS $ZIP_FILES
144
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    90
do
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    91
    ln -s $APP_FOLDER/$x $APP_BUILD/$x
144
53d8b8064019 Release shell script and associated changes. Set svn:ignore property on /app/django.zip file and /release folder.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    92
done
158
2d5a7c18f9ea Updated make_release.sh docs and added way for person invoking the script to override script variables such as RELEASE using something like "RELEASE=../testing_release ./make_release.sh".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 157
diff changeset
    93
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    94
echo "Build results in $APP_BUILD."