-
Notifications
You must be signed in to change notification settings - Fork 7
/
dmakepkg
executable file
·88 lines (74 loc) · 1.77 KB
/
dmakepkg
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
#!/bin/bash
set -e
name="$(basename $0)_$(uuidgen)"
set +e
CACHE=''
MAKEPKG=''
SRCDEST=''
usage() {
cat <<-EOF
usage: $(basename "$0") [option] [makepkg options]
Options:
-x Use host system's /etc/pacman.conf
Any non-listed flag will be automatically passed through to makepkg
with no alterations.
EOF
}
CACHE=''
CONF=''
MAKEPKG=''
while getopts ":hx" OPTION
do
case $OPTION in
h)
usage
echo '---------------------------------------'
docker run --rm --name=$name justin8/makepkg -h
exit 0
;;
x)
[[ -e '/etc/pacman.conf' ]] && CONF='-v /etc/pacman.conf:/etc/pacman.conf'
;;
esac
done
shift $(( OPTIND - 1 ))
# Using -e instead of -d incase it is a symlink
[[ -e '/var/cache/pacman/pkg' ]] && CACHE='-v /var/cache/pacman/pkg:/var/cache/pacman/pkg'
if [[ -f '/etc/makepkg.conf' ]]
then
MAKEPKG='-v /etc/makepkg.conf:/etc/makepkg.conf'
SRCDEST=''
srcdest_path=$(grep '^\s*SRCDEST=' /etc/makepkg.conf | cut -d= -f2)
if [[ -n $srcdest_path ]]; then
SRCDEST="-v ${srcdest_path}:${srcdest_path}"
fi
PKGDEST=''
pkgdest_path=$(grep '^\s*PKGDEST=' /etc/makepkg.conf | cut -d= -f2)
if [[ -n $pkgdest_path ]]; then
PKGDEST="-v ${pkgdest_path}:${pkgdest_path}"
fi
SRCPKGDEST=''
srcpkgdest_path=$(grep '^\s*SRCPKGDEST=' /etc/makepkg.conf | cut -d= -f2)
if [[ -n $srcpkgdest_path ]]; then
SRCPKGDEST="-v ${srcpkgdest_path}:${srcpkgdest_path}"
fi
LOGDEST=''
logdest_path=$(grep '^\s*LOGDEST=' /etc/makepkg.conf | cut -d= -f2)
if [[ -n $logdest_path ]]; then
LOGDEST="-v ${logdest_path}:${logdest_path}"
fi
fi
docker run --name "$name" \
--rm \
--net=host \
-v $(pwd):/src \
$CACHE \
$CONF \
$MAKEPKG \
$SRCDEST \
$PKGDEST \
$SRCPKGDEST \
$LOGDEST \
justin8/makepkg -u "$EUID" -g "$(id -g $EUID)" "$@"
rc=$?
exit $rc