1
#!/bin/sh -e
2
3
if [ $# -lt 2 ]; then
4
    echo "Usage: $0 oldversion newversion (optional) directory (e.g. 5.5 5.6 dir)"
5
    exit 1
6
fi
7
8
# If you change TMP, you will have to change the -p3 option in the patch command!
9
TMP=/tmp
10
# Change the version below to what you have
11
VER_OLD=$1
12
VER_NEW=$2
13
14
if [ $# -gt 2 ]; then
15
  DRUPAL_DIR=$3
16
else
17
  DRUPAL_DIR=`pwd`
18
fi
19
20
# Change that to the directory where Drupal is installed
21
PATCH_FILE=$TMP/drupal-$VER_OLD-to-$VER_NEW.patch
22
cd $TMP
23
24
# Download your current version
25
wget http://ftp.drupal.org/files/projects/drupal-$VER_OLD.tar.gz
26
27
# Extract it
28
tar -xzf drupal-$VER_OLD.tar.gz
29
30
# Now, download the new version
31
wget http://ftp.drupal.org/files/projects/drupal-$VER_NEW.tar.gz
32
# And extract that too
33
tar -xzf drupal-$VER_NEW.tar.gz
34
35
# Now create the diff file
36
# echo "This command, or the next one, breaks the script so you'll just have to do the rest yourself."
37
echo `diff -Naur $TMP/drupal-$VER_OLD $TMP/drupal-$VER_NEW > $PATCH_FILE`
38
39
# Now change to the directory where your Drupal installation is
40
cd $DRUPAL_DIR
41
42
# we'll want to see the output for this
43
set -vx
44
45
# Check that the patch would apply without errors
46
patch -p3 --dry-run < $PATCH_FILE
47
48
# turn off verbose output
49
set +vx
50
# turning it back off (naturally, on is a minus sign and off is a plus sign)
51
52
echo "If the above dry run patch applied without errors, you can press Y to apply the patch for real."
53
echo "If there are errors, or you just aren't ready to apply the patch, press N to abort."
54
read YN
55
if ( test -z "$YN" )
56
then
57
  echo -e "Please enter either \"Y\" or \"N\" " ;
58
  eval "$0" "$@" ;
59
  exit ;
60
fi
61
# at this point 'YN' contains Y, y, N, or n
62
if ( test "$YN" = "N" -o "$YN" = "n" )
63
then
64
  exit ;
65
fi
66
67
set -vx
68
# Assuming there are no error from the previous step, you can
69
# now apply the patch for real
70
patch -p3 < $PATCH_FILE