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.

262 lines
6.9 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. rep=${dir/\/$package/}
  139. maintainer="$( grep -h -m 1 "\[M\]" package/$rep/*/*.desc | head -n 1 | cut -d' ' -f2- )"
  140. echo -n "Creating package/$dir ... "
  141. if [ -e package/$dir ] ; then
  142. echo "failed"
  143. echo -e "\tpackage/$dir already exists!\n"
  144. exit
  145. fi
  146. if mkdir -p package/$dir ; then
  147. echo "ok"
  148. else
  149. echo "failed"
  150. exit
  151. fi
  152. cd package/$dir
  153. rc="ROCK-COPYRIGHT"
  154. if ! read_fm_config $1; then
  155. echo "Error or wrong freshmeat package name"
  156. exit 1
  157. fi
  158. echo -n "Creating $package.desc ... "
  159. cat >>$package.desc <<EEE
  160. [COPY] --- ${rc}-NOTE-BEGIN ---
  161. [COPY]
  162. [COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  163. [COPY] Please add additional copyright information _after_ the line containing
  164. [COPY] the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  165. [COPY] the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  166. [COPY]
  167. [COPY] ROCK Linux: rock-src/package/$dir/$package.desc
  168. [COPY] ROCK Linux is Copyright (C) 1998 - `date +%Y` Clifford Wolf
  169. [COPY]
  170. [COPY] This program is free software; you can redistribute it and/or modify
  171. [COPY] it under the terms of the GNU General Public License as published by
  172. [COPY] the Free Software Foundation; either version 2 of the License, or
  173. [COPY] (at your option) any later version. A copy of the GNU General Public
  174. [COPY] License can be found at Documentation/COPYING.
  175. [COPY]
  176. [COPY] Many people helped and are helping developing ROCK Linux. Please
  177. [COPY] have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  178. [COPY] file for details.
  179. [COPY]
  180. [COPY] --- ${rc}-NOTE-END ---
  181. [I] $title
  182. [T] $desc
  183. [U] $url
  184. [A] TODO: Author
  185. [M] ${maintainer:-TODO: Maintainer}
  186. [C] TODO: Category
  187. [L] $license
  188. [S] $status
  189. [V] $version
  190. [P] X -----5---9 800.000
  191. [D] 0 $download_file $download_url
  192. EEE
  193. echo "ok"
  194. echo -n "Creating $package.conf ... "
  195. if [ "$create_main" == "1" ] ; then
  196. cat >>$package.conf <<-EEE
  197. # --- ${rc}-NOTE-BEGIN ---
  198. #
  199. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  200. # Please add additional copyright information _after_ the line containing
  201. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  202. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  203. #
  204. # ROCK Linux: rock-src/package/$dir/$package.conf
  205. # ROCK Linux is Copyright (C) 1998 - `date +%Y` Clifford Wolf
  206. #
  207. # This program is free software; you can redistribute it and/or modify
  208. # it under the terms of the GNU General Public License as published by
  209. # the Free Software Foundation; either version 2 of the License, or
  210. # (at your option) any later version. A copy of the GNU General Public
  211. # License can be found at Documentation/COPYING.
  212. #
  213. # Many people helped and are helping developing ROCK Linux. Please
  214. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  215. # file for details.
  216. #
  217. # --- ${rc}-NOTE-END ---
  218. EEE
  219. cat >>$package.conf <<-EEE
  220. ${package}_main() { #TODO
  221. }
  222. custmain="${package}_main"
  223. EEE
  224. fi
  225. echo "ok"
  226. echo "Remember to fill in the TODO's:"
  227. cd -
  228. grep TODO package/$dir/$package.*
  229. echo