Skip to content

Commit b8a67b5

Browse files
committed
configure: unindex removed packages
For packages reported by xbps-checkvers as removed, generated makefile finds files matching <pkgversion>.<arch>.xbps. This is needed to know where is repodata in which package is indexed (path may contain multilib, aarch64, nonfree subdirectories). Then, xbps-rindex is called to remove package from stage index. Then, xbps-repodb needs to remove package from public index when no other package depend on it. Finally, xbps-rindex -r will remove package file.
1 parent 4a82276 commit b8a67b5

File tree

3 files changed

+58
-15
lines changed

3 files changed

+58
-15
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Makefile
22
tobuild
33
built
4+
toremove
5+
removed
46
pkgs.txt
7+
pkgs-removed.txt
58
repo-checkvers.txt
9+
repo-checkvers-remove.txt

README

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ targets in the generated "tobuild" subdirectory. Once a package has been built,
2323
a small file is created into the "built" subdirectory in order to tell Make not
2424
to build it again.
2525

26-
Every time you run './configure', those two subdirectories are reset, so you
26+
For packages listed by xbps-checkvers as removed, Make removes binary packages
27+
and unindexes them. Directiories "toremove" and "removed" are used analogically
28+
to "tobuild" and "built".
29+
30+
Every time you run './configure', those four subdirectories are reset, so you
2731
cannot interrupt a build, run './configure', and resume properly. In order to
2832
resume a build in these kinds of circumstances, you must completely remove
2933
'repo-checkvers.txt', so that ./configure can detect what has already been

configure

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CFG_CMDLINE=
55
CFG_CROSS=
66
CFG_REPO=
77
CROSS_ARCH=
8+
PKG_ARCH=
89
DISTDIR=
910
MASTERDIR=
1011
HOSTDIR=
@@ -13,6 +14,7 @@ XSC=
1314
_append=""
1415
RCV=`command -v xbps-checkvers 2>/dev/null`
1516
RCV_F="repo-checkvers.txt"
17+
RCV_FR="repo-checkvers-remove.txt"
1618
TOBUILD=
1719
_TOBUILD=
1820
USAGE="Usage: $0 [-a cross-arch] [-CN] [-R repo] [-d|-m|-h dir]"
@@ -44,7 +46,7 @@ while getopts a:Cc:d:Nm:th:vR: OPT; do
4446
exit 0
4547
;;
4648
C)
47-
rm -rf tobuild built
49+
rm -rf tobuild built toremove removed
4850
rm -f *.txt Makefile
4951
exit 0
5052
;;
@@ -90,6 +92,7 @@ shift $(($OPTIND - 1))
9092
: ${MASTERDIR:=$DISTDIR/masterdir}
9193
: ${HOSTDIR:=$DISTDIR/hostdir}
9294

95+
PKG_ARCH=${CROSS_ARCH:-$(xbps-uhelper -r "$MASTERDIR" arch)}
9396
SRCPKGS=$DISTDIR/srcpkgs
9497
XBPS_SRCPKGDIR=$SRCPKGS
9598

@@ -99,17 +102,23 @@ if [ -n "$CFG_CROSS" ]; then
99102
export XBPS_TARGET_ARCH=$CROSS_ARCH
100103
fi
101104

102-
RCV_CMD_LINE="$RCV $CFG_REPO --distdir=${DISTDIR} ${*}"
103-
printf "INFO: Getting list of updates, please wait...\n"
104-
printf "INFO: Running '$RCV_CMD_LINE' (${CROSS_ARCH:-native}) ...\n"
105+
run_rcv() {
106+
local file=$1 flags=$2
107+
RCV_CMD_LINE="$RCV $flags $CFG_REPO --distdir=${DISTDIR} ${*}"
108+
printf "INFO: Getting list of updates, please wait...\n"
109+
printf "INFO: Running '$RCV_CMD_LINE' (${CROSS_ARCH:-native}) ...\n"
105110

106-
[ -f $RCV_F ] && _append="-a"
107-
$RCV_CMD_LINE | tee ${_append} $RCV_F
108-
rval=${PIPESTATUS[0]}
109-
if [ $rval -ne 0 ]; then
110-
echo "ERROR: xbps-checkvers exited with an error: $rval"
111-
exit 1
112-
fi
111+
_append=""
112+
[ -f $file ] && _append="-a"
113+
$RCV_CMD_LINE | tee ${_append} $file
114+
rval=${PIPESTATUS[0]}
115+
if [ $rval -ne 0 ]; then
116+
echo "ERROR: xbps-checkvers exited with an error: $rval"
117+
exit 1
118+
fi
119+
}
120+
121+
run_rcv $RCV_F
113122

114123
xbps-uhelper pkgmatch "xbps-$($RCV -V | cut -d' ' -f2)_1" 'xbps>=0.54_1'
115124
case "$?" in
@@ -123,9 +132,16 @@ case "$?" in
123132
;;
124133
esac
125134

135+
RCV_REMOVED=--removed
136+
if $RCV -h 2>&1 | grep -q -e $RCV_REMOVED; then
137+
run_rcv $RCV_FR $RCV_REMOVED
138+
139+
cut -d' ' -f1-2 "$RCV_FR" >pkgs-removed.txt
140+
fi
141+
126142
printf "INFO: Creating source targets...\n"
127-
rm -rf tobuild built
128-
mkdir -p tobuild built
143+
rm -rf tobuild built toremove removed
144+
mkdir -p tobuild built toremove removed
129145
for p in `cat pkgs.txt`; do
130146
if [ -f "$SRCPKGS/$p/template" ]; then
131147
$XSC show-avail $p 2>/dev/null
@@ -134,8 +150,14 @@ for p in `cat pkgs.txt`; do
134150
fi
135151
fi
136152
done
153+
[ -f pkgs-removed.txt ] && cat pkgs-removed.txt | while read p old; do
154+
if ! [ -f "$SRCPKGS/$p/template" ]; then
155+
touch toremove/$p-$old
156+
fi
157+
done
137158

138159
_TOBUILD="`find tobuild -type f`"
160+
TOREMOVE="`find toremove -type f -printf '%f '`"
139161

140162
concat() {
141163
local found=0
@@ -192,7 +214,10 @@ printf "# Generated by configure, do not modify.\n\n" >> Makefile
192214
printf "PKGS = $TOBUILD\n" >> Makefile
193215
printf "TOBUILD = \$(patsubst %%,tobuild/%%,\$(PKGS))\n" >> Makefile
194216
printf "BUILT = \$(patsubst tobuild/%%,built/%%,\$(TOBUILD))\n\n" >> Makefile
195-
printf "all: \$(BUILT)\n" >> Makefile
217+
printf "PKGS_REMOVED = $TOREMOVE\n" >> Makefile
218+
printf "TOREMOVE = \$(patsubst %%,toremove/%%,\$(PKGS_REMOVED))\n" >> Makefile
219+
printf "REMOVED = \$(patsubst toremove/%%,removed/%%,\$(TOREMOVE))\n\n" >> Makefile
220+
printf "all: \$(BUILT) \$(REMOVED)\n" >> Makefile
196221
printf "\t@echo \"[Done]\"\n\n" >> Makefile
197222
printf "print_pkgs:\n" >> Makefile
198223
printf "\t@echo \$(PKGS)\n\n" >> Makefile
@@ -201,6 +226,11 @@ printf "\t@echo \"[xbps-src]\t\${@F}\"\n" >> Makefile
201226
printf "\t@( $XSC pkg \${@F}; rval=\$\$?; [ \$\$rval -eq 2 ] && exit 0 || exit \$\$rval )\n" >> Makefile
202227
printf "\t@touch \$@\n" >> Makefile
203228
printf "\t@rm tobuild/\${@F}\n\n" >> Makefile
229+
printf "removed/%%: toremove/%%\n" >> Makefile
230+
printf "\t@echo \"[xbps-rindex --remove --stage]\t\${@F}\"\n" >> Makefile
231+
printf "\t@find \"$HOSTDIR/binpkgs\" -name \${@F}.$PKG_ARCH.xbps -exec env ${CROSS_ARCH:+XBPS_TARGET_ARCH=$CROSS_ARCH} xbps-rindex --remove --stage '{}' ';'\n" >> Makefile
232+
printf "\t@touch \$@\n" >> Makefile
233+
printf "\t@rm toremove/\${@F}\n\n" >> Makefile
204234

205235

206236
printf "INFO: Finding and adding dependencies...\n"
@@ -228,9 +258,14 @@ for p in $TOBUILD; do
228258
printf "built/$p: $deps\n" >> Makefile
229259
done
230260

261+
for p in $TOREMOVE; do
262+
printf "removed/$p:\n" >> Makefile
263+
done
264+
231265
printf "\n" >> Makefile
232266
printf "clean:\n" >> Makefile
233267
printf "\t@rm -f built/*\n" >> Makefile
268+
printf "\t@rm -f removed/*\n" >> Makefile
234269
printf "\t@echo \"[Clean]\"\n\n" >> Makefile
235270
printf ".PHONY: all print_pkgs clean\n" >> Makefile
236271

0 commit comments

Comments
 (0)