mirror of the now-defunct rocklinux.org
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.

298 lines
8.2 KiB

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