-
Notifications
You must be signed in to change notification settings - Fork 2
/
b2code-package-list
executable file
·64 lines (60 loc) · 1.56 KB
/
b2code-package-list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# check for help option
if [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "-?" ]; then
echo
echo "Usage: `basename $0` [-l] [-s]"
echo
echo "- This command lists the available packages."
echo " If the -l option is used, the responsible librarians"
echo " are printed as well."
echo " If the -s option is used, locally installed packages"
echo " are suppressed."
echo " It has to be called in the local release directory."
echo
exit 0
fi
# read arguments
LIST_LIBRARIANS=no
LIST_LOCAL=yes
while [ $# -gt 0 ]; do
if [ "$1" = "-l" ]; then
LIST_LIBRARIANS=yes
elif [ "$1" = "-s" ]; then
LIST_LOCAL=no
elif [ "$1" = "-ls" -o "$1" = "-sl" ]; then
LIST_LIBRARIANS=yes
LIST_LOCAL=no
else
echo "Error: Invalid argument $1." 1>&2
exit 1
fi
shift
done
# get list of packages
if [ ! -f .release ]; then
echo "Error: Not in a release directory." 1>&2
exit 1
fi
RELEASE=`cat .release`
if [ "${RELEASE}" = "head" ]; then
RELEASE="HEAD"
fi
# loop over packages
PACKAGES=`git ls-tree --name-only ${RELEASE} | grep -v "^\.\|\.rst$\|\.md$\|\.cff$\|^COPYING$"`
PACKAGE_LIST=""
for PACKAGE in ${PACKAGES}; do
if [ -n "${PACKAGE}" ]; then
if [ ${LIST_LOCAL} = no -a -d ${PACKAGE} ]; then
continue
fi
if [ ${LIST_LIBRARIANS} = yes ]; then
LIBRARIANS=`git show ${RELEASE}:${PACKAGE}/.librarians 2> /dev/null | tr "\n" "," | sed "s/,$//"`
echo "${PACKAGE} (${LIBRARIANS})"
else
PACKAGE_LIST="${PACKAGE_LIST} ${PACKAGE}"
fi
fi
done
if [ -n "${PACKAGE_LIST}" ]; then
echo ${PACKAGE_LIST}
fi