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.

299 lines
8.3 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 urlh $fmname.xml url_homepage
  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. url="$(curl -I $urlh 2>/dev/null | grep "^Location:" | sed -e 's,^Location: \(.*\)$,\1,' | tr -d '\015' )"
  72. get_download $url_tbz $url_tgz $url_zip #@FIXME $url_cvs
  73. # grep trove categories for status IDs
  74. for trove_id in `grep '<trove_id>' $fmname.xml | sed 's,.*<trove_id>\(.*\)</trove_id>,\1,g'` ; do
  75. case $trove_id in
  76. 9) status="Alpha"
  77. ;;
  78. 10) status="Beta"
  79. ;;
  80. 11,12) status="Stable"
  81. ;;
  82. # there is no default
  83. esac
  84. done
  85. # download package fm-page and grep for the author
  86. html="http://freshmeat.net/projects/$fmname/"
  87. curl -I -s "$html" -o "header.log"
  88. html_new="`grep Location: header.log | sed 's,Location:[ ]\([.0-9A-Za-z-:/%?_= ]*\).*,\1,'`"
  89. [ ! -z html_new ] && html="$html_new"
  90. unset html_new
  91. rm -f header.log
  92. curl -s "$html" -o "$fmname.html"
  93. dev_name="`grep 'contact developer' "$fmname.html" | sed 's,^[[:blank:]]*\(.*\)[[:blank:]]<a.*$,\1,' | sed 's, *$,,g'`"
  94. dev_mail="<`grep 'contact developer' "$fmname.html" | sed 's,^.*<a href=\"mailto:\(.*\)\">.*$,\1,'`>"
  95. echo "__at__ @" >subst
  96. echo "__dot__ ." >>subst
  97. echo "|at| @" >>subst
  98. echo "|dot| ." >>subst
  99. echo "\\[at\\] @" >>subst
  100. echo "\\[dot\\] ." >>subst
  101. echo "(at) @" >>subst
  102. echo "(dot) ." >>subst
  103. echo -n "$dev_mail" >dev_mail
  104. # for some strange reason, this doesn't work:
  105. # cat subst | while read from to ; do
  106. # export dev_mail="${dev_mail// $from /$to}"
  107. # done
  108. # dev_mail will have the same value as before
  109. cat subst | while read from to ; do
  110. dev_mail="`cat dev_mail`"
  111. dev_mail="${dev_mail// $from /$to}"
  112. echo -n "$dev_mail" >dev_mail
  113. done
  114. dev_mail="`cat dev_mail`"
  115. rm -f subst $fmname.html dev_mail
  116. if [ -z "$dev_mail" -o -z "$dev_name" ] ; then
  117. dev_name="TODO: "
  118. dev_mail="Author"
  119. fi
  120. #cleanup license
  121. case "$license" in
  122. *GPL*Library*)
  123. license=LGPL
  124. ;;
  125. *GPL*Documentation*)
  126. license=FDL
  127. ;;
  128. *GPL*)
  129. license=GPL
  130. ;;
  131. *Mozilla*Public*)
  132. license=MPL
  133. ;;
  134. *MIT*)
  135. license=MIT
  136. ;;
  137. *BSD*)
  138. license=BSD
  139. ;;
  140. esac
  141. rm -f $fmname.xml
  142. else
  143. return 1
  144. fi
  145. }
  146. if [ "$1" == "-main" ] ; then
  147. create_main=1
  148. shift
  149. fi
  150. if [ $# -lt 2 -o $# -gt 2 ] ; then
  151. cat <<-EEE
  152. Usage:
  153. $0 <option> package/repository/packagename freshmeat-package-name
  154. Where <option> may be:
  155. -main Create a package.conf file with main-function
  156. EEE
  157. exit 1
  158. fi
  159. dir=${1#package/} ; shift
  160. package=${dir##*/}
  161. if [ "$package" = "$dir" ]; then
  162. echo "failed"
  163. echo -e "\t$dir must be <rep>/<pkg>!\n"
  164. exit
  165. fi
  166. rep="$( echo package/*/$package | cut -d'/' -f 2 )"
  167. if [ "$rep" != "*" ]; then
  168. echo "failed"
  169. echo -e "\tpackage $package belongs to $rep!\n"
  170. exit
  171. fi
  172. rep=${dir/\/$package/}
  173. maintainer="$( grep -h -m 1 "\[M\]" package/$rep/*/*.desc | head -n 1 | cut -d' ' -f2- )"
  174. echo -n "Creating package/$dir ... "
  175. if [ -e package/$dir ] ; then
  176. echo "failed"
  177. echo -e "\tpackage/$dir already exists!\n"
  178. exit
  179. fi
  180. if mkdir -p package/$dir ; then
  181. echo "ok"
  182. else
  183. echo "failed"
  184. exit
  185. fi
  186. cd package/$dir
  187. rc="ROCK-COPYRIGHT"
  188. if ! read_fm_config $1; then
  189. echo "Error or wrong freshmeat package name"
  190. exit 1
  191. fi
  192. echo -n "Creating $package.desc ... "
  193. cat >>$package.desc <<EEE
  194. [COPY] --- ${rc}-NOTE-BEGIN ---
  195. [COPY]
  196. [COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  197. [COPY] Please add additional copyright information _after_ the line containing
  198. [COPY] the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  199. [COPY] the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  200. [COPY]
  201. [COPY] ROCK Linux: rock-src/package/$dir/$package.desc
  202. [COPY] ROCK Linux is Copyright (C) 1998 - `date +%Y` Clifford Wolf
  203. [COPY]
  204. [COPY] This program is free software; you can redistribute it and/or modify
  205. [COPY] it under the terms of the GNU General Public License as published by
  206. [COPY] the Free Software Foundation; either version 2 of the License, or
  207. [COPY] (at your option) any later version. A copy of the GNU General Public
  208. [COPY] License can be found at Documentation/COPYING.
  209. [COPY]
  210. [COPY] Many people helped and are helping developing ROCK Linux. Please
  211. [COPY] have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  212. [COPY] file for details.
  213. [COPY]
  214. [COPY] --- ${rc}-NOTE-END ---
  215. [I] ${title:-TODO: Title}
  216. [T] ${desc:-TODO: Description}
  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. [D] 0 $download_file $download_url
  226. EEE
  227. echo "ok"
  228. echo -n "Creating $package.conf ... "
  229. if [ "$create_main" == "1" ] ; then
  230. cat >>$package.conf <<-EEE
  231. # --- ${rc}-NOTE-BEGIN ---
  232. #
  233. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  234. # Please add additional copyright information _after_ the line containing
  235. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  236. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  237. #
  238. # ROCK Linux: rock-src/package/$dir/$package.conf
  239. # ROCK Linux is Copyright (C) 1998 - `date +%Y` Clifford Wolf
  240. #
  241. # This program is free software; you can redistribute it and/or modify
  242. # it under the terms of the GNU General Public License as published by
  243. # the Free Software Foundation; either version 2 of the License, or
  244. # (at your option) any later version. A copy of the GNU General Public
  245. # License can be found at Documentation/COPYING.
  246. #
  247. # Many people helped and are helping developing ROCK Linux. Please
  248. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  249. # file for details.
  250. #
  251. # --- ${rc}-NOTE-END ---
  252. EEE
  253. cat >>$package.conf <<-EEE
  254. ${package}_main() { #TODO
  255. }
  256. custmain="${package}_main"
  257. EEE
  258. fi
  259. echo "ok"
  260. echo "Remember to fill in the TODO's:"
  261. cd -
  262. grep TODO package/$dir/$package.*
  263. echo