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.

173 lines
4.6 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: lib/sde-package/.../freshmeat
  6. # Copyright (C) 2006 - 2008 The OpenSDE Project
  7. # Copyright (C) 2004 - 2006 The T2 SDE Project
  8. # Copyright (C) 1998 - 2003 Clifford Wolf
  9. #
  10. # More information can be found in the files COPYING and README.
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; version 2 of the License. A copy of the
  15. # GNU General Public License can be found in the file COPYING.
  16. # --- SDE-COPYRIGHT-NOTE-END ---
  17. #Alias: fm
  18. extract_xml_name() {
  19. local tmp="`tr -d "\012" < $2 | grep $3 |
  20. sed -e "s|.*<$3>\([^<]*\)<.*|\1|" -e 's| |\n|g'`"
  21. eval "$1=\"\$tmp\""
  22. }
  23. get_download() {
  24. local location
  25. for arg; do
  26. if curl -s -I -f "$arg" -o "header.log"; then
  27. location="`sed -n 's/\r// ; s/Location: *//p' header.log`"
  28. download_file="`basename $location`"
  29. download_url="`dirname $location`/"
  30. rm -f header.log
  31. return
  32. fi
  33. done
  34. rm -f header.log
  35. }
  36. read_fm_config() {
  37. local fmname=$1
  38. curl_options= #--disable-epsv -#
  39. if curl -s -f $resume $curl_options "http://freshmeat.net/projects-xml/$fmname/$fmname.xml" -o "$fmname.xml"; then
  40. extract_xml_name project $fmname.xml projectname_full
  41. extract_xml_name title $fmname.xml desc_short
  42. extract_xml_name desc $fmname.xml desc_full
  43. extract_xml_name urlh $fmname.xml url_homepage
  44. extract_xml_name license $fmname.xml license
  45. extract_xml_name version $fmname.xml latest_release_version
  46. extract_xml_name url_tbz $fmname.xml url_bz2
  47. extract_xml_name url_tgz $fmname.xml url_tgz
  48. extract_xml_name url_zip $fmname.xml url_zip
  49. extract_xml_name url_cvs $fmname.xml url_cvs
  50. url="$(curl -I $urlh 2>/dev/null | grep "^Location:" | sed -e 's,^Location: \(.*\)$,\1,' | tr -d '\015' )"
  51. get_download $url_tbz $url_tgz $url_zip #@FIXME $url_cvs
  52. # grep trove categories for status IDs
  53. for trove_id in `grep '<trove_id>' $fmname.xml | sed 's,.*<trove_id>\(.*\)</trove_id>,\1,g'` ; do
  54. case $trove_id in
  55. 9) status="Alpha"
  56. ;;
  57. 10) status="Beta"
  58. ;;
  59. 11,12) status="Stable"
  60. ;;
  61. # there is no default
  62. esac
  63. done
  64. # download package fm-page and grep for the author
  65. html="http://freshmeat.net/projects/$fmname/"
  66. curl -I -s "$html" -o "header.log"
  67. html_new="`grep Location: header.log | sed 's,Location:[ ]\([.0-9A-Za-z:/%?_= -]*\).*,\1,'`"
  68. [ ! -z "$html_new" ] && html="$html_new"
  69. unset html_new
  70. rm -f header.log
  71. curl -s "$html" -o "$fmname.html"
  72. dev_name="`grep 'contact developer' "$fmname.html" | sed 's,^[[:blank:]]*\(.*\)[[:blank:]]<a.*$,\1,' | sed 's, *$,,g'`"
  73. dev_mail="`grep 'contact developer' "$fmname.html" | sed 's,^.*<a href=\"mailto:\(.*\)\">.*$,\1,'`"
  74. echo "__at__ @" >subst
  75. echo "__dot__ ." >>subst
  76. echo "|at| @" >>subst
  77. echo "|dot| ." >>subst
  78. echo "\\[at\\] @" >>subst
  79. echo "\\[dot\\] ." >>subst
  80. echo "(at) @" >>subst
  81. echo "(dot) ." >>subst
  82. echo -n "$dev_mail" >dev_mail
  83. # for some strange reason, this doesn't work:
  84. # cat subst | while read from to ; do
  85. # export dev_mail="${dev_mail// $from /$to}"
  86. # done
  87. # dev_mail will have the same value as before
  88. cat subst | while read from to ; do
  89. dev_mail="`cat dev_mail`"
  90. dev_mail="${dev_mail// $from /$to}"
  91. echo -n "$dev_mail" >dev_mail
  92. done
  93. dev_mail="`cat dev_mail`"
  94. rm -f subst $fmname.html dev_mail
  95. if [ -z "$dev_name" ]; then
  96. dev_mail=
  97. elif [ -z "$dev_mail" ]; then
  98. dev_mail="TODO: Mail Address"
  99. else
  100. dev_mail="<$dev_mail>"
  101. fi
  102. #cleanup license
  103. case "$license" in
  104. *GPL*Library*)
  105. license=LGPL
  106. ;;
  107. *GPL*Documentation*)
  108. license=FDL
  109. ;;
  110. *GPL*)
  111. license=GPL
  112. ;;
  113. *Mozilla*Public*)
  114. license=MPL
  115. ;;
  116. *MIT*)
  117. license=MIT
  118. ;;
  119. *BSD*)
  120. license=BSD
  121. ;;
  122. *Artistic*)
  123. license=Artistic
  124. ;;
  125. esac
  126. rm -f $fmname.xml
  127. else
  128. return 1
  129. fi
  130. }
  131. if [ $# -ne 1 ]; then
  132. echo "Usage: $0 <name>" >&2
  133. exit 1
  134. elif ! read_fm_config "$1"; then
  135. echo "$1: not found in freshmeat" >&2
  136. exit 1
  137. fi
  138. # [I]
  139. title="`echo "$title" | sed 's/^\(.\)/\U\1/ ; s/\.$//'`"
  140. [ -z "$title" ] || echo "[I] $title"
  141. # [T]
  142. desc="`echo "$desc" | sed '1s/^\(.\)/\U\1/ ; s/\. *\(.\)/. \U\1/g'`"
  143. if [ -n "$desc" ]; then
  144. echo "$desc" | fmt --width 75 | sed -e 's,^,[T] ,'
  145. fi
  146. # [U]
  147. [ -z "$url" ] || echo "[U] $url"
  148. # [A]
  149. [ -z "$dev_name$dev_mail" ] || echo "[A] $dev_name $dev_mail"
  150. # [L]
  151. [ -z "$license" ] || echo "[L] $license"
  152. # [S]
  153. [ -z "$status" ] || echo "[S] $status"
  154. # [V]
  155. [ -z "$version" ] || echo "[S] $version"
  156. # [D]
  157. [ -z "$download_file" ] || echo "[D] 0 $download_file $download_url"