2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: bin/sde-create-package
6 # Copyright (C) 2008 The OpenSDE Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- SDE-COPYRIGHT-NOTE-END ---
16 #Description: Creates a new package
20 export SDEROOT
=$
( cd "${0%/*}/.."; pwd -P )
22 .
"$SDEROOT/lib/libsde.in"
23 .
"$SDEROOT/lib/sde-package.in"
24 .
"$SDEROOT/lib/sde-package/hives.in"
27 local progname
=${0##*/} hive
=
29 Usage: ${progname//-/ } [--hive <hive>[:<index>]] [<repository>/][<package>] [hive arguments]
31 Available Hives (--hivelist):
33 for hive
in $
( package_hives_list
); do
34 desc
=$
( package_hive_desc
"$hive" )
35 aliases
=$
( package_hive_aliases
"$hive" )
36 if [ "$hive" = 'download' ]; then
42 printf "%15s %s%s\n" "$hive" "${desc:-...}" "${aliases:+ (Alias: ${aliases// /,})}${default:+ (default)}"
47 longopts
='help,hive:,hivelist'
48 options
=$
( getopt
-o "$shortopts" -l "$longopts" -- "$@" )
54 # load new arguments list
55 eval set -- "$options"
61 while [ $# -gt 0 ]; do
75 *) echo_abort
1 "$1: Unknown argument, aborting."
80 # just list know hives
82 if [ -n "$hivelist" ]; then
83 for x
in $
( package_hives_list
); do
89 # validate the choosen hive
91 if [ -n "$hive" ]; then
92 # split hive and hiveindex
93 if expr "$hive" : ".*:.*" > /dev
/null
; then
94 hiveindex
="${hive#*:}"
98 # translate into the real name of the hive, in the case the alias was gives
99 x
=$
( package_hive_alias
"$hive" )
101 echo_abort
1 "$hive: Invalid hive."
106 # assume download hive of none is given
113 if [ -z "$pkg" ]; then
114 echo_error
"no package name given."
117 elif expr "$pkg" : ".*/.*" > /dev
/null
; then
122 # sanitize $repo if needed
123 if [ "$repo" = "." ]; then
124 # detect repo based on $PWD
125 repo
=$
( package_autodetect_repo
)
126 elif expr "$repo" : ".*/.*" > /dev
/null
; then
128 if [ -d "$repo" ]; then
129 # exists, go there and find out
130 repo
=$
( cd "$repo"; package_autodetect_repo
)
134 if [ -d "${repo%/*}" ]; then
135 repo
=$
( cd "$repo"; package_autodetect_repo
)
137 echo_error
"${repo#$PWD/}: Invalid repository"
143 # detect repo based on $PWD
144 repo
=$
( package_autodetect_repo
)
146 # base use wip/ if the detection failed
151 confdir
=$
( package_confdir
"$pkg" )
152 [ -z "$confdir" ] || echo_abort
2 "$pkg: package already exists (${confdir#$SDEROOT/})."
154 echo_info
"Creating package/$repo/$pkg from $hive:${hiveindex:-$pkg}"
156 # get info form the hive
157 output
=$
( "$SDEROOT/lib/sde-package/hives/$hive" "${hiveindex:-$pkg}" "$@" )
158 [ -n "$output" ] || echo_abort
1 "$hive failed to fetch ${hiveindex:-$pkg} information"
160 # do we have content for the $1 tag?
163 echo "$output" |
grep -q "^\[$1\]"
166 # what do we know for the $1 tag?
169 echo "$output" |
grep "^\[$1\]" |
sed -e 's,^\[[^]]\+\][ \t]*,,' -e 's,[ \t]*\$,,'
172 # checks if output has $1, and return $2 if not
175 if output_has_tag
"$1"; then
182 # parse the output of the hive
186 title
=$
( output_parse I
'TODO: Short Information' )
188 desc
=$
( output_parse T
'TODO: Long Expanation
189 TODO: Long Expanation
190 TODO: Long Expanation
191 TODO: Long Expanation
192 TODO: Long Expanation' )
194 url
=$
( output_parse U
'TODO: URL' )
196 author
=$
( output_parse A
'TODO: Author' )
198 category
=$
( output_parse C
'TODO: Category' )
200 license
=$
( output_parse L
'TODO: License' )
202 status
=$
( output_parse S
'TODO: Status' )
204 version
=$
( output_parse V
'TODO: Version' )
206 download
=$
( output_parse D
'' )
209 mkdir
-p "$SDEROOT/package/$repo/$pkg"
211 # create $confdir/$pkg.desc
212 TAG
=SDE-COPYRIGHT-NOTE
215 [COPY] --- $TAG-BEGIN ---
216 [COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch.
218 [COPY] Filename: package/.../$pkg/$pkg.desc
219 [COPY] Copyright (C) $( date +%Y ) The OpenSDE Project
221 [COPY] More information can be found in the files COPYING and README.
223 [COPY] This program is free software; you can redistribute it and/or modify
224 [COPY] it under the terms of the GNU General Public License as published by
225 [COPY] the Free Software Foundation; version 2 of the License. A copy of the
226 [COPY] GNU General Public License can be found in the file COPYING.
227 [COPY] --- $TAG-END ---
231 $( echo "$desc" | sed -e 's,^,[T] ,' )
236 [M] The OpenSDE Community <list@opensde.org>
243 [P] X -----5---9 800.000
246 echo "$download" |
while read l
; do
247 "$SDEROOT/lib/sde-package/url2d.sh" "$l"
249 ) |
tee "$SDEROOT/package/$repo/$pkg/$pkg.desc"