You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

patch.xml 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <!--
  17. =======================================================================
  18. Use Apache Ant to generate a patch file.
  19. =======================================================================
  20. -->
  21. <project name="create-patch" default="patchpackage" basedir=".">
  22. <property environment="env"/>
  23. <property name="patch.package" value="patch.tar.gz"/>
  24. <property name="patch.file" value="patch.txt"/>
  25. <condition property="svn.found">
  26. <or>
  27. <available file="svn" filepath="${env.PATH}"/>
  28. <available file="svn.exe" filepath="${env.PATH}"/>
  29. <available file="svn.exe" filepath="${env.Path}"/>
  30. </or>
  31. </condition>
  32. <target name="createpatch">
  33. <fail unless="svn.found" message="You need a version of svn to create the patch"/>
  34. <exec executable="svn" output="${patch.file}">
  35. <arg value="diff"/>
  36. </exec>
  37. </target>
  38. <target name="newfiles">
  39. <exec executable="svn" output="${patch.file}.tmp">
  40. <arg value="status"/>
  41. </exec>
  42. <!-- prepare the list of files to include in patch.tar.gz -->
  43. <loadfile srcfile="${patch.file}.tmp" property="tar.file.list">
  44. <filterchain>
  45. <!-- capture any new files -->
  46. <linecontainsregexp>
  47. <regexp pattern="^(\?|A)......"/>
  48. </linecontainsregexp>
  49. <!-- filter out the first six characters -->
  50. <tokenfilter>
  51. <replaceregex pattern="^(.......)" replace=""/>
  52. </tokenfilter>
  53. <!--remove line breaks -->
  54. <striplinebreaks/>
  55. </filterchain>
  56. </loadfile>
  57. </target>
  58. <target name="patchpackage" depends="createpatch,newfiles">
  59. <delete file="${patch.package}"/>
  60. <tar includes="${tar.file.list}"
  61. destfile="${patch.package}"
  62. basedir="."
  63. compression="gzip" >
  64. </tar>
  65. <delete file="${patch.file}.tmp"/>
  66. </target>
  67. <target name="apply"
  68. description="apply patch.tar.gz files generated by patchpackage">
  69. <!--
  70. extract patch.tar.gz to svn working copy
  71. $ tar xvzf patch.tar.gz
  72. -->
  73. <echo message="extracting ${patch.file} to working copy"/>
  74. <untar src="${patch.package}"
  75. dest="."
  76. failOnEmptyArchive="true"
  77. compression="gzip">
  78. </untar>
  79. <!--
  80. Apply the changes from patch.txt
  81. $ svn patch patch.txt
  82. -->
  83. <echo message="svn patch ${patch.file}"/>
  84. <fail unless="svn.found" message="You need a version of svn to create the patch"/>
  85. <exec executable="svn">
  86. <arg value="patch"/>
  87. <arg value="${patch.file}"/>
  88. </exec>
  89. <delete file="${patch.file}"/>
  90. <!--
  91. get a list of all new files in patch.tar.gz and store in tar.file.list filelist
  92. $ tar tf patch.tar.gz | grep -v patch\.txt | xargs svn add
  93. -->
  94. <echo message="Getting ${patch.file} file list"/>
  95. <delete dir="${patch.package}.tmp" quiet="false" failonerror="false" />
  96. <untar src="${patch.package}"
  97. dest="${patch.package}.tmp"
  98. failOnEmptyArchive="true"
  99. compression="gzip">
  100. </untar>
  101. <fileset dir="${patch.package}.tmp"
  102. id="tar.file.list"
  103. excludes="${patch.file}"/>
  104. <!-- add new files -->
  105. <echo message="Adding new files to svn working copy"/>
  106. <apply executable="svn"
  107. relative="true">
  108. <arg value="add"/>
  109. <fileset refid="tar.file.list"/>
  110. </apply>
  111. <delete dir="${patch.package}.tmp"/>
  112. </target>
  113. </project>