OpenSDE Framework (without history before r20070)
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.

148 lines
3.8 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: lib/sde-package/update.in
  5. # Copyright (C) 2006 - 2007 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; version 2 of the License. A copy of the
  12. # GNU General Public License can be found in the file COPYING.
  13. # --- SDE-COPYRIGHT-NOTE-END ---
  14. package_patch_update() {
  15. local descfile="$1" ver="$2" location="$3"
  16. local oldver= sedopt=
  17. local tmpfile=$( mktemp )
  18. oldver=$( sed -n -e 's,^\[V\][ \t]\+\([^ \t]\+\)[ \t]*,\1,p' "$descfile" | head -n 1 )
  19. echo_info "$pkg ($oldver -> $ver)"
  20. awk -f $SDEROOT/lib/sde-package/package-update.awk -v "ver=$ver" -v "location=$location" "$descfile" > $tmpfile
  21. if diff -u $descfile $tmpfile; then
  22. echo_warning "No change detected."
  23. else
  24. cp $tmpfile "$descfile"
  25. fi
  26. rm -f $tmpfile
  27. }
  28. package_do_update() {
  29. local pkg="$1" ver="$2" location="$3"
  30. local confdir=$( ls -1d "$SDEROOT/package/"*"/$pkg" 2> /dev/null )
  31. local descfile="${confdir}/${pkg}.desc"
  32. local oldver=
  33. if [ -z "$confdir" -o ! -f "$descfile" ]; then
  34. echo_error "Package '$pkg' doesn't exist."
  35. return 1
  36. elif [ -z "$ver" ]; then
  37. echo_info "Updating checksum for $pkg."
  38. else
  39. package_patch_update "$descfile" "$ver" "$location"
  40. fi
  41. cd "$SDEROOT"
  42. ./bin/sde-download -q "$pkg" && ./lib/sde-package/patch-cksum.sh "$pkg" | patch -p0
  43. }
  44. package_update_md5() {
  45. local md5="$1" baseurl=
  46. local nolocation= location=
  47. shift
  48. echo_info "Loading MD5 file from '$md5'"
  49. if [ "$1" == "--no-location" ]; then
  50. nolocation=yes; shift
  51. echo_info "(Using individual download locations)"
  52. fi
  53. baseurl="${md5%/*}"
  54. curl "$md5" | while read md5sum file; do
  55. pkg=$( echo "$file" | sed -e 's,-[0-9].*,,' | tr [A-Z] [a-z] )
  56. if [ -z "$pkg" ]; then
  57. echo_error "Failed to detect package name for '$file'."
  58. continue
  59. fi
  60. case "$pkg" in
  61. exo)
  62. pkg=lib${pkg} ;;
  63. gtk-xfce-engine)
  64. pkg=${pkg}2 ;;
  65. libxml2)
  66. pkg=${pkg%2} ;;
  67. terminal)
  68. pkg=xfce4-terminal ;;
  69. mono/gtk-sharp)
  70. pkg=gtk-sharp2 ;;
  71. kde-i18n/*|c++/*|java/*|python/*)
  72. pkg=${pkg#*/}
  73. esac
  74. confdir=$( ls -1d $SDEROOT/package/*/$pkg 2> /dev/null || true )
  75. if [ -z "$confdir" -o ! -f "$confdir/$pkg.desc" ]; then
  76. echo_error "Failed to detect package name for '$file' ($pkg)."
  77. continue
  78. fi
  79. ver=$( echo "$file" | sed -n -e 's,.*-\([0-9].*\)\.tar\.bz2,\1,p' )
  80. if [ -z "$ver" ]; then
  81. echo_error "Failed to detect new version for $pkg ($file)."
  82. continue
  83. fi
  84. if [ -z "$nolocation" ]; then
  85. location="$baseurl/$file";
  86. package_do_update "$pkg" "$ver" "${location%/*}/"
  87. else
  88. package_do_update "$pkg" "$ver"
  89. fi
  90. done
  91. }
  92. package_update() {
  93. local pkg= ver=
  94. local nolocation=
  95. local location=
  96. if [ "$1" == "--no-location" ]; then
  97. nolocation=yes; shift
  98. elif [ "$1" == "--location" ]; then
  99. location="$2"; shift 2
  100. fi
  101. if [ "$1" == "--md5" ]; then
  102. package_update_md5 "$2" ${nolocation:+--no-location}
  103. return $?
  104. elif [ $# -eq 2 ]; then
  105. # package and version
  106. pkg="$( echo "$1" | tr A-Z a-z)"
  107. ver="$2"
  108. elif [ $# -eq 1 ]; then
  109. # package or verion?
  110. pkg="$( echo "$1" | tr A-Z a-z)"
  111. if [ ! -d "$( echo "$SDEROOT/package/"*"/$pkg/" )" ]; then
  112. pkg="$( package_autodetect )"
  113. ver="$1"
  114. fi
  115. elif [ $# -eq 0 ]; then
  116. # can i refresh an autodetected package?
  117. pkg=$( package_autodetect )
  118. else
  119. echo_error "Invalid Syntax."
  120. . $SDEROOT/lib/sde-help.in
  121. help_command package
  122. return 1
  123. fi
  124. if [ -n "$pkg" ]; then
  125. package_do_update "$pkg" "$ver" "${location}"
  126. else
  127. echo_error "I could't guess which package you want to update."
  128. . $SDEROOT/lib/sde-help.in
  129. help_command package
  130. return 2
  131. fi
  132. }