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.

119 lines
3.3 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. gettext-0.10.40, gnome-applets-1.4.0.4
  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. for var in pkg xpkg newver ; do
  57. if [ -z "$( eval echo \$${var} )" ] ; then
  58. echo "ERROR: Please specify package and version in this format:" >&2
  59. echo "ERROR: package-version package=xpackage-version" >&2
  60. echo "ERROR: You entered: $x" >&2
  61. continue 2
  62. fi
  63. done
  64. echo "[ ${pkg}=${xpkg}-${newver} ]" >&2
  65. for dir in package/*/* ; do
  66. if [ "${dir##*/}" == "$pkg" ] ; then
  67. if [ -n "${pkgdir}" ] ; then
  68. echo "ERROR: Package in multiple repositories: $pkg" >&2
  69. echo "ERROR: $( ls -d package/*/${pkg} )" >&2
  70. continue 2
  71. fi
  72. pkgdir="$dir"
  73. continue
  74. fi
  75. done
  76. if [ -n "$pkgdir" ] ; then
  77. unset ${!desc_*} descparser_ign_xpkg
  78. if [ "${pkg}" == "${xpkg}" ] ; then
  79. oldver="`egrep "^\[(V|VER|VERSION)\] " $pkgdir/$pkg.desc |
  80. tr '\t' ' ' | tr -s ' ' | cut -f2 -d' '`"
  81. if [ $( wc -l <<< "${oldver}" ) -gt 1 ] ; then
  82. echo "ERROR: Package ${pkg} is a forked package!" >&2
  83. echo "ERROR: Use $0 package=xpackage-version" >&2
  84. continue
  85. fi
  86. else
  87. parse_desc ${pkgdir}/${pkg}.desc
  88. oldver=${desc_V##*
  89. }
  90. # this is not a typo! desc_V contains all [V] tags newline separated
  91. fi
  92. tmpfile=`mktemp` ; tmpfile2=`mktemp`
  93. [ "$oldver" == "$newver" ] && continue
  94. echo "Upgrade Patch for $pkg ($pkgdir): $oldver -> $newver"
  95. sed -e"s/^\[\(D\|DOWN\|DOWNLOAD\)\] [0-9]\+ \(.*\)$oldver\(.*\)/[\1] 0 \2$newver\3/" \
  96. -e"s/${oldver//./\\.}/$newver/g" -e"s/^\(\[V\] $newver\) .*/\1/" \
  97. < $pkgdir/$pkg.desc > $tmpfile
  98. diff -u ./$pkgdir/$pkg.desc $tmpfile | tee $tmpfile2
  99. [ -s $tmpfile2 ] || echo "Patch for '$x' is empty!" >&2
  100. rm -f $tmpfile $tmpfile2
  101. else
  102. echo "Can't find package for '$x'!" >&2
  103. echo "Can't find package for '$x'!"
  104. fi
  105. echo
  106. done