Skip to content

Commit 2794466

Browse files
committed
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 3035bc7 commit 2794466

3 files changed

Lines changed: 63 additions & 16 deletions

File tree

.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: 54 additions & 15 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,24 @@ 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+
shift 2
108+
RCV_CMD_LINE="$RCV $flags $CFG_REPO --distdir=${DISTDIR} ${*}"
109+
printf "INFO: Getting list of updates, please wait...\n"
110+
printf "INFO: Running '$RCV_CMD_LINE' (${CROSS_ARCH:-native}) ...\n"
105111

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
112+
_append=""
113+
[ -f $file ] && _append="-a"
114+
$RCV_CMD_LINE | tee ${_append} $file
115+
rval=${PIPESTATUS[0]}
116+
if [ $rval -ne 0 ]; then
117+
echo "ERROR: xbps-checkvers exited with an error: $rval"
118+
exit 1
119+
fi
120+
}
121+
122+
run_rcv $RCV_F "" "$@"
113123

114124
xbps-uhelper pkgmatch "xbps-$($RCV -V | cut -d' ' -f2)_1" 'xbps>=0.54_1'
115125
case "$?" in
@@ -123,9 +133,15 @@ case "$?" in
123133
;;
124134
esac
125135

136+
RCV_REMOVED=--removed
137+
if $RCV -h 2>&1 | grep -q -e $RCV_REMOVED; then
138+
run_rcv $RCV_FR $RCV_REMOVED
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,15 +214,27 @@ 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: allbuilt allremoved\n" >> Makefile
196221
printf "\t@echo \"[Done]\"\n\n" >> Makefile
222+
printf "allbuilt: \$(BUILT)\n\n" >> Makefile
223+
printf "allremoved: \$(REMOVED)\n\n" >> Makefile
197224
printf "print_pkgs:\n" >> Makefile
198225
printf "\t@echo \$(PKGS)\n\n" >> Makefile
226+
printf "print_pkgs_removed:\n" >> Makefile
227+
printf "\t@echo \$(PKGS_REMOVED)\n\n" >> Makefile
199228
printf "built/%%: tobuild/%%\n" >> Makefile
200229
printf "\t@echo \"[xbps-src]\t\${@F}\"\n" >> Makefile
201230
printf "\t@( $XSC pkg \${@F}; rval=\$\$?; [ \$\$rval -eq 2 ] && exit 0 || exit \$\$rval )\n" >> Makefile
202231
printf "\t@touch \$@\n" >> Makefile
203232
printf "\t@rm tobuild/\${@F}\n\n" >> Makefile
233+
printf "removed/%%: toremove/%%\n" >> Makefile
234+
printf "\t@echo \"[xbps-rindex --remove --stage]\t\${@F}\"\n" >> Makefile
235+
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
236+
printf "\t@touch \$@\n" >> Makefile
237+
printf "\t@rm toremove/\${@F}\n\n" >> Makefile
204238

205239

206240
printf "INFO: Finding and adding dependencies...\n"
@@ -228,11 +262,16 @@ for p in $TOBUILD; do
228262
printf "built/$p: $deps\n" >> Makefile
229263
done
230264

265+
for p in $TOREMOVE; do
266+
printf "removed/$p:\n" >> Makefile
267+
done
268+
231269
printf "\n" >> Makefile
232270
printf "clean:\n" >> Makefile
233271
printf "\t@rm -f built/*\n" >> Makefile
272+
printf "\t@rm -f removed/*\n" >> Makefile
234273
printf "\t@echo \"[Clean]\"\n\n" >> Makefile
235-
printf ".PHONY: all print_pkgs clean\n" >> Makefile
274+
printf ".PHONY: all print_pkgs clean allbuilt allremoved\n" >> Makefile
236275

237276
printf "INFO: 'Makefile' generated.\n"
238277
printf "INFO: Type 'make'\n"

0 commit comments

Comments
 (0)