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.

144 lines
3.7 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_arror "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. kde-i18n/*)
  66. pkg=${pkg#*/} ;;
  67. terminal)
  68. pkg=xfce4-terminal ;;
  69. esac
  70. confdir=$( ls -1d $SDEROOT/package/*/$pkg 2> /dev/null || true )
  71. if [ -z "$confdir" -o ! -f "$confdir/$pkg.desc" ]; then
  72. echo_error "Failed to detect package name for '$file' ($pkg)."
  73. continue
  74. fi
  75. ver=$( echo "$file" | sed -n -e 's,.*-\([0-9].*\)\.tar\.bz2,\1,p' )
  76. if [ -z "$ver" ]; then
  77. echo_error "Failed to detect new version for $pkg ($file)."
  78. continue
  79. fi
  80. if [ -z "$nolocation" ]; then
  81. location="$baseurl/$file";
  82. package_do_update "$pkg" "$ver" "${location%/*}/"
  83. else
  84. package_do_update "$pkg" "$ver"
  85. fi
  86. done
  87. }
  88. package_update() {
  89. local pkg= ver=
  90. local nolocation=
  91. local location=
  92. if [ "$1" == "--no-location" ]; then
  93. nolocation=yes; shift
  94. elif [ "$1" == "--location" ]; then
  95. location="$2"; shift 2
  96. fi
  97. if [ "$1" == "--md5" ]; then
  98. package_update_md5 "$2" ${nolocation:+--no-location}
  99. return $?
  100. elif [ $# -eq 2 ]; then
  101. # package and version
  102. pkg="$( echo "$1" | tr A-Z a-z)"
  103. ver="$2"
  104. elif [ $# -eq 1 ]; then
  105. # package or verion?
  106. pkg="$( echo "$1" | tr A-Z a-z)"
  107. if [ ! -d "$( echo "$SDEROOT/package/"*"/$pkg/" )" ]; then
  108. pkg="$( package_autodetect )"
  109. ver="$1"
  110. fi
  111. elif [ $# -eq 0 ]; then
  112. # can i refresh an autodetected package?
  113. pkg=$( package_autodetect )
  114. else
  115. echo_error "Invalid Syntax."
  116. . $SDEROOT/lib/sde-help.in
  117. help_command package
  118. return 1
  119. fi
  120. if [ -n "$pkg" ]; then
  121. package_do_update "$pkg" "$ver" "${location}"
  122. else
  123. echo_error "I could't guess which package you want to update."
  124. . $SDEROOT/lib/sde-help.in
  125. help_command package
  126. return 2
  127. fi
  128. }