#!/bin/sh
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: bin/sde-list-pkg
|
|
# Copyright (C) 2007 The OpenSDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
|
# GNU General Public License can be found in the file COPYING.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
[ -n "$SDEROOT" ] ||
|
|
export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
|
|
|
|
. $SDEROOT/lib/libsde.in
|
|
|
|
list_usage() {
|
|
local progname=${0##*/}
|
|
cat <<EOT
|
|
Usage: $progname [--arch <arch>]
|
|
$progname [--cfg <config>] [--extenders] [--repositories] [ITEMS...]
|
|
EOT
|
|
}
|
|
|
|
list_arch() {
|
|
local repo= arch="$1"
|
|
local files=
|
|
|
|
if [ ! -s $SDEROOT/architecture/$arch/archtest.out ]; then
|
|
echo_error "wrong architecture ($arch) specified, aborting."
|
|
return 1
|
|
fi
|
|
|
|
# the .awk file needs complete $SDEROOT relative .desc locations
|
|
cd $SDEROOT
|
|
|
|
for repo in package/*; do
|
|
files=$( ls -1d $repo/*/*.desc 2> /dev/null )
|
|
if [ -n "$files" ]; then
|
|
gawk -f ./lib/sde-package/package-list.awk -v "arch=$arch" $files
|
|
fi
|
|
done | sort -k 3
|
|
}
|
|
|
|
list_desc_extenders() {
|
|
local config="$1"
|
|
local repo= pkg= pattern= pattern2= confdir=
|
|
shift
|
|
|
|
[ $# -gt 0 ] || return
|
|
|
|
if [ $# -eq 1 ]; then
|
|
pattern=$1
|
|
else
|
|
pattern="{$( echo $* | tr ' ' ',' )}"
|
|
fi
|
|
|
|
if [ -z "$config" ]; then
|
|
for repo in $( cd "$SDEROOT/package"; ls -1d * 2> /dev/null ); do
|
|
( cd "$SDEROOT"; eval ls -1d package/$repo/*/pkg_${pattern}_{pre,post}.conf 2> /dev/null | cut -d/ -f-3 | sort -u )
|
|
done | while read confdir; do
|
|
pkg=${confdir##*/}
|
|
echo $confdir/$pkg.desc
|
|
done
|
|
else
|
|
for repo in $( grep '^X' $SDEROOT/config/$config/packages | cut -d' ' -f4 | sort -u ); do
|
|
set -- $( grep "^X [^ ]\+ [^ ]\+ $repo " "$SDEROOT/config/$config/packages" | cut -d' ' -f5 )
|
|
|
|
if [ $# -eq 1 ]; then
|
|
pattern2=$1
|
|
else
|
|
pattern2="{$( echo $* | tr ' ' ',' )}"
|
|
fi
|
|
|
|
( cd "$SDEROOT"; eval ls -1d package/$repo/${pattern2}/pkg_${pattern}_{pre,post}.conf 2> /dev/null | cut -d/ -f-3 | sort -u )
|
|
done | while read confdir; do
|
|
pkg=${confdir##*/}
|
|
echo $confdir/$pkg.desc
|
|
done
|
|
fi
|
|
}
|
|
|
|
list_desc_repo() {
|
|
local repo="$1" pkg= desc=
|
|
|
|
if [ -d "$SDEROOT/package/$repo/" ]; then
|
|
set -- $( cd "$SDEROOT/package/$repo/"; ls -1d * 2> /dev/null )
|
|
|
|
for pkg; do
|
|
desc="package/$repo/$pkg/$pkg.desc"
|
|
|
|
if [ -f "$SDEROOT/$desc" ]; then
|
|
echo "$desc"
|
|
fi
|
|
done
|
|
|
|
if [ -n "$extenders" ]; then
|
|
# get desc of extenders of those packages
|
|
list_desc_extenders '' "$@"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
list_desc() {
|
|
local config="$1" patterns=
|
|
local repo= file= pkg= desc=
|
|
shift;
|
|
|
|
if [ -z "$config" ]; then
|
|
if [ $# -eq 0 ]; then
|
|
# no config, use the whole db
|
|
for repo in $( cd "$SDEROOT/package"; ls -1d * 2> /dev/null ); do
|
|
extenders= list_desc_repo "$repo"
|
|
done
|
|
elif [ -z "$repositories" ]; then
|
|
# no config, but a given set of packages
|
|
for pkg; do
|
|
desc=$( cd "$SDEROOT"; ls -1d package/*/$pkg/$pkg.desc )
|
|
|
|
if [ -f "$SDEROOT/$desc" ]; then
|
|
echo "$desc"
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -n "$extenders" ]; then
|
|
# get desc of extenders of those packages
|
|
list_desc_extenders '' "$@"
|
|
fi
|
|
else
|
|
for repo; do
|
|
list_desc_repo "$repo"
|
|
done
|
|
fi
|
|
elif [ -r "$SDEROOT/config/$config/packages" ]; then
|
|
if [ $# -eq 0 ]; then
|
|
# every active package
|
|
grep '^X' config/xfce/packages | cut -d' ' -f4,5 | while read repo pkg; do
|
|
desc=package/$repo/$pkg/$pkg.desc
|
|
|
|
if [ -f "$SDEROOT/$desc" ]; then
|
|
echo "$desc"
|
|
fi
|
|
done
|
|
elif [ -z "$repositories" ]; then
|
|
if [ $# -eq 1 ]; then
|
|
pattern=$1
|
|
else
|
|
pattern="\\($( echo $* | sed -e "s/ /\\\\|/g" )\\)"
|
|
fi
|
|
|
|
grep "^X [^ ]\+ [^ ]\+ [^ ]\+ $pattern " "$SDEROOT/config/$config/packages" | cut -d' ' -f4,5 | while read repo pkg; do
|
|
desc=package/$repo/$pkg/$pkg.desc
|
|
|
|
if [ -f "$SDEROOT/$desc" ]; then
|
|
echo "$desc"
|
|
fi
|
|
done
|
|
|
|
if [ -n "$extenders" ]; then
|
|
# get desc of extenders of those packages
|
|
list_desc_extenders "$config" "$@"
|
|
fi
|
|
elif [ $# -gt 0 ]; then
|
|
if [ $# -eq 1 ]; then
|
|
pattern=$1
|
|
else
|
|
pattern="\\($( echo $* | sed -e "s/ /\\\\|/g" )\\)"
|
|
fi
|
|
|
|
grep "^X [^ ]\+ [^ ]\+ $pattern " "$SDEROOT/config/$config/packages" | cut -d' ' -f4,5 | while read repo pkg; do
|
|
desc=package/$repo/$pkg/$pkg.desc
|
|
|
|
if [ -f "$SDEROOT/$desc" ]; then
|
|
echo "$desc"
|
|
fi
|
|
done
|
|
|
|
if [ -n "$extenders" ]; then
|
|
# get desc of extenders of those packages
|
|
list_desc_extenders "$config" $( grep "^X [^ ]\+ [^ ]\+ $pattern " "$SDEROOT/config/$config/packages" |
|
|
cut -d' ' -f 5 )
|
|
fi
|
|
fi
|
|
else
|
|
echo_abort -1 "$config: config not found."
|
|
fi
|
|
}
|
|
|
|
arch=
|
|
config=
|
|
mode=desc
|
|
extenders=
|
|
repositories=
|
|
|
|
shortopts='a:c:er'
|
|
longopts='arch:,cfg:,extenders,repositories'
|
|
options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
|
|
if [ $? -ne 0 ]; then
|
|
list_usage
|
|
exit -1
|
|
fi
|
|
|
|
# load new arguments list
|
|
eval set -- "$options"
|
|
|
|
# arguments
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
-a|--arch) mode=arch
|
|
arch="$2"; shift ;;
|
|
-c|--cfg) config="$2"; shift ;;
|
|
|
|
-r|--repositories)
|
|
repositories=yes ;;
|
|
-e|--extenders)
|
|
extenders=yes ;;
|
|
|
|
--) shift; break ;;
|
|
*) echo_abort 1 "Unknown argument '$1', aborting."
|
|
esac
|
|
shift
|
|
done
|
|
|
|
case "$mode" in
|
|
arch) list_arch "$arch" ;;
|
|
desc) list_desc "$config" "$@" ;;
|
|
*) list_usage ;;
|
|
esac
|