scripts/build.sh
author Pawel Solyga <Pawel.Solyga@gmail.com>
Thu, 21 May 2009 14:44:41 +0200
changeset 2331 91379f6b8fcb
parent 2328 e077dc264dff
child 2335 366e64ecba91
permissions -rwxr-xr-x
Add sorting of student projects on organization home page. List of student projects on organization home page is now sorted in alphabetical order by student name. Fixes issue 613.
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"
2303
11cf7f2cc4ff [PATCH] Remove __init__.py from app, as app is not a module
Sverre Rabbelier <sverre@rabbelier.nl>
parents: 2227
diff changeset
    13
DEFAULT_APP_FILES="app.yaml cron.yaml index.yaml main.py settings.py urls.py"
2326
16c1b1412b0d Add htmlsanitizer folder to build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2303
diff changeset
    14
DEFAULT_APP_DIRS="soc ghop gsoc feedparser python25src reflistprop jquery ranklist json htmlsanitizer"
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
    15
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
    16
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    17
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
    18
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
    19
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
    20
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
    21
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
    22
2328
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    23
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    24
if [ "$1" != "--skip-pylint" ]; then
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    25
  cd pylint
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    26
  bash do_pylint.sh --silent
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    27
  if [ "$?" != "1" ] ; then
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    28
      echo ' Build failed. Build script encountered pylint errors.'
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    29
      exit 1
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    30
  fi
e077dc264dff Invoke pylint from build script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2326
diff changeset
    31
  cd ..
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
1808
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    34
if [ -e $APP_FOLDER ] ; then
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    35
    cd $APP_FOLDER
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    36
else
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    37
    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
    38
    exit 1
f6ec0f486247 build.sh: bail if run in the wrong directory.
Augie Fackler <durin42@gmail.com>
parents: 1731
diff changeset
    39
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
    40
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
# 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
    42
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
    43
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    44
# 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
    45
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
    46
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    47
# 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
    48
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
    49
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    50
# 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
    51
# 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
    52
# 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
    53
# 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
    54
#
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
    55
# 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
    56
# - .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
    57
# - 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
    58
# - *.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
    59
# - *.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
    60
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    61
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
    62
    -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
    63
    -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
    64
    -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
    65
    -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
    66
    -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
    67
    -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
    68
    -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
    69
    -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
    70
    -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
    71
    -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
    72
    -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
    73
    -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
    74
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
    75
# 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
    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
# 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
    78
# - .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
    79
160
269462f166ef Explain why pushd and popd are needed when making tiny_mce.zip.
Todd Larsen <tlarsen@google.com>
parents: 159
diff changeset
    80
# 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
    81
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
    82
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
    83
    -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
    84
    -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
    85
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
    86
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
    87
# 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
    88
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
    89
do
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    90
    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
    91
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
    92
910
384e55e48706 Change build.sh to create a build/ output directory (rather than release/).
Todd Larsen <tlarsen@google.com>
parents: 909
diff changeset
    93
echo "Build results in $APP_BUILD."