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.

185 lines
5.1 KiB

  1. #!/bin/bash
  2. #
  3. # Written by Benjamin Schieder <blindcoder@scavenger.homeip.net>
  4. #
  5. # Use:
  6. # newpackage.sh [-main] <rep>/<pkg> http://www.example.com/down/pkg.tar.bz2
  7. #
  8. # will create <pkg>.desc and <pkg>.conf. .desc will contain the [D] and [COPY]
  9. # already filled in. The other tags are mentioned with TODO.
  10. #
  11. # .conf will contain an empty <pkg>_main() { } and custmain="<pkg>_main"
  12. # if -main is specified.
  13. #
  14. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  15. #
  16. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  17. # Please add additional copyright information _after_ the line containing
  18. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  19. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  20. #
  21. # ROCK Linux: rock-src/misc/archive/newpackage.sh
  22. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  23. #
  24. # This program is free software; you can redistribute it and/or modify
  25. # it under the terms of the GNU General Public License as published by
  26. # the Free Software Foundation; either version 2 of the License, or
  27. # (at your option) any later version. A copy of the GNU General Public
  28. # License can be found at Documentation/COPYING.
  29. #
  30. # Many people helped and are helping developing ROCK Linux. Please
  31. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  32. # file for details.
  33. #
  34. # --- ROCK-COPYRIGHT-NOTE-END ---
  35. #
  36. if [ "$1" == "-main" ] ; then
  37. create_main=1
  38. shift
  39. fi
  40. if [ $# -lt 2 ] ; then
  41. cat <<-EEE
  42. Usage:
  43. $0 <option> package/repository/packagename Download_1 < Download_2, Download_n >
  44. Where <option> may be:
  45. -main Create a package.conf file with main-function
  46. EEE
  47. exit 1
  48. fi
  49. dir=${1#package/} ; shift
  50. package=${dir##*/}
  51. if [ "$package" = "$dir" ]; then
  52. echo "failed"
  53. echo -e "\t$dir must be <rep>/<pkg>!\n"
  54. exit
  55. fi
  56. rep="$( echo package/*/$package | cut -d'/' -f 2 )"
  57. if [ "$rep" != "*" ]; then
  58. echo "failed"
  59. echo -e "\tpackage $package belongs to $rep!\n"
  60. exit
  61. fi
  62. rep=${dir/\/$package/}
  63. maintainer="$( grep -h -m 1 "\[M\]" package/$rep/*/*.desc | head -n 1 | cut -d' ' -f2- )"
  64. echo -n "Creating package/$dir ... "
  65. if [ -e package/$dir ] ; then
  66. echo "failed"
  67. echo -e "\tpackage/$dir already exists!\n"
  68. exit
  69. fi
  70. if mkdir -p package/$dir ; then
  71. echo "ok"
  72. else
  73. echo "failed"
  74. exit
  75. fi
  76. cd package/$dir
  77. rc="ROCK-COPYRIGHT"
  78. echo -n "Creating $package.desc ... "
  79. cat >>$package.desc <<EEE
  80. [COPY] --- ${rc}-NOTE-BEGIN ---
  81. [COPY]
  82. [COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  83. [COPY] Please add additional copyright information _after_ the line containing
  84. [COPY] the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  85. [COPY] the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  86. [COPY]
  87. [COPY] ROCK Linux: rock-src/package/$dir/$package.desc
  88. [COPY] ROCK Linux is Copyright (C) 1998 - `date +%Y` Clifford Wolf
  89. [COPY]
  90. [COPY] This program is free software; you can redistribute it and/or modify
  91. [COPY] it under the terms of the GNU General Public License as published by
  92. [COPY] the Free Software Foundation; either version 2 of the License, or
  93. [COPY] (at your option) any later version. A copy of the GNU General Public
  94. [COPY] License can be found at Documentation/COPYING.
  95. [COPY]
  96. [COPY] Many people helped and are helping developing ROCK Linux. Please
  97. [COPY] have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  98. [COPY] file for details.
  99. [COPY]
  100. [COPY] --- ${rc}-NOTE-END ---
  101. [I] TODO: Short Information
  102. [T] TODO: Long Expanation
  103. [T] TODO: Long Expanation
  104. [T] TODO: Long Expanation
  105. [T] TODO: Long Expanation
  106. [T] TODO: Long Expanation
  107. [U] TODO: URL
  108. [A] TODO: Author
  109. [M] ${maintainer:-TODO: Maintainer}
  110. [C] TODO: Category
  111. [L] TODO: License
  112. [S] TODO: Status
  113. [V] TODO: Version
  114. [P] X -----5---9 800.000
  115. EEE
  116. while [ "$1" ]; do
  117. dl=$1; shift
  118. file=`echo $dl | sed 's,^.*/,,g'`
  119. server=${dl%$file}
  120. echo [D] 0 $file $server >> $package.desc
  121. done
  122. echo >> $package.desc
  123. echo "ok"
  124. echo -n "Creating $package.conf ... "
  125. if [ "$create_main" == "1" ] ; then
  126. cat >>$package.conf <<-EEE
  127. # --- ${rc}-NOTE-BEGIN ---
  128. #
  129. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  130. # Please add additional copyright information _after_ the line containing
  131. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  132. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  133. #
  134. # ROCK Linux: rock-src/package/$dir/$package.conf
  135. # ROCK Linux is Copyright (C) 1998 - `date +%Y` Clifford Wolf
  136. #
  137. # This program is free software; you can redistribute it and/or modify
  138. # it under the terms of the GNU General Public License as published by
  139. # the Free Software Foundation; either version 2 of the License, or
  140. # (at your option) any later version. A copy of the GNU General Public
  141. # License can be found at Documentation/COPYING.
  142. #
  143. # Many people helped and are helping developing ROCK Linux. Please
  144. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  145. # file for details.
  146. #
  147. # --- ${rc}-NOTE-END ---
  148. EEE
  149. cat >>$package.conf <<-EEE
  150. ${package}_main() { #TODO
  151. }
  152. custmain="${package}_main"
  153. EEE
  154. fi
  155. echo "ok"
  156. echo "Remember to fill in the TODO's:"
  157. cd -
  158. grep TODO package/$dir/$package.*
  159. echo