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.

282 lines
6.9 KiB

  1. #!/bin/bash
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: lib/sde-package/new-freshmeat.sh
  6. # Copyright (C) 2006 - 2007 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. #
  18. # Written by Benjamin Schieder <blindcoder@scavenger.homeip.net>
  19. #
  20. # Modified by Juergen Sawinski <jsaw@gmx.net> to create
  21. # a package based on freshmeat info.
  22. #
  23. # And Rene Rebe <rene@exactcode.de> to fix I/T sentences to begin with
  24. # capitals as well as no trailing . in the I tag.
  25. #
  26. # newpackage.sh [-main] <rep>/<pkg> <freshmeat package name>
  27. #
  28. extract_xml_name() {
  29. local tmp="`tr -d "\012" < $2 | grep $3 |
  30. sed -e "s|.*<$3>\([^<]*\)<.*|\1|" -e 's| |\n|g'`"
  31. eval "$1=\"\$tmp\""
  32. }
  33. get_download() {
  34. local location
  35. for arg; do
  36. if curl -s -I -f "$arg" -o "header.log"; then
  37. location="`sed -n 's/\r// ; s/Location: *//p' header.log`"
  38. download_file="`basename $location`"
  39. download_url="`dirname $location`/"
  40. rm -f header.log
  41. return
  42. fi
  43. done
  44. rm -f header.log
  45. }
  46. read_fm_config() {
  47. local fmname=$1
  48. curl_options="" #--disable-epsv -#
  49. if curl -s -f $resume $curl_options "http://freshmeat.net/projects-xml/$fmname/$fmname.xml" -o "$fmname.xml"; then
  50. extract_xml_name project $fmname.xml projectname_full
  51. extract_xml_name title $fmname.xml desc_short
  52. extract_xml_name desc $fmname.xml desc_full
  53. extract_xml_name urlh $fmname.xml url_homepage
  54. extract_xml_name license $fmname.xml license
  55. extract_xml_name version $fmname.xml latest_release_version
  56. extract_xml_name url_tbz $fmname.xml url_bz2
  57. extract_xml_name url_tgz $fmname.xml url_tgz
  58. extract_xml_name url_zip $fmname.xml url_zip
  59. extract_xml_name url_cvs $fmname.xml url_cvs
  60. url="$(curl -I $urlh 2>/dev/null | grep "^Location:" | sed -e 's,^Location: \(.*\)$,\1,' | tr -d '\015' )"
  61. get_download $url_tbz $url_tgz $url_zip #@FIXME $url_cvs
  62. # grep trove categories for status IDs
  63. for trove_id in `grep '<trove_id>' $fmname.xml | sed 's,.*<trove_id>\(.*\)</trove_id>,\1,g'` ; do
  64. case $trove_id in
  65. 9) status="Alpha"
  66. ;;
  67. 10) status="Beta"
  68. ;;
  69. 11,12) status="Stable"
  70. ;;
  71. # there is no default
  72. esac
  73. done
  74. # download package fm-page and grep for the author
  75. html="http://freshmeat.net/projects/$fmname/"
  76. curl -I -s "$html" -o "header.log"
  77. html_new="`grep Location: header.log | sed 's,Location:[ ]\([.0-9A-Za-z:/%?_= -]*\).*,\1,'`"
  78. [ ! -z "$html_new" ] && html="$html_new"
  79. unset html_new
  80. rm -f header.log
  81. curl -s "$html" -o "$fmname.html"
  82. dev_name="`grep 'contact developer' "$fmname.html" | sed 's,^[[:blank:]]*\(.*\)[[:blank:]]<a.*$,\1,' | sed 's, *$,,g'`"
  83. dev_mail="`grep 'contact developer' "$fmname.html" | sed 's,^.*<a href=\"mailto:\(.*\)\">.*$,\1,'`"
  84. echo "__at__ @" >subst
  85. echo "__dot__ ." >>subst
  86. echo "|at| @" >>subst
  87. echo "|dot| ." >>subst
  88. echo "\\[at\\] @" >>subst
  89. echo "\\[dot\\] ." >>subst
  90. echo "(at) @" >>subst
  91. echo "(dot) ." >>subst
  92. echo -n "$dev_mail" >dev_mail
  93. # for some strange reason, this doesn't work:
  94. # cat subst | while read from to ; do
  95. # export dev_mail="${dev_mail// $from /$to}"
  96. # done
  97. # dev_mail will have the same value as before
  98. cat subst | while read from to ; do
  99. dev_mail="`cat dev_mail`"
  100. dev_mail="${dev_mail// $from /$to}"
  101. echo -n "$dev_mail" >dev_mail
  102. done
  103. dev_mail="`cat dev_mail`"
  104. rm -f subst $fmname.html dev_mail
  105. if [ -z "$dev_name" ]; then
  106. dev_name="TODO:"
  107. dev_mail="Author"
  108. elif [ -z "$dev_mail" ]; then
  109. dev_name="TODO: $dev_name"
  110. dev_mail="Mail Address"
  111. else
  112. dev_mail="<$dev_mail>"
  113. fi
  114. #cleanup license
  115. case "$license" in
  116. *GPL*Library*)
  117. license=LGPL
  118. ;;
  119. *GPL*Documentation*)
  120. license=FDL
  121. ;;
  122. *GPL*)
  123. license=GPL
  124. ;;
  125. *Mozilla*Public*)
  126. license=MPL
  127. ;;
  128. *MIT*)
  129. license=MIT
  130. ;;
  131. *BSD*)
  132. license=BSD
  133. ;;
  134. *Artistic*)
  135. license=Artistic
  136. ;;
  137. esac
  138. rm -f $fmname.xml
  139. else
  140. return 1
  141. fi
  142. }
  143. if [ "$1" == "-main" ] ; then
  144. create_main=1
  145. shift
  146. fi
  147. if [ $# -lt 2 -o $# -gt 2 ] ; then
  148. cat <<-EEE
  149. Usage:
  150. $0 <option> package/repository/packagename freshmeat-package-name
  151. Where <option> may be:
  152. -main Create a package.conf file with main-function
  153. EEE
  154. exit 1
  155. fi
  156. dir=${1#package/} ; shift
  157. package=${dir##*/}
  158. if [ "$package" = "$dir" ]; then
  159. echo "failed"
  160. echo -e "\t$dir must be <rep>/<pkg>!\n"
  161. exit
  162. fi
  163. rep="$( echo package/*/$package | cut -d'/' -f 2 )"
  164. if [ "$rep" != "*" ]; then
  165. echo "failed"
  166. echo -e "\tpackage $package belongs to $rep!\n"
  167. exit
  168. fi
  169. rep=${dir/\/$package/}
  170. maintainer='The OpenSDE Community <list@opensde.org>'
  171. echo -n "Creating package/$dir ... "
  172. if [ -e package/$dir ] ; then
  173. echo "failed"
  174. echo -e "\tpackage/$dir already exists!\n"
  175. exit
  176. fi
  177. if mkdir -p package/$dir ; then
  178. echo "ok"
  179. else
  180. echo "failed"
  181. exit
  182. fi
  183. cd package/$dir
  184. rc="ROCK-COPYRIGHT"
  185. download_file=
  186. download_url=
  187. if ! read_fm_config $1; then
  188. echo "Error or wrong freshmeat package name"
  189. exit 1
  190. fi
  191. echo -n "Creating $package.desc ... "
  192. note=SDE-COPYRIGHT-NOTE
  193. cat > $package.desc <<EOF
  194. [COPY] --- $note-BEGIN ---
  195. [COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  196. [COPY]
  197. [COPY] Filename: package/.../$package/$package.desc
  198. [COPY] Copyright (C) $( date +%Y ) The OpenSDE Project
  199. [COPY]
  200. [COPY] More information can be found in the files COPYING and README.
  201. [COPY]
  202. [COPY] This program is free software; you can redistribute it and/or modify
  203. [COPY] it under the terms of the GNU General Public License as published by
  204. [COPY] the Free Software Foundation; version 2 of the License. A copy of the
  205. [COPY] GNU General Public License can be found in the file COPYING.
  206. [COPY] --- $note-END ---
  207. EOF
  208. title="`echo "$title" | sed 's/^\(.\)/\U\1/ ; s/\.$//'`"
  209. cat >>$package.desc <<EOF
  210. [I] ${title:-TODO: Title}
  211. EOF
  212. desc="`echo "$desc" | sed '1s/^\(.\)/\U\1/ ; s/\. *\(.\)/. \U\1/g'`"
  213. while read l; do
  214. echo "[T] $l" >>$package.desc
  215. done < <(echo ${desc:-TODO: Description} | fmt --width 75)
  216. cat >>$package.desc <<EOF
  217. [U] ${url:-TODO: URL}
  218. [A] $dev_name $dev_mail
  219. [M] ${maintainer:-TODO: Maintainer}
  220. [C] TODO: Category
  221. [L] ${license:-TODO: License}
  222. [S] ${status:-TODO: Status}
  223. [V] ${version:-TODO: Version}
  224. [P] X -----5---9 800.000
  225. EOF
  226. if [ "$download_file" ]; then
  227. cat >>$package.desc <<-EOF
  228. [D] 0 $download_file $download_url
  229. EOF
  230. fi
  231. echo "ok"
  232. echo -n "Creating $package.conf ... "
  233. if [ "$create_main" == "1" ] ; then
  234. cat >>$package.conf <<-EOF
  235. ${package}_main() {
  236. : TODO
  237. }
  238. custmain="${package}_main"
  239. EOF
  240. fi
  241. echo "ok"
  242. echo "Remember to fill in the TODO's:"
  243. cd -
  244. grep TODO package/$dir/$package.*
  245. echo