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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
#!/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/>. #
##############################################################################
package_build() {
local pkgname="$3"
deptree_is_satisfyable "$pkgname" || return 0
msg "makepkg: $pkgname"
msg " remaining packages: $(wc -l < "$DEPTREE")"
prepare_makepkgdir "$MAKEPKGDIR/$pkgname" || return
local res=0
"$1" "$pkgname" 2>&1 | tee .MAKEPKGLOG
res="${PIPESTATUS[0]}"
popd >/dev/null || return
if [ "$res" -ne 0 ]; then
notify -c error "${pkgname//_/\\_}" -h string:document:"$MAKEPKGDIR/$pkgname/.MAKEPKGLOG"
if [ -f "$TOPBUILDDIR/.KEEP_GOING" ]; then
sed -i "s/^$pkgname : \\[/& FIXME/" "$DEPTREE"
else
return "$res"
fi
fi
deptree_is_satisfyable "$pkgname" || return 0
"$2" "$pkgname" || return
deptree_remove "$pkgname"
local full curr
full=$(wc -l < "$DEPTREE".FULL)
curr=$((full - $(wc -l < "$DEPTREE")))
notify -c success -u low "*$curr/$full* ${pkgname//_/\\_}"
}
packages_build_all() {
while [ -s "$DEPTREE" ]; do
local pkgname pkgarch
pkgname=$(deptree_next) \
|| { error -n "could not resolve dependencies"; return "$ERROR_MISSING"; }
package_build "$1" "$2" "$pkgname" || return
done
}
package_reuse_upstream() {
local dep
for dep in $(pkgdeps "$1"); do
deptree_check_depend "$1" "$dep" || return
done
deptree_is_satisfyable "$1" || return 0
check_pkgfile "$PKGPOOL" "$1" && return
local pkgarch
pkgarch=$(pkgarch "$1")
case "$pkgarch" in
any)
pacman -Sddw --noconfirm --cachedir "$PKGDEST" "$1" || return
;;
*)
pacman -Sddw --noconfirm --cachedir . "$1" || return
local pkgdir="$MAKEPKGDIR/$1/pkg/$1"
local pkgfiles pkgfile
pkgfiles=( "$1"-*.pkg.tar.xz ); pkgfile="${pkgfiles[0]}"
mkdir -p "$pkgdir"
bsdtar -C "$pkgdir" -xf "$pkgfile" || return
rm "$pkgdir"/.{MTREE,BUILDINFO}
sed -i "s/arch = .*/arch = $CARCH/" "$pkgdir"/.PKGINFO
pushd "$pkgdir" >/dev/null || return
# shellcheck disable=SC2035
env LANG=C bsdtar -vczf .MTREE --format=mtree \
--options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
.PKGINFO *
# shellcheck disable=SC2035
env LANG=C bsdtar -vcf - .MTREE .PKGINFO * | xz -c -z - > \
"$PKGDEST/${pkgfile%-*}-$CARCH.pkg.tar.xz" || return
popd >/dev/null || return
;;
esac
}
package_enable_arch() {
sed -i "/arch=(.*\\bany\\b.*)/!s/arch=([^)]*/& $1/" PKGBUILD
# force regeneration of .SRCINFO
rm -f .SRCINFO
}
package_has_patch() {
local OPTIND o p=''
while getopts "p:" o; do
case "$o" in
p) p="-$OPTARG" ;;
*) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-p prefix] pkgname" ;;
esac
done
shift $((OPTIND-1))
local pkgbase pkgname
pkgbase=$(srcinfo_pkgbase) || return
pkgname=$(srcinfo_pkgname) || return
local patch="$SRCDIR/patches/$CARCH/$pkgbase$p.$pkgname".patch
[ -f "$patch" ] || patch="$SRCDIR/patches/$CARCH/$pkgbase$p".patch
[ -f "$patch" ] || patch="$SRCDIR/patches/generic/$pkgbase$p.$pkgname".patch
[ -f "$patch" ] || patch="$SRCDIR/patches/generic/$pkgbase$p".patch
[ -f "$patch" ] || return "$ERROR_MISSING"
}
package_patch() {
local OPTIND o p='' r=no
while getopts "p:r" o; do
case "$o" in
p) p="-$OPTARG" ;;
r) r=yes ;;
*) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-p prefix] [-r] pkgname" ;;
esac
done
shift $((OPTIND-1))
local pkgbase pkgname
pkgbase=$(srcinfo_pkgbase) || return
pkgname=$(srcinfo_pkgname) || return
local patch="$SRCDIR/patches/$CARCH/$pkgbase$p.$pkgname".patch
echo -n "checking for $CARCH/$(basename "$patch") ... "
local have_patch=yes
if [ ! -f "$patch" ]; then
have_patch=no
fi
echo "$have_patch (needed: $r)"
if [ "x$have_patch" == "xno" ]; then
patch="$SRCDIR/patches/$CARCH/$pkgbase$p".patch
echo -n "checking for $CARCH/$(basename "$patch") ... "
have_patch=yes
if [ ! -f "$patch" ]; then
have_patch=no
fi
echo "$have_patch (needed: $r)"
fi
if [ "x$have_patch" == "xno" ]; then
patch="$SRCDIR/patches/generic/$pkgbase$p.$pkgname".patch
echo -n "checking for generic/$(basename "$patch") ... "
have_patch=yes
if [ ! -f "$patch" ]; then
have_patch=no
fi
echo "$have_patch (needed: $r)"
fi
if [ "x$have_patch" == "xno" ]; then
patch="$SRCDIR/patches/generic/$pkgbase$p".patch
echo -n "checking for generic/$(basename "$patch") ... "
have_patch=yes
if [ ! -f "$patch" ]; then
have_patch=no
fi
echo "$have_patch (needed: $r)"
fi
ln -s "$patch" .PATCH
[ "x$r" == "xyes" ] && [ "x$have_patch" == "xno" ] && return "$ERROR_MISSING"
cp PKGBUILD{,.orig}
[ ! -e "$patch" ] || patch -Np1 -i "$patch" || return
cp PKGBUILD{,.in}
# force regeneration of .SRCINFO
rm -f .SRCINFO
}
package_import_keys() {
local keys k
keys="$(srcinfo_validpgpkeys)"
for k in $keys; do
check_gpgkey "$k" && continue
if ! retry -n 5 -s 60 sudo -u "$SUDO_USER" gpg --recv-keys "$k"; then
error -n "failed to import key '$k'"
return "$ERROR_KEYFAIL"
fi
done
}
|