
Script for managing jsp-hooks when upgrading
Just a small script to make life easier when upgrading your jsp-hooks. The script in its current version works only on Ubuntu with the diff-tool "meld" preinstalled, but shouldn't be hard to port to windows or osx.
The script needs to have three paths set up correctly as you can see in the code:
- The path to your hooked jsp-files are,
- The path to your current version (unhooked!) of liferay.
- The path to the version that you plan to upgrade to
Then it will happily check if there are any changes between versions in the relevant files (i.e. only the files you have hooked), and open up a meld showing both liferay versions and your hooked version alongside each other for easy diffing and updating.
Run the script in the shell with python <your-script-name> as usual.
Anyway, here is the code, pre-configured for our upgrade from 6EE to 6EE SP1:
#! /usr/bin/env python
# -*- coding: UTF-8 -*-
import os,filecmp
def main():
""" This script is for doing three-way comparisons between your hooked jsp's and two different versions of Liferay.
Typical usage is to check if you need to update your jsp-hooks when upgrading Liferay.
This will open up a new meld-instance on Ubuntu for each jsp that has changes, so that you can update accordingly.
PS! Will only work on Ubuntu with "meld" pre-installed, but can easily be changed to work with other plattforms / tools """
external_diff_tool = "meld"
parameters = ""
hook_path = "../webapp/WEB-INF/jsp"
last_version_path = "/home/kyrrem/Downloads/liferay-portal-6.0-ee/tomcat-6.0.29/webapps/ROOT"
new_version_path = "/home/kyrrem/Downloads/liferay-portal-6.0-ee-sp1/tomcat-6.0.29/webapps/ROOT"
i = 0
for (path, dirs, files) in os.walk(hook_path):
if '.svn' in dirs:
dirs.remove('.svn')
for name in files:
hook_version_filename = path+"/"+name
last_version_filename = last_version_path+path.replace(hook_path, "",1)+"/"+name
new_version_filename = new_version_path+path.replace(hook_path, "",1)+"/"+name
if os.path.isfile(last_version_filename):
if filecmp.cmp(last_version_filename, new_version_filename, False):
print "No changes found in "+name+", skipping..."
else:
print "Changes found in "+name+", opening external diff tool..."
os.system(external_diff_tool+parameters+" "+last_version_filename+" "+new_version_filename+ " "+hook_version_filename)
if __name__ == "__main__":
main()