summaryrefslogtreecommitdiff
path: root/examples/pkglist
blob: 77cb16f71a53eb4d6b0f857e1688c5f30bd0c0ee (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
#!/usr/bin/env zsh
## on the PKG_HOST: list available packages
## used by ct update remote

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

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

setopt err_exit

cd ${PKG_PATH}

for dir in *(-/); {

	# git repo
	if [[ -d ${dir}/.git ]] {
		echo -n "${dir} git "
		echo -n ${$(git --git-dir=${dir}/.git log -n 1)[2]}
		echo " ${PKG_PROTO}://${PKG_UAH}/${PKG_PATH}/${dir}/.git"

	# bare git repo
	} elif [[ -d ${dir}/objects && -d ${dir}/refs ]] {
		echo -n "${dir} git "
		echo -n ${$(git --git-dir=${dir} log -n 1)[2]}
		echo " ${PKG_PROTO}://${PKG_UAH}/${PKG_PATH}/${dir}"

	# unknown
	} else {
		echo "${dir}: Unsupported or no repository" >&2
	}
}