Skip to content

Commit

Permalink
configure: unindex removed packages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Chocimier committed Dec 21, 2019
1 parent 4a82276 commit 16a5db7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
6 changes: 5 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ targets in the generated "tobuild" subdirectory. Once a package has been built,
a small file is created into the "built" subdirectory in order to tell Make not
to build it again.

Every time you run './configure', those two subdirectories are reset, so you
For packages listed by xbps-checkvers as removed, Make removes binary packages
and unindexes them. Directiories "toremove" and "removed" are used analogically
to "tobuild" and "built".

Every time you run './configure', those four subdirectories are reset, so you
cannot interrupt a build, run './configure', and resume properly. In order to
resume a build in these kinds of circumstances, you must completely remove
'repo-checkvers.txt', so that ./configure can detect what has already been
Expand Down
40 changes: 32 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CFG_CMDLINE=
CFG_CROSS=
CFG_REPO=
CROSS_ARCH=
PKG_ARCH=
DISTDIR=
MASTERDIR=
HOSTDIR=
Expand Down Expand Up @@ -44,7 +45,7 @@ while getopts a:Cc:d:Nm:th:vR: OPT; do
exit 0
;;
C)
rm -rf tobuild built
rm -rf tobuild built toremove removed
rm -f *.txt Makefile
exit 0
;;
Expand Down Expand Up @@ -90,6 +91,7 @@ shift $(($OPTIND - 1))
: ${MASTERDIR:=$DISTDIR/masterdir}
: ${HOSTDIR:=$DISTDIR/hostdir}

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

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

RCV_CMD_LINE="$RCV $CFG_REPO --distdir=${DISTDIR} ${*}"
if $RCV -h 2>&1 | grep -q -e --removed; then
RCV_REMOVED=-e
else
RCV_REMOVED=
fi

RCV_CMD_LINE="$RCV $RCV_REMOVED $CFG_REPO --distdir=${DISTDIR} ${*}"
printf "INFO: Getting list of updates, please wait...\n"
printf "INFO: Running '$RCV_CMD_LINE' (${CROSS_ARCH:-native}) ...\n"

Expand All @@ -114,28 +122,31 @@ fi
xbps-uhelper pkgmatch "xbps-$($RCV -V | cut -d' ' -f2)_1" 'xbps>=0.54_1'
case "$?" in
0) # version < 0.54
grep pkgname "$RCV_F" | awk '{ print $2 }' >pkgs.txt ;;
grep pkgname "$RCV_F" | awk '{ print $2 0 0 }' >pkgs.txt ;;
1) # version >= 0.54
cut -d' ' -f1 "$RCV_F" >pkgs.txt ;;
cut -d' ' -f1-3 "$RCV_F" >pkgs.txt ;;
*)
echo "ERROR: couldn't determine xbps-checkvers version"
exit 1
;;
esac

printf "INFO: Creating source targets...\n"
rm -rf tobuild built
mkdir -p tobuild built
for p in `cat pkgs.txt`; do
rm -rf tobuild built toremove removed
mkdir -p tobuild built toremove removed
cat pkgs.txt | while read p old new; do
if [ -f "$SRCPKGS/$p/template" ]; then
$XSC show-avail $p 2>/dev/null
if [ $? -eq 0 ]; then
touch tobuild/$p
fi
elif [ "$new" = - ]; then
touch toremove/$p-$old
fi
done

_TOBUILD="`find tobuild -type f`"
TOREMOVE="`find toremove -type f -printf '%f '`"

concat() {
local found=0
Expand Down Expand Up @@ -192,7 +203,10 @@ printf "# Generated by configure, do not modify.\n\n" >> Makefile
printf "PKGS = $TOBUILD\n" >> Makefile
printf "TOBUILD = \$(patsubst %%,tobuild/%%,\$(PKGS))\n" >> Makefile
printf "BUILT = \$(patsubst tobuild/%%,built/%%,\$(TOBUILD))\n\n" >> Makefile
printf "all: \$(BUILT)\n" >> Makefile
printf "PKGS_REMOVED = $TOREMOVE\n" >> Makefile
printf "TOREMOVE = \$(patsubst %%,toremove/%%,\$(PKGS_REMOVED))\n" >> Makefile
printf "REMOVED = \$(patsubst toremove/%%,removed/%%,\$(TOREMOVE))\n\n" >> Makefile
printf "all: \$(BUILT) \$(REMOVED)\n" >> Makefile
printf "\t@echo \"[Done]\"\n\n" >> Makefile
printf "print_pkgs:\n" >> Makefile
printf "\t@echo \$(PKGS)\n\n" >> Makefile
Expand All @@ -201,6 +215,11 @@ printf "\t@echo \"[xbps-src]\t\${@F}\"\n" >> Makefile
printf "\t@( $XSC pkg \${@F}; rval=\$\$?; [ \$\$rval -eq 2 ] && exit 0 || exit \$\$rval )\n" >> Makefile
printf "\t@touch \$@\n" >> Makefile
printf "\t@rm tobuild/\${@F}\n\n" >> Makefile
printf "removed/%%: toremove/%%\n" >> Makefile
printf "\t@echo \"[xbps-rindex -R]\t\${@F}\"\n" >> Makefile
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
printf "\t@touch \$@\n" >> Makefile
printf "\t@rm toremove/\${@F}\n\n" >> Makefile


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

for p in $TOREMOVE; do
printf "removed/$p:\n" >> Makefile
done

printf "\n" >> Makefile
printf "clean:\n" >> Makefile
printf "\t@rm -f built/*\n" >> Makefile
printf "\t@rm -f removed/*\n" >> Makefile
printf "\t@echo \"[Clean]\"\n\n" >> Makefile
printf ".PHONY: all print_pkgs clean\n" >> Makefile

Expand Down

0 comments on commit 16a5db7

Please sign in to comment.