forked from 2m/arch-pkgbuild-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·68 lines (55 loc) · 1.8 KB
/
entrypoint.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
#!/bin/sh -l
DEBUG=$4
if [[ -n $DEBUG && $DEBUG = true ]]; then
set -x
fi
target=$1
pkgname=$2
command=$3
# assumes that package files are in a subdirectory
# of the same name as "pkgname", so this works well
# with "aurpublish" tool
if [[ ! -d $pkgname ]]; then
echo "$pkgname should be a directory."
exit 1
fi
if [[ ! -e $pkgname/PKGBUILD ]]; then
echo "$pkgname does not contain a PKGBUILD file."
exit 1
fi
pkgbuild_dir=$(readlink $pkgname -f) # nicely cleans up path, ie. ///dsq/dqsdsq/my-package//// -> /dsq/dqsdsq/my-package
# '/github/workspace' is mounted as a volume and has owner set to root
# set the owner of $pkgbuild_dir to the 'build' user, so it can access package files.
sudo chown -R build $pkgbuild_dir
# needs permissions so '/github/home/.config/yay' is accessible by yay
sudo chown -R build /github/home
cd $pkgbuild_dir
pkgname="$(basename $pkgbuild_dir)" # keep quotes in case someone passes in a directory path with whitespaces...
install_deps() {
# install make and regular package dependencies
grep -E 'depends|makedepends' PKGBUILD | \
sed -e 's/.*depends=//' -e 's/ /\n/g' | \
tr -d "'" | tr -d "(" | tr -d ")" | \
xargs yay -S --noconfirm
}
case $target in
pkgbuild)
namcap PKGBUILD
install_deps
makepkg --syncdeps --noconfirm
namcap ${pkgname}-*
pacman -Qip ${pkgname}-*
pacman -Qlp ${pkgname}-*
;;
run)
install_deps
makepkg --syncdeps --noconfirm --install
eval "$command"
;;
srcinfo)
makepkg --printsrcinfo | diff .SRCINFO - || \
{ echo ".SRCINFO is out of sync. Please run 'makepkg --printsrcinfo' and commit the changes."; false; }
;;
*)
echo "Target should be one of 'pkgbuild', 'srcinfo', 'run'" ;;
esac