-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun.sh
executable file
·73 lines (65 loc) · 1.31 KB
/
run.sh
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
#!/bin/bash
usage() {
cat <<-EOF
usage: $(basename "$0") [OPTIONS] [makepkg parameters]
This wrapper for makepkg will default to running with '--force --syncdeps --noconfirm'.
Any unrecognized parameters will be passed directly through to makepkg.
OPTIONS:
-h Display this help
-p Run a pacman -Syu before building
-u UID to own any created package
-g GID to own any created package (Ignored unless UID is also provided)
EOF
}
while getopts ":g:hpu:" OPTION
do
case $OPTION in
g)
group=$OPTARG
;;
h)
usage
exit 0
;;
p)
update=true
;;
u)
user="$OPTARG"
;;
esac
done
shift $(( OPTIND -1 ))
if ! [[ -f /src/PKGBUILD ]]
then
echo "No PKGBUILD file found! Aborting."
exit 1
fi
# cp errors if there is a directory, even though we don't want to copy directories
cp /src/* /build
set -e
chown -R build-user. /build
if [[ -n $update ]]
then
pacman -Syu
else
pacman -Sy
if [[ -n $@ ]]
then
flags=$@
else
flags='--force --syncdeps --noconfirm'
fi
fi
su build-user -s /bin/bash -c "makepkg $flags"
if [[ -n $user ]]
then
chown="$user"
if [[ -n $group ]]
then
chown="${chown}:${group}"
fi
chown -R $chown /build
fi
# Don't fail if there is no pkg but custom flags were specified. i.e. -cors will only test, but not create a package
cp /build/*pkg.tar* /src &>/dev/null || [[ -n $@ ]]