forked from archhaskell/habs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeahsrc
executable file
·70 lines (58 loc) · 1.38 KB
/
makeahsrc
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
65
66
67
68
69
70
#! /bin/zsh
set -eu
##################################################
# some useful stuff
ALL_OFF="$(tput sgr0)"
BOLD="$(tput bold)"
BLUE="${BOLD}$(tput setaf 4)"
GREEN="${BOLD}$(tput setaf 2)"
RED="${BOLD}$(tput setaf 1)"
YELLOW="${BOLD}$(tput setaf 3)"
msg() {
local msg=$1; shift
printf "${GREEN}***${ALL_OFF}${BOLD} ${msg}${ALL_OFF}\n" $@ >&2
}
error() {
local msg=$1; shift
printf "${RED}*** ERROR:${ALL_OFF}${BOLD} ${msg}${ALL_OFF}\n" $@ >&2
}
die() {
[ -n "${1}" ] && error ${1}
exit 1
}
##################################################
habs_dir=.
source_arg="--source"
usage() {
cat << EOF
Usage: makeshsrc [options] -- [packages]
Script for building source packages in your HABS dir.
Options:
-h This help
-a Build full source packages
-b <dir> Location of your HABS dir (default .)
EOF
}
buildsrc() {
msg "Building source in $PWD"
makepkg ${source_arg}
}
while getopts hab: opt; do
case "${opt}" in
h) usage; exit 0;;
a) source_arg="--allsource";;
b) habs_dir="${OPTARG}";;
esac
done
shift $((OPTIND - 1))
for pkg0 in $@; do
pkg1=${(L)pkg0}
[ -d ${habs_dir}/${pkg1} ] && pkg=${pkg1}
[ -d ${habs_dir}/haskell-${pkg1} ] && pkg=haskell-${pkg1}
if [[ "x${pkg}" != "x" ]]; then
(cd ${habs_dir}/$pkg; buildsrc )
else
die "No such package: $pkg0"
fi
pkg=
done