#!/bin/bash ############ funcs function __dru_rm_from_both_core_dirs { echo rm -dr drupal-$site_drv/$1 drupal-$latest_drv/$1 && echo "OK: Done a : rm -dr drupal-$site_drv/$1 drupal-$latest_drv/$1" } function __dru_cp_from_site_dir_to_both_core_dirs { echo for dest in drupal-$site_drv drupal-$latest_drv do for src in "$@" do if [[ -e "$site_dir/$src" ]] # -e checks for both files and dirs then cp -pr "$site_dir/$src" "$dest/" && echo "OK: Done a: cp -pr '$site_dir/$src' '$dest/'" fi done done echo " OK: So, now the current core is ready for diffing and the latest core is almost ready to go live." } ############# Requirements # This script requires that you have drush/link to drush in your $PATH if [[ -z `which drush` ]] then echo "drush not found in PATH! Exiting..."; exit 2 fi ########### determine versions # Drupal version from CHANGELOG.txt of the site we update if [[ -f CHANGELOG.txt ]] then site_drv=`cat CHANGELOG.txt | grep "^Drupal" | sed 's/\,.*$//' | sed 's/Drupal\ //' | head -1` fi site_dir=`pwd` if [[ -z $site_drv ]] # can be empty (-z) either because CHANGELOG.txt missing or corrupt then echo "Unable to get Drupal site version. Maybe you are not in its root dir?. Exiting..."; exit 1; fi echo "OK: Your site's current Drupal core version: |$site_drv|. (determined via CHANGELOG.txt)" latest_drv=`drush info drupal | grep "drupal" | head -1 | awk '{print $2}'` echo "OK: The latest Drupal core version is: |$latest_drv|. (determined via 'drush info drupal')" #exit ############### download orig and new drupal_updates_dir="/tmp/drupal_updates" echo "OK: Removing $drupal_updates_dir - to start fresh there." rm -fdr $drupal_updates_dir && echo "OK: Removed. Creating it again and going there." mkdir $drupal_updates_dir cd $drupal_updates_dir echo " OK: All the time we are working from $drupal_updates_dir. " #pwd # We have 3 dirs in this show - current site, drupal core with the same version and latest drupal core echo " OK: Your site is at : $site_dir OK: Drupal core with the same version is at : ./drupal-$site_drv OK: Drupal core with the LATEST version is at : ./drupal-$latest_drv OK: the working directory (a.k.a. '.') is : `pwd` " #################### if proj=core auto-resolve the sites diff, as well as the backup and cache dirs # remove /sites dir from both dirs drush dl drupal-$latest_drv #|| echo "ERR 33"; exit drush dl drupal-$site_drv #|| echo "Error 34"; exit __dru_rm_from_both_core_dirs sites && echo "OK: removed sites from untouched core versions cause we will put our live site's 'sites' dir there" __dru_cp_from_site_dir_to_both_core_dirs sites backup cache ################## now do an interactive diff reolution - some things deleted, others copied , others left alone = hacks left to reside in the new version ######## the last diff should be NULL = dirs match exactly diff_command="diff -qr $site_dir drupal-$site_drv" diff_output=`$diff_command` echo " diff command: $diff_command diff output: $diff_output "