2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: bin/sde-list-pkg
6 # Copyright (C) 2007 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 ---
17 export SDEROOT
=$
( cd "${0%/*}/.."; pwd -P )
19 .
$SDEROOT/lib
/libsde.
in
22 local progname
=${0##*/}
24 Usage: $progname [--arch <arch>]
25 $progname [--cfg <config>] [--extenders] [--repositories] [ITEMS...]
33 if [ ! -s $SDEROOT/architecture
/$arch/archtest.out
]; then
34 echo_error
"wrong architecture ($arch) specified, aborting."
38 # the .awk file needs complete $SDEROOT relative .desc locations
41 for repo
in package
/*; do
42 files
=$
( ls -1d $repo/*/*.desc
2> /dev
/null
)
43 if [ -n "$files" ]; then
44 gawk
-f .
/lib
/sde-package
/package-list.
awk -v "arch=$arch" $files
49 list_desc_extenders
() {
51 local repo
= pkg
= pattern
= pattern2
= confdir
=
54 [ $# -gt 0 ] ||
return
59 pattern
="{$( echo $* | tr ' ' ',' )}"
62 if [ -z "$config" ]; then
63 for repo
in $
( cd "$SDEROOT/package"; ls -1d * 2> /dev
/null
); do
64 ( cd "$SDEROOT"; eval ls -1d package
/$repo/*/pkg_
${pattern}_
{pre
,post
}.conf
2> /dev
/null | cut
-d/ -f-3 |
sort -u )
65 done |
while read confdir
; do
67 echo $confdir/$pkg.desc
70 for repo
in $
( grep '^X' $SDEROOT/config
/$config/packages | cut
-d' ' -f4 |
sort -u ); do
71 set -- $
( grep "^X [^ ]\+ [^ ]\+ $repo " "$SDEROOT/config/$config/packages" | cut
-d' ' -f5 )
76 pattern2
="{$( echo $* | tr ' ' ',' )}"
79 ( cd "$SDEROOT"; eval ls -1d package
/$repo/${pattern2}/pkg_${pattern}_{pre,post}.conf
2> /dev
/null | cut
-d/ -f-3 |
sort -u )
80 done |
while read confdir
; do
82 echo $confdir/$pkg.desc
88 local repo
="$1" pkg
= desc
=
90 if [ -d "$SDEROOT/package/$repo/" ]; then
91 set -- $
( cd "$SDEROOT/package/$repo/"; ls -1d * 2> /dev
/null
)
94 desc
="package/$repo/$pkg/$pkg.desc"
96 if [ -f "$SDEROOT/$desc" ]; then
101 if [ -n "$extenders" ]; then
102 # get desc of extenders of those packages
103 list_desc_extenders
'' "$@"
109 local config
="$1" patterns
=
110 local repo
= file= pkg
= desc
=
113 if [ -z "$config" ]; then
114 if [ $# -eq 0 ]; then
115 # no config, use the whole db
116 for repo
in $
( cd "$SDEROOT/package"; ls -1d * 2> /dev
/null
); do
117 extenders
= list_desc_repo
"$repo"
119 elif [ -z "$repositories" ]; then
120 # no config, but a given set of packages
122 desc
=$
( cd "$SDEROOT"; ls -1d package
/*/$pkg/$pkg.desc
)
124 if [ -f "$SDEROOT/$desc" ]; then
130 if [ -n "$extenders" ]; then
131 # get desc of extenders of those packages
132 list_desc_extenders
'' "$@"
136 list_desc_repo
"$repo"
139 elif [ -r "$SDEROOT/config/$config/packages" ]; then
140 if [ $# -eq 0 ]; then
141 # every active package
142 grep '^X' config
/xfce
/packages | cut
-d' ' -f4,5 |
while read repo pkg
; do
143 desc
=package
/$repo/$pkg/$pkg.desc
145 if [ -f "$SDEROOT/$desc" ]; then
149 elif [ -z "$repositories" ]; then
150 if [ $# -eq 1 ]; then
153 pattern
="\\($( echo $* | sed -e "s
/ /\\\\|
/g
" )\\)"
156 grep "^X [^ ]\+ [^ ]\+ [^ ]\+ $pattern " "$SDEROOT/config/$config/packages" | cut
-d' ' -f4,5 |
while read repo pkg
; do
157 desc
=package
/$repo/$pkg/$pkg.desc
159 if [ -f "$SDEROOT/$desc" ]; then
164 if [ -n "$extenders" ]; then
165 # get desc of extenders of those packages
166 list_desc_extenders
"$config" "$@"
168 elif [ $# -gt 0 ]; then
169 if [ $# -eq 1 ]; then
172 pattern
="\\($( echo $* | sed -e "s
/ /\\\\|
/g
" )\\)"
175 grep "^X [^ ]\+ [^ ]\+ $pattern " "$SDEROOT/config/$config/packages" | cut
-d' ' -f4,5 |
while read repo pkg
; do
176 desc
=package
/$repo/$pkg/$pkg.desc
178 if [ -f "$SDEROOT/$desc" ]; then
183 if [ -n "$extenders" ]; then
184 # get desc of extenders of those packages
185 list_desc_extenders
"$config" $
( grep "^X [^ ]\+ [^ ]\+ $pattern " "$SDEROOT/config/$config/packages" |
190 echo_abort
-1 "$config: config not found."
201 longopts
='arch:,cfg:,extenders,repositories'
202 options
=$
( getopt
-o "$shortopts" -l "$longopts" -- "$@" )
203 if [ $?
-ne 0 ]; then
208 # load new arguments list
209 eval set -- "$options"
212 while [ $# -gt 0 ]; do
216 -c|
--cfg) config
="$2"; shift ;;
224 *) echo_abort
1 "Unknown argument '$1', aborting."
230 arch
) list_arch
"$arch" ;;
231 desc
) list_desc
"$config" "$@" ;;