| 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
<!-- <![CDATA[
|
| 3 |
$Id: site-patch.xml,v 1.8 2007/09/29 06:06:24 allisterbeharry Exp $
|
| 4 |
]]> -->
|
| 5 |
|
| 6 |
<!-- ==================================================================================================== -->
|
| 7 |
<!-- @file This is the base site-patch task in DAST. It downloads and applies a patch to a Drupal site. -->
|
| 8 |
<!-- @author Allister Beharry -->
|
| 9 |
<!-- @package org.drupal.dast.tasks -->
|
| 10 |
<!-- ==================================================================================================== -->
|
| 11 |
|
| 12 |
<project name="site-configure" default="main">
|
| 13 |
<property name="dast.ext.patch" value="${dast.ext}${php.directory_separator}patch" />
|
| 14 |
<taskdef name="warn" classname="phing.tasks.system.WarnTask"/>
|
| 15 |
<taskdef name="DumpProperties" classname="DumpPropertiesTask"/>
|
| 16 |
|
| 17 |
<!-- =================================
|
| 18 |
target: fetch-patch
|
| 19 |
================================= -->
|
| 20 |
|
| 21 |
<target name="fetch-patch" depends="configure" description="--> Fetches the patch file from a Url or local directory">
|
| 22 |
|
| 23 |
<!--Clear any exisitng patch file out from dast.ext.patch-->
|
| 24 |
<available file="${dast.ext.patch}${php.directory_separator}${patch.file}" property="patchFileAlreadyExists"/>
|
| 25 |
<if><isset property="patchFileAlreadyExists"/><then>
|
| 26 |
<echo>Deleting existing patch file at ${dast.ext.patch}${php.directory_separator}${patch.file}</echo>
|
| 27 |
<delete file="${dast.ext.patch}${php.directory_separator}${patch.file}" />
|
| 28 |
</then>
|
| 29 |
</if>
|
| 30 |
|
| 31 |
<if><equals arg1="${patch.method}" arg2="HTTP" /><then> <!--Fetch patch file from URL-->
|
| 32 |
<if><not><isset property="patch.Url"/></not><then>
|
| 33 |
<fail>patch.Url not set, check the properties files file for omissions or bad syntax</fail>
|
| 34 |
</then>
|
| 35 |
</if>
|
| 36 |
<echo>Downloading ${patch.file} from ${patch.Url}...</echo>
|
| 37 |
<exec command="wget "${patch.Url}"" dir="${dast.ext.patch}" checkreturn="true"
|
| 38 |
Output="${build.log.defaultdir}${php.directory_separator}site-patch-fetch-patch-output.log"
|
| 39 |
Error="${build.log.defaultdir}${php.directory_separator}site-patch-fetch-patch-error.log" />
|
| 40 |
</then>
|
| 41 |
</if>
|
| 42 |
|
| 43 |
|
| 44 |
<if><equals arg1="${patch.method}" arg2="file" /> <!--Fetch patch file from local file-->
|
| 45 |
<then>
|
| 46 |
<!--Check the availability of the patch file -->
|
| 47 |
<available file="${patch.file.path}" property="patch.FileExists"/>
|
| 48 |
<if><not><isset property="patch.FileExists"/></not><then>
|
| 49 |
<fail>The file ${patch.file.path} could not be found. Stopping. </fail>
|
| 50 |
</then>
|
| 51 |
</if>
|
| 52 |
<copy file="${patch.file.path}" todir="${dast.ext.patch}" overwrite="true" />
|
| 53 |
</then>
|
| 54 |
</if>
|
| 55 |
</target>
|
| 56 |
|
| 57 |
<!-- =================================
|
| 58 |
target: exec-patch
|
| 59 |
================================= -->
|
| 60 |
<target name="exec-patch" depends="configure" description="--> Patches a Drupal dir">
|
| 61 |
<echo> Applying ${patch.file} patch to ${drupal.dir}...</echo>
|
| 62 |
|
| 63 |
<exec command = "patch -d "${drupal.dir}" -${patch.options} < "${dast.ext.patch}${php.directory_separator}${patch.file}"
|
| 64 |
-b" dir = "${dast.ext.patch}"
|
| 65 |
checkreturn="false" passthru="true"
|
| 66 |
Output="${build.log.defaultdir}${php.directory_separator}site-patch-exec-patch-output.log"
|
| 67 |
Error="${build.log.defaultdir}${php.directory_separator}site-patch-exec-patch-error.log"/>
|
| 68 |
|
| 69 |
<echo>Patching completed, see ${dast.ext.patch} for patch exec output and ${drupal.dir} for .rej and .orij files.</echo>
|
| 70 |
|
| 71 |
</target>
|
| 72 |
|
| 73 |
|
| 74 |
<!-- =================================
|
| 75 |
target: main
|
| 76 |
================================= -->
|
| 77 |
<target name="main" depends="configure" description="--> Runs fetch-patch and exec-patch tasks in that sequence">
|
| 78 |
<phingcall target="fetch-patch" />
|
| 79 |
<phingcall target="exec-patch" />
|
| 80 |
</target>
|
| 81 |
|
| 82 |
<!-- =================================
|
| 83 |
target: configure
|
| 84 |
================================= -->
|
| 85 |
<target name="configure" description="--> Configures the build with properties from properties file.">
|
| 86 |
<if><isset property="basePropertiesFile"/><then>
|
| 87 |
<available file="${project.basedir}${php.directory_separator}${basePropertiesFile}" property="basePropertiesFileExists"/>
|
| 88 |
<if><not><isset property="basePropertiesFileExists"/></not><then>
|
| 89 |
<fail>Could not find the specified base properties file ${project.basedir}${php.directory_separator}${basePropertiesFile}. Stopping.</fail>
|
| 90 |
</then>
|
| 91 |
<else>
|
| 92 |
<property name="build.basePropertiesFile" value="${project.basedir}${php.directory_separator}${basePropertiesFile}" />
|
| 93 |
<echo>Using ${build.basePropertiesFile} as base properties file.</echo>
|
| 94 |
</else>
|
| 95 |
</if>
|
| 96 |
</then>
|
| 97 |
|
| 98 |
<else> <!--Use default base properties file -->
|
| 99 |
<available file="${project.basedir}${php.directory_separator}drupalorg_testing-site-base.properties" property="basePropertiesFileExists"/>
|
| 100 |
<if><not><isset property="basePropertiesFileExists"/></not><then>
|
| 101 |
<warn>Could not find the default base properties file ${project.basedir}${php.directory_separator}drupalorg_testing-site-base.properties. Only the user properties file can be used.</warn>
|
| 102 |
</then>
|
| 103 |
<else>
|
| 104 |
<property name="build.basePropertiesFile" value="${project.basedir}${php.directory_separator}drupalorg_testing-site-base.properties" />
|
| 105 |
<echo>Using default base properties file ${build.basePropertiesFile}.</echo>
|
| 106 |
</else>
|
| 107 |
</if>
|
| 108 |
</else>
|
| 109 |
</if>
|
| 110 |
|
| 111 |
<if><isset property="propertiesFile"/><then>
|
| 112 |
<!--Use user properties from specified file -->
|
| 113 |
<available file="${project.basedir}${php.directory_separator}${propertiesFile}" property="propertiesFileExists"/>
|
| 114 |
<if><not><isset property="propertiesFileExists"/></not><then>
|
| 115 |
<fail>Could not find the specified user properties file ${project.basedir}${php.directory_separator}${propertiesFile}. Stopping.</fail>
|
| 116 |
</then>
|
| 117 |
<else>
|
| 118 |
<property name="build.propertiesFile" value="${project.basedir}${php.directory_separator}${propertiesFile}" />
|
| 119 |
<echo>Using ${build.propertiesFile} as user properties file.</echo>
|
| 120 |
</else>
|
| 121 |
</if>
|
| 122 |
</then>
|
| 123 |
|
| 124 |
<else> <!--Use default user properties file -->
|
| 125 |
<available file="${project.basedir}${php.directory_separator}drupalorg_testing-site.properties" property="propertiesFileExists"/>
|
| 126 |
<if><not><isset property="propertiesFileExists"/></not><then>
|
| 127 |
<warn>Could not find the default user properties file ${project.basedir}${php.directory_separator}drupalorg_testing-site.properties. Only the base properties file will be used.</warn>
|
| 128 |
</then>
|
| 129 |
<else>
|
| 130 |
<property name="build.propertiesFile" value="${project.basedir}${php.directory_separator}drupalorg_testing-site.properties" />
|
| 131 |
<echo>Using ${build.propertiesFile} as default user properties file.</echo>
|
| 132 |
</else>
|
| 133 |
</if>
|
| 134 |
</else>
|
| 135 |
</if>
|
| 136 |
|
| 137 |
|
| 138 |
<if><and><not><isset property="build.basePropertiesFile" /></not><not><isset property="build.propertiesFile" /></not></and><then>
|
| 139 |
<fail>Cannot use either the user or base properties files. Stopping </fail>
|
| 140 |
</then>
|
| 141 |
</if>
|
| 142 |
|
| 143 |
<if><isset property="build.basePropertiesFile" /><then>
|
| 144 |
<property file="${build.basePropertiesFile}" override="true"/>
|
| 145 |
</then>
|
| 146 |
<else><echo>No base properties file used.</echo></else>
|
| 147 |
</if>
|
| 148 |
|
| 149 |
<if><isset property="build.propertiesFile" /><then>
|
| 150 |
<if><equals arg1="${build.propertiesFile}" arg2="${dast.home}${php.directory_separator}drupalorg_testing-site.properties" /><then>
|
| 151 |
<if><and><isset property="build.basePropertiesFile" /><not><equals arg1="${build.basePropertiesFile}" arg2="${dast.home}${php.directory_separator}drupalorg_testing-site-base.properties" /></not></and><then>
|
| 152 |
<echo>The base properties file ${build.basePropertiesFile} is not the default so the default user properties file will not be loaded.</echo>
|
| 153 |
</then>
|
| 154 |
<else>
|
| 155 |
<property file="${build.propertiesFile}" override="true"/>
|
| 156 |
<echo>Using default user properties file ${dast.home}${php.directory_separator}drupalorg_testing-site.properties.</echo>
|
| 157 |
</else>
|
| 158 |
</if>
|
| 159 |
</then>
|
| 160 |
<else><property file="${build.propertiesFile}" override="true"/></else>
|
| 161 |
</if>
|
| 162 |
</then>
|
| 163 |
<else><echo>No user properties file used.</echo></else>
|
| 164 |
</if>
|
| 165 |
|
| 166 |
<if>
|
| 167 |
<not><isset property="patch.method"/></not>
|
| 168 |
<then>
|
| 169 |
<fail>patch.method property not set, check the properties files for omissions or bad syntax</fail>
|
| 170 |
</then>
|
| 171 |
</if>
|
| 172 |
|
| 173 |
<if>
|
| 174 |
<not><isset property="patch.file"/></not>
|
| 175 |
<then>
|
| 176 |
<fail>patch.file property not set, check the properties files for omissions or bad syntax</fail>
|
| 177 |
</then>
|
| 178 |
</if>
|
| 179 |
|
| 180 |
<if>
|
| 181 |
<not><isset property="patch.options"/></not>
|
| 182 |
<then>
|
| 183 |
<fail>patch.options property not set, check the properties files for omissions or bad syntax</fail>
|
| 184 |
</then>
|
| 185 |
</if>
|
| 186 |
|
| 187 |
|
| 188 |
<if>
|
| 189 |
<not><isset property="drupal.dir"/></not>
|
| 190 |
<then>
|
| 191 |
<fail>drupal.dir property not set, check the properties files for omissions or bad syntax</fail>
|
| 192 |
</then>
|
| 193 |
</if>
|
| 194 |
</target>
|
| 195 |
|
| 196 |
<!-- =================================
|
| 197 |
target: dump-config
|
| 198 |
================================= -->
|
| 199 |
<target name="dump-config" depends="configure" description="--> Prints out all the values of the properties that are currently configuring the build">
|
| 200 |
<!--<echo> dast.ext.patch: ${dast.ext.patch}</echo>
|
| 201 |
<echo> build.testing: ${build.testing}</echo>
|
| 202 |
<echo> build.basePropertiesFile: ${build.basePropertiesFile}</echo>
|
| 203 |
<echo> build.propertiesFile: ${build.propertiesFile}</echo>
|
| 204 |
<echo> build.log.defaultdir: ${build.log.defaultdir}</echo>
|
| 205 |
<echo> patch.method: ${patch.method}</echo>
|
| 206 |
<echo> patch.file: ${patch.file}</echo>
|
| 207 |
<echo> patch.options: ${patch.options}</echo>
|
| 208 |
<echo> patch.Url: ${patch.Url}</echo>
|
| 209 |
<echo> patch.file.path: ${patch.file.path}</echo>
|
| 210 |
<echo> drupal.dir: ${drupal.dir}</echo>-->
|
| 211 |
<DumpProperties />
|
| 212 |
</target>
|
| 213 |
</project>
|