| 1 | #!/bin/bash |
| 2 | |
| 3 | die() { |
| 4 | echo $* |
| 5 | exit 1 |
| 6 | } |
| 7 | |
| 8 | default_tag="javascriptcore-snapshot-02022010" |
| 9 | |
| 10 | if [ $# -eq 0 ]; then |
| 11 | tag="$default_tag" |
| 12 | elif [ $# -eq 1 ]; then |
| 13 | tag=$1 |
| 14 | else |
| 15 | die "usage: $0 [commit (defaults to $default_tag)]" |
| 16 | fi |
| 17 | |
| 18 | repository=`git config qtwebkit.url` |
| 19 | if [ -z "$repository" ]; then |
| 20 | die "error: cannot locate webkit git repository. please run git config --global qtwebkit.url /path-or-url/to/webkit/repo" |
| 21 | fi |
| 22 | |
| 23 | excluded_directories="$excluded_directories JavaScriptCore/Makefile" |
| 24 | excluded_directories="$excluded_directories JavaScriptCore/GNUmakefile.am" |
| 25 | excluded_directories="$excluded_directories JavaScriptCore/Configurations" |
| 26 | excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.exp" |
| 27 | excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.xcodeproj" |
| 28 | excluded_directories="$excluded_directories JavaScriptCore/tests" |
| 29 | excluded_directories="$excluded_directories JavaScriptCore/API/tests" |
| 30 | excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.vcproj" |
| 31 | excluded_directories="$excluded_directories JavaScriptCore/wtf/wx" |
| 32 | excluded_directories="$excluded_directories JavaScriptCore/wtf/gtk" |
| 33 | excluded_directories="$excluded_directories JavaScriptCore/wtf/mac" |
| 34 | excluded_directories="$excluded_directories JavaScriptCore/wtf/win" |
| 35 | excluded_directories="$excluded_directories JavaScriptCore/wtf/chromium" |
| 36 | excluded_directories="$excluded_directories JavaScriptCore/wtf/haiku" |
| 37 | excluded_directories="$excluded_directories JavaScriptCore/icu" |
| 38 | excluded_directories="$excluded_directories JavaScriptCore/qt" |
| 39 | excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.gyp" |
| 40 | |
| 41 | |
| 42 | files_to_remove="" |
| 43 | files_to_remove="$files_to_remove JavaScriptCore/AllInOneFile.cpp" |
| 44 | files_to_remove="$files_to_remove JavaScriptCore/JavaScriptCoreSources.bkl" |
| 45 | files_to_remove="$files_to_remove JavaScriptCore/jscore.bkl" |
| 46 | files_to_remove="$files_to_remove JavaScriptCore/jsc.pro" |
| 47 | files_to_remove="$files_to_remove JavaScriptCore/JavaScriptCore.pro" |
| 48 | files_to_remove="$files_to_remove JavaScriptCore/DerivedSources.pro" |
| 49 | files_to_remove="$files_to_remove JavaScriptCore/create_rvct_stubs" |
| 50 | |
| 51 | require_clean_work_tree() { |
| 52 | # test if working tree is dirty |
| 53 | git rev-parse --verify HEAD > /dev/null && |
| 54 | git update-index --refresh && |
| 55 | git diff-files --quiet && |
| 56 | git diff-index --cached --quiet HEAD || |
| 57 | die "Working tree is dirty" |
| 58 | } |
| 59 | |
| 60 | which qmake >/dev/null 2>/dev/null |
| 61 | if [ "$?" != 0 ]; then |
| 62 | die "abort: Could not locate qmake in your PATH" |
| 63 | fi |
| 64 | |
| 65 | test -z "$(git rev-parse --show-cdup)" || { |
| 66 | exit=$? |
| 67 | echo >&2 "You need to run this command from the toplevel of the working tree." |
| 68 | exit $exit |
| 69 | } |
| 70 | |
| 71 | echo "checking working tree" |
| 72 | require_clean_work_tree |
| 73 | |
| 74 | revCount=`git ls-remote $repository | grep $tag | awk '{print $1}' | wc -l` |
| 75 | if [ "$revCount" != 1 ]; then |
| 76 | die "Cannot parse $tag into a revision. It seems ambiguous". |
| 77 | fi |
| 78 | |
| 79 | rev=`git ls-remote $repository | grep -E "^.+$tag$" | awk '{print $1}'` |
| 80 | |
| 81 | tarball=`mktemp /tmp/webkit-snapshot.tar.XXXXXX` || exit 1 |
| 82 | echo "creating $tarball" |
| 83 | |
| 84 | echo "archiving webkit from $repository $tag ( $rev )" |
| 85 | |
| 86 | git archive --remote=$repository $rev JavaScriptCore WebKit.pri > $tarball || exit 1 |
| 87 | |
| 88 | echo "removing unwanted files and directories" |
| 89 | for dir in $excluded_directories; do |
| 90 | echo " removing $dir" |
| 91 | tar --delete --file=$tarball $dir |
| 92 | done |
| 93 | |
| 94 | for item in $exclude_with_exceptions_list; do |
| 95 | dir=`echo $item | awk -F : '{print $1}'` |
| 96 | include=`echo $item | awk -F : '{print $2}'` |
| 97 | echo " removing $dir except $include" |
| 98 | files=`tar --list --file=$tarball $dir | grep -v -E "^$dir\$" | grep -v $include` |
| 99 | tar --delete --file=$tarball $files |
| 100 | done |
| 101 | |
| 102 | for file in $files_to_remove; do |
| 103 | echo " removing $file" |
| 104 | tar --delete --file=$tarball $file |
| 105 | done |
| 106 | |
| 107 | echo "done!" |
| 108 | |
| 109 | srcdir=src/3rdparty/javascriptcore |
| 110 | absSrcDir=$PWD/$srcdir |
| 111 | localDiff= |
| 112 | lastImportRevison= |
| 113 | |
| 114 | echo "replacing $srcdir" |
| 115 | if [ -d $srcdir ]; then |
| 116 | git ls-files $srcdir | xargs rm |
| 117 | git ls-files -z src/3rdparty/javascriptcore | git update-index --force-remove -z --stdin |
| 118 | else |
| 119 | mkdir -p $srcdir |
| 120 | fi |
| 121 | |
| 122 | (cd $srcdir && tar xf $tarball) |
| 123 | git add $srcdir |
| 124 | |
| 125 | echo "generating extra sources" |
| 126 | ( |
| 127 | for proj in JavaScriptCore; do |
| 128 | cd $absSrcDir/$proj && |
| 129 | rm -rf tmp && |
| 130 | mkdir tmp && |
| 131 | cd tmp && |
| 132 | mkdir -p ../generated && |
| 133 | qmake -o Makefile CONFIG-=QTDIR_build QT_CONFIG+=phonon GENERATED_SOURCES_DIR=`pwd`/../generated OUTPUT_DIR=`pwd` ../$proj.pro && |
| 134 | make generated_files && |
| 135 | perl -pi -e "s,$absSrcDir/,,g" ../generated/*.cpp ../generated/*.h && |
| 136 | git add ../generated && |
| 137 | cd .. && |
| 138 | rm -rf tmp && |
| 139 | cd .. |
| 140 | done |
| 141 | ) |
| 142 | rm -rf $srcdir/WebKitBuild |
| 143 | |
| 144 | cat >$srcdir/VERSION <<EOT |
| 145 | This is a snapshot of JavaScriptCore from |
| 146 | |
| 147 | git://gitorious.org/qtwebkit/qtwebkit.git |
| 148 | |
| 149 | The commit imported was from the |
| 150 | |
| 151 | $tag branch/tag |
| 152 | |
| 153 | and has the sha1 checksum |
| 154 | |
| 155 | $rev |
| 156 | EOT |
| 157 | git add $srcdir/VERSION |
| 158 | |
| 159 | git diff-files --name-only -z | git update-index --remove -z --stdin |
| 160 | |
| 161 | echo "removing $tarball" |
| 162 | rm -f $tarball |
| 163 | |
| 164 | cat >commitlog.txt <<EOT |
| 165 | Updated JavaScriptCore from $repository to $tag ( $rev ) |
| 166 | EOT |
| 167 | |
| 168 | if [ -d "$repository/.git" -a -n "$lastImportRevison" ]; then |
| 169 | echo >>commitlog.txt |
| 170 | echo "Changes in WebKit/qt since the last update:" >>commitlog.txt |
| 171 | echo >>commitlog.txt |
| 172 | git --git-dir=$repository/.git diff $lastImportRevison $rev -- WebKit/qt/ChangeLog | sed -n -e "s,^\+\(.*\),\1,p" >>commitlog.txt |
| 173 | fi |
| 174 | |
| 175 | echo "Changes:" |
| 176 | echo |
| 177 | git --no-pager diff --name-status --cached $srcdir |
| 178 | |
| 179 | echo |
| 180 | echo "Wrote commitlog.txt. Use with" |
| 181 | echo |
| 182 | echo " git commit -e -F commitlog.txt" |
| 183 | echo |
| 184 | echo "to commit your changes" |
| 185 | |
| 186 | if [ -n "$localDiff" ]; then |
| 187 | echo |
| 188 | echo "The changes that were locally stored in Perforce are now stored as a git patch in $localDiff" |
| 189 | echo "You may want to appy them with" |
| 190 | echo |
| 191 | echo " git am -3 $localDiff" |
| 192 | echo |
| 193 | fi |