-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspkg-src
executable file
·121 lines (106 loc) · 2.58 KB
/
spkg-src
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
source ./conf
STACK_PKGS=""
FLAG_FORCE=
FLAG_IGNORE=
FLAG_QUIET=
MAKEPKG_OPTS=
COMMAND=$1
shift 1
mkdir -p output
show_err() {
echo $@ 1>&2
exit 2
}
usage() {
echo "Usage: spkg-src COMMAND OPTIONS PACKAGE(s)" 1>&2
echo "Commands:" 1>&2
echo " build Build package from source" 1>&2
echo " build-all Build all packages from source" 1>&2
echo " help Show this message" 1>&2
echo "Options:" 1>&2
echo " -f Forced to build packages" 1>&2
echo " -q Quiet build" 1>&2
echo " -i PACKAGEs Ignore build packages" 1>&2
exit 1
}
while getopts "fqi:" option; do
case $option in
f)
FLAG_FORCE=y
;;
i)
FLAG_IGNORE=$OPTARG
;;
q)
FLAG_QUIET=y
;;
*)
usage
;;
esac
done
shift $(( OPTIND-1 ))
if [[ $FLAG_QUIET == y ]]; then
MAKEPKG_OPTS+=" -q"
fi
if [[ $SKIP_SU_WARNING == y ]]; then
MAKEPKG_OPTS+=" -s"
fi
buildpkg() {
[[ $FLAG_IGNORE == *"$1"* ]] && echo "Ignore $1 package"
[[ ! -f pkgs/$1 ]] && show_err "'$1' package not found"
cd output || exit 1
revision="1"
. ../pkgs/$1 || exit 1
[[ -z "$revision" ]] && revision="1"
if [[ ! -f "$name-${version}_${revision}-`uname -m`.spkg" || ! -z "$FLAG_FORCE" ]]; then
echo "> Start building '$1'..."
makepkg $MAKEPKG_OPTS -i ../pkgs/$1 || exit 1
#else
#echo "> Skipping building '$1'"
fi
cd ..
}
build() {
. pkgs/$1 || exit 1
if [[ "$STACK_PKGS" != *"$1"* ]]; then
for depend in $depends; do
if [[ "$STACK_PKGS" != *"$depend"* ]]; then
build $depend
STACK_PKGS+=" $depend"
else
break
fi
done
buildpkg $1
fi
}
makeinfo() {
cd output || exit 1
spkg-rindex *.spkg || exit
cd ..
echo "Writing repo info done."
}
#if [[ -d $HOME/.cache/spkg-makepkg/ ]]; then
# echo "Clear cache..."
# rm -rf $HOME/.cache/spkg-makepkg/
#fi
case $COMMAND in
build)
[[ -z $@ ]] && show_err "error: nothing to build."
for pkg in $@; do
build $pkg
done
makeinfo
;;
build-all)
for pkg in `ls pkgs`; do
buildpkg $pkg
done
makeinfo
;;
* | help)
usage
;;
esac