blob: 46ba6cad5811590a3622fd5bcad5c6d2213be532 (
plain)
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
|
#!/bin/bash
##############################################################################
# parabola-riscv64-bootstrap #
# #
# Copyright (C) 2018 Andreas Grapentin #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
set -euo pipefail
retry() {
for i in $(seq $(expr $1 - 1)); do
"${@:3}" && return 0 || sleep $2;
done
"${@:3}" || return;
}
import_keys() {
local keys="$(source ${1:-PKGBUILD} && echo "${validpgpkeys[@]}")"
if [ -n "$keys" ]; then
local key
for key in $keys; do
echo -n "checking for key $key ... "
sudo -u $SUDO_USER gpg --list-keys $key &>/dev/null && _have_key=yes || _have_key=no
echo $_have_key
if [ "x$_have_key" == "xno" ]; then
retry 5 60 sudo -u $SUDO_USER gpg --recv-keys $key \
|| die "failed to import key $key"
fi
done
fi
}
_fetch_pkgfiles_from() {
curl -sL $url | grep -iq 'not found' && return 1
local src=$(curl -sL $url | grep -i 'source files' | cut -d'"' -f2 | sed 's#/tree/#/plain/#')
for link in $(curl -sL $src | grep '^ <li><a href' | cut -d"'" -f2 \
| sed "s#^#$(echo $src | awk -F/ '{print $3}')#"); do
wget -q $link -O $(basename ${link%\?*});
done
[ -f PKGBUILD ] || return 1
}
fetch_pkgfiles() {
# acquire the pkgbuild and auxiliary files
local url=https://www.parabola.nu/packages/libre/x86_64/$1/
_fetch_pkgfiles_from $url && echo "libre" > .REPO && return
local repo
for repo in core extra community; do
url=https://www.archlinux.org/packages/$repo/x86_64/$1/
_fetch_pkgfiles_from $url && echo "$repo" > .REPO && return
done
die "$1: failed to fetch pkgfiles"
}
prepare_makepkgdir() {
rm -rf "$_makepkgdir"/$_pkgname
mkdir -p "$_makepkgdir"/$_pkgname
pushd "$_makepkgdir"/$_pkgname >/dev/null
chown -R $SUDO_USER "$_makepkgdir"/$_pkgname
}
failed_build() {
_log=$(find "$_logdest" -type f -iname "$1-*" -printf "%T@ %p\n" \
| sort -n | tail -n1 | cut -d' ' -f2-)
set +o pipefail
_phase=""
[ -z "$_log" ] || _phase=$(cat $_log | grep '==>.*occurred in' \
| awk '{print $7}' | sed 's/().*//')
set -o pipefail
if [ -n "${_phase:-}" ]; then
notify -c error "$_pkgname: error in $_phase()" -h string:document:"$_log"
else
notify -c error "$_pkgname: error in makepkg"
fi
[ "x$KEEP_GOING" == "xyes" ] || die "error building $_pkgname"
_build_failed=yes
}
make_realdep() {
local dep
dep="$1"
_realdep=$(pacman --noconfirm -Sddw "$dep" \
| grep '^Packages' | awk '{print $3}')
[ -n "$_realdep" ] && _realdep="${_realdep%-*-*}" && return 0
dep="$(echo "$dep" | sed 's/[<>=].*//')"
_realdep=$(pacman --noconfirm -Sddw "$dep" \
| grep '^Packages' | awk '{print $3}')
[ -n "$_realdep" ] && _realdep="${_realdep%-*-*}" && return 0
return 0
}
|