mirror of the now-defunct rocklinux.org
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.

124 lines
3.4 KiB

  1. #!/bin/bash
  2. #
  3. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  4. #
  5. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. # Please add additional copyright information _after_ the line containing
  7. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  8. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  9. #
  10. # ROCK Linux: rock-src/scripts/Create-PkgUpdPatch
  11. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  12. #
  13. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License as published by
  15. # the Free Software Foundation; either version 2 of the License, or
  16. # (at your option) any later version. A copy of the GNU General Public
  17. # License can be found at Documentation/COPYING.
  18. #
  19. # Many people helped and are helping developing ROCK Linux. Please
  20. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  21. # file for details.
  22. #
  23. # --- ROCK-COPYRIGHT-NOTE-END ---
  24. if [ "$1" != "${1#-}" ] ; then
  25. cat << EOT >&2
  26. $0:
  27. Automatically create package-update patches.
  28. Input format (e.g.): automake~1.5, bind~9.2.0rc3, binutils~2.11.90.0.31,
  29. gnome-applets~1.4.0.4, linux=linux26~2.6.26.5
  30. Output format: unified diff for the .desc files
  31. Type ./scripts/Help Create-PkgUpdPatch for details."
  32. EOT
  33. exit 1
  34. fi
  35. if [ "$*" ] ; then
  36. echo "$*" | exec $0
  37. exit $?
  38. fi
  39. base=.
  40. . scripts/functions
  41. tr ', \t' '\n\n\n' |
  42. tr -s '\n' |
  43. while read x ; do
  44. pkg="" ; pkgdir=""
  45. [ -z "$x" ] && continue
  46. if [ "${x//=/}" != "${x}" ] ; then
  47. pkg="${x%%=*}"
  48. xpkg="${x#*=}"
  49. newver="${xpkg#*~}"
  50. xpkg="${xpkg%~*}"
  51. else
  52. pkg="${x%%~*}"
  53. xpkg="${pkg}"
  54. newver="${x#*~}"
  55. fi
  56. if [ "$newver" == "$pkg" ]; then
  57. newver=""
  58. fi
  59. for var in pkg xpkg newver ; do
  60. if [ -z "$( eval echo \$${var} )" ] ; then
  61. echo "ERROR: Please specify package and version in this format:" >&2
  62. echo "ERROR: package~version package=xpackage~version" >&2
  63. echo "ERROR: You entered: $x" >&2
  64. continue 2
  65. fi
  66. done
  67. echo "[ ${pkg}=${xpkg}~${newver} ]" >&2
  68. for dir in package/*/* ; do
  69. if [ "${dir##*/}" == "$pkg" ] ; then
  70. if [ -n "${pkgdir}" ] ; then
  71. echo "ERROR: Package in multiple repositories: $pkg" >&2
  72. echo "ERROR: $( ls -d package/*/${pkg} )" >&2
  73. continue 2
  74. fi
  75. pkgdir="$dir"
  76. continue
  77. fi
  78. done
  79. if [ -n "$pkgdir" ] ; then
  80. unset ${!desc_*} descparser_ign_xpkg
  81. if [ "${pkg}" == "${xpkg}" ] ; then
  82. oldver="`egrep "^\[(V|VER|VERSION)\] " $pkgdir/$pkg.desc |
  83. tr '\t' ' ' | tr -s ' ' | cut -f2 -d' '`"
  84. if [ $( wc -l <<< "${oldver}" ) -gt 1 ] ; then
  85. echo "ERROR: Package ${pkg} is a forked package!" >&2
  86. echo "ERROR: Use $0 package=xpackage-version" >&2
  87. continue
  88. fi
  89. else
  90. parse_desc ${pkgdir}/${pkg}.desc
  91. oldver=${desc_V##*
  92. }
  93. # this is not a typo! desc_V contains all [V] tags newline separated
  94. fi
  95. tmpfile=`mktemp` ; tmpfile2=`mktemp`
  96. [ "$oldver" == "$newver" ] && continue
  97. echo "Upgrade Patch for $pkg ($pkgdir): $oldver -> $newver"
  98. sed -e"s/^\[\(D\|DOWN\|DOWNLOAD\)\] [0-9]\+ \(.*\)$oldver\(.*\)/[\1] 0 \2__newver__\3/" \
  99. -e"s/${oldver//./\\.}/__newver__/g" -e"s/^\(\[V\] __newver__\) .*/\1/" \
  100. < $pkgdir/$pkg.desc > $tmpfile
  101. sed -i -e"s,__newver__,$newver,g" $tmpfile
  102. diff -u ./$pkgdir/$pkg.desc $tmpfile | tee $tmpfile2
  103. [ -s $tmpfile2 ] || echo "Patch for '$x' is empty!" >&2
  104. rm -f $tmpfile $tmpfile2
  105. else
  106. echo "Can't find package for '$x'!" >&2
  107. echo "Can't find package for '$x'!"
  108. fi
  109. echo
  110. done