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.

259 lines
6.8 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. set -x
  47. for arg; do
  48. if curl -I -f "$arg" -o "header.log"; then
  49. location="`grep Location: header.log | sed 's,Location:[ ]\([.0-9A-Za-z-:/% ]*\).*,\1,'`"
  50. download_file="`basename $location`"
  51. download_url="`dirname $location`/"
  52. rm -f header.log
  53. set +x
  54. return
  55. fi
  56. done
  57. set +x
  58. rm -f header.log
  59. }
  60. read_fm_config() {
  61. local fmname=$1
  62. curl_options="" #--disable-epsv
  63. if curl -w '\rFinished downloading %{size_download} bytes in %{time_total} seconds (%{speed_download} bytes/sec). \n' -f --progress-bar $resume $curl_options "http://freshmeat.net/projects-xml/$fmname/$fmname.xml" -o "$fmname.xml"; then
  64. extract_xml_name project $fmname.xml projectname_full
  65. extract_xml_name title $fmname.xml desc_short
  66. extract_xml_name desc $fmname.xml desc_full
  67. extract_xml_name url $fmname.xml url_project_page
  68. extract_xml_name status $fmname.xml branch_name
  69. extract_xml_name license $fmname.xml license
  70. extract_xml_name version $fmname.xml latest_version
  71. extract_xml_name url_tbz $fmname.xml url_bz2
  72. extract_xml_name url_tgz $fmname.xml url_tgz
  73. extract_xml_name url_zip $fmname.xml url_zip
  74. extract_xml_name url_cvs $fmname.xml url_cvs
  75. get_download $url_tbz $url_tgz $url_zip #@FIXME $url_cvs
  76. #cleanup some variables
  77. case "$status" in
  78. Alpha|Beta|Gamma|Stable)
  79. ;;
  80. *)
  81. status="TODO: Unknown ($status)"
  82. ;;
  83. esac
  84. case "$license" in
  85. *GPL*Library*)
  86. license=LGPL
  87. ;;
  88. *GPL*Documentation*)
  89. license=FDL
  90. ;;
  91. *GPL*)
  92. license=GPL
  93. ;;
  94. *Mozilla*Public*)
  95. license=MPL
  96. ;;
  97. *MIT*)
  98. license=MIT
  99. ;;
  100. *BSD*)
  101. license=BSD
  102. ;;
  103. *)
  104. license="TODO: Unknown ($license)"
  105. ;;
  106. esac
  107. rm -f $fmname.xml
  108. else
  109. return 1
  110. fi
  111. }
  112. if [ "$1" == "-main" ] ; then
  113. create_main=1
  114. shift
  115. fi
  116. if [ $# -lt 2 -o $# -gt 2 ] ; then
  117. cat <<-EEE
  118. Usage:
  119. $0 <option> package/repository/packagename freshmeat-package-name
  120. Where <option> may be:
  121. -main Create a package.conf file with main-function
  122. EEE
  123. exit 1
  124. fi
  125. dir=${1#package/} ; shift
  126. package=${dir##*/}
  127. if [ "$package" = "$dir" ]; then
  128. echo "failed"
  129. echo -e "\t$dir must be <rep>/<pkg>!\n"
  130. exit
  131. fi
  132. rep="$( echo package/*/$package | cut -d'/' -f 2 )"
  133. if [ "$rep" != "*" ]; then
  134. echo "failed"
  135. echo -e "\tpackage $package belongs to $rep!\n"
  136. exit
  137. fi
  138. echo -n "Creating package/$dir ... "
  139. if [ -e package/$dir ] ; then
  140. echo "failed"
  141. echo -e "\tpackage/$dir already exists!\n"
  142. exit
  143. fi
  144. if mkdir -p package/$dir ; then
  145. echo "ok"
  146. else
  147. echo "failed"
  148. exit
  149. fi
  150. cd package/$dir
  151. rc="ROCK-COPYRIGHT"
  152. if ! read_fm_config $1; then
  153. echo "Error or wrong freshmeat package name"
  154. exit 1
  155. fi
  156. echo -n "Creating $package.desc ... "
  157. cat >>$package.desc <<EEE
  158. [COPY] --- ${rc}-NOTE-BEGIN ---
  159. [COPY]
  160. [COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  161. [COPY] Please add additional copyright information _after_ the line containing
  162. [COPY] the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  163. [COPY] the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  164. [COPY]
  165. [COPY] ROCK Linux: rock-src/package/$dir/$package.desc
  166. [COPY] ROCK Linux is Copyright (C) 1998 - `date +%Y` Clifford Wolf
  167. [COPY]
  168. [COPY] This program is free software; you can redistribute it and/or modify
  169. [COPY] it under the terms of the GNU General Public License as published by
  170. [COPY] the Free Software Foundation; either version 2 of the License, or
  171. [COPY] (at your option) any later version. A copy of the GNU General Public
  172. [COPY] License can be found at Documentation/COPYING.
  173. [COPY]
  174. [COPY] Many people helped and are helping developing ROCK Linux. Please
  175. [COPY] have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  176. [COPY] file for details.
  177. [COPY]
  178. [COPY] --- ${rc}-NOTE-END ---
  179. [I] $title
  180. [T] $desc
  181. [U] $url
  182. [A] TODO: Author
  183. [M] TODO: Maintainer
  184. [C] TODO: Category
  185. [L] $license
  186. [S] $status
  187. [V] $version
  188. [P] X -----5---9 800.000
  189. [D] 0 $download_file $download_url
  190. EEE
  191. echo "ok"
  192. echo -n "Creating $package.conf ... "
  193. if [ "$create_main" == "1" ] ; then
  194. cat >>$package.conf <<-EEE
  195. # --- ${rc}-NOTE-BEGIN ---
  196. #
  197. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  198. # Please add additional copyright information _after_ the line containing
  199. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  200. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  201. #
  202. # ROCK Linux: rock-src/package/$dir/$package.conf
  203. # ROCK Linux is Copyright (C) 1998 - `date +%Y` Clifford Wolf
  204. #
  205. # This program is free software; you can redistribute it and/or modify
  206. # it under the terms of the GNU General Public License as published by
  207. # the Free Software Foundation; either version 2 of the License, or
  208. # (at your option) any later version. A copy of the GNU General Public
  209. # License can be found at Documentation/COPYING.
  210. #
  211. # Many people helped and are helping developing ROCK Linux. Please
  212. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  213. # file for details.
  214. #
  215. # --- ${rc}-NOTE-END ---
  216. EEE
  217. cat >>$package.conf <<-EEE
  218. ${package}_main() { #TODO
  219. }
  220. custmain="${package}_main"
  221. EEE
  222. fi
  223. echo "ok"
  224. echo "Remember to fill in the TODO's:"
  225. cd -
  226. grep TODO package/$dir/$package.*
  227. echo