summaryrefslogtreecommitdiff
path: root/examples/pkglist-sh
blob: aa60fba5e3467eb79a966d6e4dd2d0a3e5d98f10 (plain)
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
#!/bin/sh
## on the PKG_HOST: list available packages
## non-zsh version
## used by ct update remote

if [ -z ${PKG_PATH} -o -z ${PKG_PROTO} ]; then
	echo "PKG_PATH and PKG_PROTO must be set while running ${0}" >&2
	exit 1
fi

if [ ! -d ${PKG_PATH} ]; then
	echo "${0}: package root directory '${PKG_PATH}' does not exist!" >&2
	exit 1
fi

set -e

cd ${PKG_PATH}

for dir in $(find . -type d -mindepth 1 -maxdepth 1  ! -name ".?*"); do
	# git repo
	if [ -d ${dir}/.git ]; then
		echo -n "${dir} git "
		echo -n $(git --git-dir=${dir}/.git log -n 1 | cut -d ' ' -f 2)
		echo " ${PKG_PROTO}://${PKG_UAH}/${PKG_PATH}/${dir}/.git"
	elif [ -d ${dir}/objects -a -d ${dir}/refs ]; then
                # bare git repo
		echo -n "${dir} git "
		echo -n $(git --git-dir=${dir} log -n 1 | cut -d ' ' -f 2)
		echo " ${PKG_PROTO}://${PKG_UAH}/${PKG_PATH}/${dir}"
	else
		# unknown
		echo "${dir}: Unsupported or no repository" >&2
	fi
done