scripts/build.sh
author Lennard de Rijk <ljvderijk@gmail.com>
Sat, 05 Sep 2009 14:04:24 +0200
changeset 2862 27971a13089f
parent 2832 2a0a7e081caf
child 2873 4fb030d43575
permissions -rwxr-xr-x
Fixed Ivory Coast rename that was introduced in r74f0972f52.
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"
2832
2a0a7e081caf Profiling patch
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2679
diff changeset
    13
DEFAULT_APP_FILES="app.yaml cron.yaml index.yaml queue.yaml main.py settings.py
2a0a7e081caf Profiling patch
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2679
diff changeset
    14
shell.py urls.py gae_django.py profiler.py"
2377
8f3771ff383b Add taggable-mixin and gviz to build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2335
diff changeset
    15
DEFAULT_APP_DIRS="soc ghop gsoc feedparser python25src reflistprop jquery \
2832
2a0a7e081caf Profiling patch
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2679
diff changeset
    16
    ranklist shell json htmlsanitizer taggable gviz app_profiler"
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
    17
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
    18
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    19
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
    20
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
    21
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
    22
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
    23
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
    24
2328
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    25
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    26
if [ "$1" != "--skip-pylint" ]; then
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    27
  cd pylint
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    28
  bash do_pylint.sh --silent
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    29
  if [ "$?" != "1" ] ; then
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    30
      echo ' Build failed. Build script encountered pylint errors.'
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    31
      exit 1
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    32
  fi
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    33
  cd ..
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    34
fi
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    35
1808
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    36
if [ -e $APP_FOLDER ] ; then
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    37
    cd $APP_FOLDER
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    38
else
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    39
    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
    40
    exit 1
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    41
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
    42
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
# 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
    44
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
    45
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    46
# 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
    47
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
    48
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    49
# 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
    50
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
    51
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    52
# 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
    53
# 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
    54
# 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
    55
# 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
    56
#
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
    57
# 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
    58
# - .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
    59
# - 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
    60
# - *.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
    61
# - *.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
    62
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    63
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
    64
    -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
    65
    -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
    66
    -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
    67
    -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
    68
    -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
    69
    -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
    70
    -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
    71
    -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
    72
    -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
    73
    -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
    74
    -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
    75
    -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
    76
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
    77
# 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
    78
#
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
    79
# 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
    80
# - .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
    81
160
269462f166ef Explain why pushd and popd are needed when making tiny_mce.zip.
Todd Larsen <tlarsen@google.com>
parents: 159
diff changeset
    82
# 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
    83
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
    84
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
    85
    -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
    86
    -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
    87
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
    88
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
    89
# 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
    90
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
    91
do
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    92
    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
    93
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
    94
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    95
echo "Build results in $APP_BUILD."