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.

171 lines
4.5 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. #Description: Create based on freshmeat.net information
  18. #Alias: fm
  19. extract_xml_name() {
  20. local tmp="`tr -d "\012" < $2 | grep $3 |
  21. sed -e "s|.*<$3>\([^<]*\)<.*|\1|" -e 's| |\n|g'`"
  22. eval "$1=\"\$tmp\""
  23. }
  24. get_download() {
  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. rm -f header.log
  29. return
  30. fi
  31. done
  32. rm -f header.log
  33. }
  34. read_fm_config() {
  35. local fmname=$1
  36. curl_options= #--disable-epsv -#
  37. if curl -s -f $resume $curl_options "http://freshmeat.net/projects-xml/$fmname/$fmname.xml" -o "$fmname.xml"; then
  38. extract_xml_name project $fmname.xml projectname_full
  39. extract_xml_name title $fmname.xml desc_short
  40. extract_xml_name desc $fmname.xml desc_full
  41. extract_xml_name urlh $fmname.xml url_homepage
  42. extract_xml_name license $fmname.xml license
  43. extract_xml_name version $fmname.xml latest_release_version
  44. extract_xml_name url_tbz $fmname.xml url_bz2
  45. extract_xml_name url_tgz $fmname.xml url_tgz
  46. extract_xml_name url_zip $fmname.xml url_zip
  47. extract_xml_name url_cvs $fmname.xml url_cvs
  48. url="$(curl -I $urlh 2>/dev/null | grep "^Location:" | sed -e 's,^Location: \(.*\)$,\1,' | tr -d '\015' )"
  49. get_download $url_tbz $url_tgz $url_zip #@FIXME $url_cvs
  50. # grep trove categories for status IDs
  51. for trove_id in `grep '<trove_id>' $fmname.xml | sed 's,.*<trove_id>\(.*\)</trove_id>,\1,g'` ; do
  52. case $trove_id in
  53. 9) status="Alpha"
  54. ;;
  55. 10) status="Beta"
  56. ;;
  57. 11,12) status="Stable"
  58. ;;
  59. # there is no default
  60. esac
  61. done
  62. # download package fm-page and grep for the author
  63. html="http://freshmeat.net/projects/$fmname/"
  64. curl -I -s "$html" -o "header.log"
  65. html_new="`grep Location: header.log | sed 's,Location:[ ]\([.0-9A-Za-z:/%?_= -]*\).*,\1,'`"
  66. [ ! -z "$html_new" ] && html="$html_new"
  67. unset html_new
  68. rm -f header.log
  69. curl -s "$html" -o "$fmname.html"
  70. dev_name="`grep 'contact developer' "$fmname.html" | sed 's,^[[:blank:]]*\(.*\)[[:blank:]]<a.*$,\1,' | sed 's, *$,,g'`"
  71. dev_mail="`grep 'contact developer' "$fmname.html" | sed 's,^.*<a href=\"mailto:\(.*\)\">.*$,\1,'`"
  72. echo "__at__ @" >subst
  73. echo "__dot__ ." >>subst
  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 -n "$dev_mail" >dev_mail
  81. # for some strange reason, this doesn't work:
  82. # cat subst | while read from to ; do
  83. # export dev_mail="${dev_mail// $from /$to}"
  84. # done
  85. # dev_mail will have the same value as before
  86. cat subst | while read from to ; do
  87. dev_mail="`cat dev_mail`"
  88. dev_mail="${dev_mail// $from /$to}"
  89. echo -n "$dev_mail" >dev_mail
  90. done
  91. dev_mail="`cat dev_mail`"
  92. rm -f subst $fmname.html dev_mail
  93. if [ -z "$dev_name" ]; then
  94. dev_mail=
  95. elif [ -z "$dev_mail" ]; then
  96. dev_mail="TODO: Mail Address"
  97. else
  98. dev_mail="<$dev_mail>"
  99. fi
  100. #cleanup license
  101. case "$license" in
  102. *GPL*Library*)
  103. license=LGPL
  104. ;;
  105. *GPL*Documentation*)
  106. license=FDL
  107. ;;
  108. *GPL*)
  109. license=GPL
  110. ;;
  111. *Mozilla*Public*)
  112. license=MPL
  113. ;;
  114. *MIT*)
  115. license=MIT
  116. ;;
  117. *BSD*)
  118. license=BSD
  119. ;;
  120. *Artistic*)
  121. license=Artistic
  122. ;;
  123. esac
  124. rm -f $fmname.xml
  125. else
  126. return 1
  127. fi
  128. }
  129. if [ $# -ne 1 ]; then
  130. echo "Usage: $0 <name>" >&2
  131. exit 1
  132. elif ! read_fm_config "$1"; then
  133. echo "$1: not found in freshmeat" >&2
  134. exit 1
  135. fi
  136. # [I]
  137. title="`echo "$title" | sed 's/^\(.\)/\U\1/ ; s/\.$//'`"
  138. [ -z "$title" ] || echo "[I] $title"
  139. # [T]
  140. desc="`echo "$desc" | sed '1s/^\(.\)/\U\1/ ; s/\. *\(.\)/. \U\1/g'`"
  141. if [ -n "$desc" ]; then
  142. echo "$desc" | fmt --width 75 | sed -e 's,^,[T] ,'
  143. fi
  144. # [U]
  145. [ -z "$url" ] || echo "[U] $url"
  146. # [A]
  147. [ -z "$dev_name$dev_mail" ] || echo "[A] $dev_name $dev_mail"
  148. # [L]
  149. [ -z "$license" ] || echo "[L] $license"
  150. # [S]
  151. [ -z "$status" ] || echo "[S] $status"
  152. # [V]
  153. [ -z "$version" ] || echo "[V] $version"
  154. # [D]
  155. [ -z "$location" ] || echo "[D] $location"