Skip to content

Commit 16a5db7

Browse files
committed
configure: unindex removed packages
For packages reported by xbps-checkvers as removed, generated makefile finds files matching <pkgversion>.<arch>.xbps or <pkgversion>.noarch.xbps. This is needed to know where is repodata where package is indexed (path may contain multilib, aarch64, nonfree subdirectories). Then, xbps-rindex is called to unindex package. Then, package file is removed from disk, but if it is noarch, it is recreated as empty file to allow it to be unindexed on other architectures. As it is not valid package, it won't be indexed again.
1 parent 4a82276 commit 16a5db7

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

README

+5-1
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

+32-8
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=
@@ -44,7 +45,7 @@ while getopts a:Cc:d:Nm:th:vR: OPT; do
4445
exit 0
4546
;;
4647
C)
47-
rm -rf tobuild built
48+
rm -rf tobuild built toremove removed
4849
rm -f *.txt Makefile
4950
exit 0
5051
;;
@@ -90,6 +91,7 @@ shift $(($OPTIND - 1))
9091
: ${MASTERDIR:=$DISTDIR/masterdir}
9192
: ${HOSTDIR:=$DISTDIR/hostdir}
9293

94+
PKG_ARCH=${CROSS_ARCH:-$(xbps-uhelper -r "$MASTERDIR" arch)}
9395
SRCPKGS=$DISTDIR/srcpkgs
9496
XBPS_SRCPKGDIR=$SRCPKGS
9597

@@ -99,7 +101,13 @@ if [ -n "$CFG_CROSS" ]; then
99101
export XBPS_TARGET_ARCH=$CROSS_ARCH
100102
fi
101103

102-
RCV_CMD_LINE="$RCV $CFG_REPO --distdir=${DISTDIR} ${*}"
104+
if $RCV -h 2>&1 | grep -q -e --removed; then
105+
RCV_REMOVED=-e
106+
else
107+
RCV_REMOVED=
108+
fi
109+
110+
RCV_CMD_LINE="$RCV $RCV_REMOVED $CFG_REPO --distdir=${DISTDIR} ${*}"
103111
printf "INFO: Getting list of updates, please wait...\n"
104112
printf "INFO: Running '$RCV_CMD_LINE' (${CROSS_ARCH:-native}) ...\n"
105113

@@ -114,28 +122,31 @@ fi
114122
xbps-uhelper pkgmatch "xbps-$($RCV -V | cut -d' ' -f2)_1" 'xbps>=0.54_1'
115123
case "$?" in
116124
0) # version < 0.54
117-
grep pkgname "$RCV_F" | awk '{ print $2 }' >pkgs.txt ;;
125+
grep pkgname "$RCV_F" | awk '{ print $2 0 0 }' >pkgs.txt ;;
118126
1) # version >= 0.54
119-
cut -d' ' -f1 "$RCV_F" >pkgs.txt ;;
127+
cut -d' ' -f1-3 "$RCV_F" >pkgs.txt ;;
120128
*)
121129
echo "ERROR: couldn't determine xbps-checkvers version"
122130
exit 1
123131
;;
124132
esac
125133

126134
printf "INFO: Creating source targets...\n"
127-
rm -rf tobuild built
128-
mkdir -p tobuild built
129-
for p in `cat pkgs.txt`; do
135+
rm -rf tobuild built toremove removed
136+
mkdir -p tobuild built toremove removed
137+
cat pkgs.txt | while read p old new; do
130138
if [ -f "$SRCPKGS/$p/template" ]; then
131139
$XSC show-avail $p 2>/dev/null
132140
if [ $? -eq 0 ]; then
133141
touch tobuild/$p
134142
fi
143+
elif [ "$new" = - ]; then
144+
touch toremove/$p-$old
135145
fi
136146
done
137147

138148
_TOBUILD="`find tobuild -type f`"
149+
TOREMOVE="`find toremove -type f -printf '%f '`"
139150

140151
concat() {
141152
local found=0
@@ -192,7 +203,10 @@ printf "# Generated by configure, do not modify.\n\n" >> Makefile
192203
printf "PKGS = $TOBUILD\n" >> Makefile
193204
printf "TOBUILD = \$(patsubst %%,tobuild/%%,\$(PKGS))\n" >> Makefile
194205
printf "BUILT = \$(patsubst tobuild/%%,built/%%,\$(TOBUILD))\n\n" >> Makefile
195-
printf "all: \$(BUILT)\n" >> Makefile
206+
printf "PKGS_REMOVED = $TOREMOVE\n" >> Makefile
207+
printf "TOREMOVE = \$(patsubst %%,toremove/%%,\$(PKGS_REMOVED))\n" >> Makefile
208+
printf "REMOVED = \$(patsubst toremove/%%,removed/%%,\$(TOREMOVE))\n\n" >> Makefile
209+
printf "all: \$(BUILT) \$(REMOVED)\n" >> Makefile
196210
printf "\t@echo \"[Done]\"\n\n" >> Makefile
197211
printf "print_pkgs:\n" >> Makefile
198212
printf "\t@echo \$(PKGS)\n\n" >> Makefile
@@ -201,6 +215,11 @@ printf "\t@echo \"[xbps-src]\t\${@F}\"\n" >> Makefile
201215
printf "\t@( $XSC pkg \${@F}; rval=\$\$?; [ \$\$rval -eq 2 ] && exit 0 || exit \$\$rval )\n" >> Makefile
202216
printf "\t@touch \$@\n" >> Makefile
203217
printf "\t@rm tobuild/\${@F}\n\n" >> Makefile
218+
printf "removed/%%: toremove/%%\n" >> Makefile
219+
printf "\t@echo \"[xbps-rindex -R]\t\${@F}\"\n" >> Makefile
220+
printf "\t@find \"$HOSTDIR/binpkgs\" '(' -name \${@F}.$PKG_ARCH.xbps -o -name \${@F}.noarch.xbps ')' -exec env ${CROSS_ARCH:+XBPS_TARGET_ARCH=$CROSS_ARCH} xbps-rindex -R '{}' ';' -delete '(' -name \${@F}.noarch.xbps -a -exec touch '{}' ';' ')' \n" >> Makefile
221+
printf "\t@touch \$@\n" >> Makefile
222+
printf "\t@rm toremove/\${@F}\n\n" >> Makefile
204223

205224

206225
printf "INFO: Finding and adding dependencies...\n"
@@ -228,9 +247,14 @@ for p in $TOBUILD; do
228247
printf "built/$p: $deps\n" >> Makefile
229248
done
230249

250+
for p in $TOREMOVE; do
251+
printf "removed/$p:\n" >> Makefile
252+
done
253+
231254
printf "\n" >> Makefile
232255
printf "clean:\n" >> Makefile
233256
printf "\t@rm -f built/*\n" >> Makefile
257+
printf "\t@rm -f removed/*\n" >> Makefile
234258
printf "\t@echo \"[Clean]\"\n\n" >> Makefile
235259
printf ".PHONY: all print_pkgs clean\n" >> Makefile
236260

0 commit comments

Comments
 (0)