diff --git a/README b/README index 65ba3b0..f505d02 100644 --- a/README +++ b/README @@ -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 diff --git a/configure b/configure index df641d4..40f9d17 100755 --- a/configure +++ b/configure @@ -5,6 +5,7 @@ CFG_CMDLINE= CFG_CROSS= CFG_REPO= CROSS_ARCH= +PKG_ARCH= DISTDIR= MASTERDIR= HOSTDIR= @@ -13,6 +14,7 @@ XSC= _append="" RCV=`command -v xbps-checkvers 2>/dev/null` RCV_F="repo-checkvers.txt" +RCV_FR="repo-checkvers-remove.txt" TOBUILD= _TOBUILD= 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 exit 0 ;; C) - rm -rf tobuild built + rm -rf tobuild built toremove removed rm -f *.txt Makefile exit 0 ;; @@ -90,6 +92,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 @@ -99,17 +102,23 @@ if [ -n "$CFG_CROSS" ]; then export XBPS_TARGET_ARCH=$CROSS_ARCH fi -RCV_CMD_LINE="$RCV $CFG_REPO --distdir=${DISTDIR} ${*}" -printf "INFO: Getting list of updates, please wait...\n" -printf "INFO: Running '$RCV_CMD_LINE' (${CROSS_ARCH:-native}) ...\n" +run_rcv() { + local file=$1 flags=$2 + RCV_CMD_LINE="$RCV $flags $CFG_REPO --distdir=${DISTDIR} ${*}" + printf "INFO: Getting list of updates, please wait...\n" + printf "INFO: Running '$RCV_CMD_LINE' (${CROSS_ARCH:-native}) ...\n" -[ -f $RCV_F ] && _append="-a" -$RCV_CMD_LINE | tee ${_append} $RCV_F -rval=${PIPESTATUS[0]} -if [ $rval -ne 0 ]; then - echo "ERROR: xbps-checkvers exited with an error: $rval" - exit 1 -fi + _append="" + [ -f $file ] && _append="-a" + $RCV_CMD_LINE | tee ${_append} $file + rval=${PIPESTATUS[0]} + if [ $rval -ne 0 ]; then + echo "ERROR: xbps-checkvers exited with an error: $rval" + exit 1 + fi +} + +run_rcv $RCV_F xbps-uhelper pkgmatch "xbps-$($RCV -V | cut -d' ' -f2)_1" 'xbps>=0.54_1' case "$?" in @@ -123,9 +132,16 @@ case "$?" in ;; esac +RCV_REMOVED=--removed +if $RCV -h 2>&1 | grep -q -e $RCV_REMOVED; then + run_rcv $RCV_FR $RCV_REMOVED + + cut -d' ' -f1-2 "$RCV_FR" >pkgs-removed.txt +fi + printf "INFO: Creating source targets...\n" -rm -rf tobuild built -mkdir -p tobuild built +rm -rf tobuild built toremove removed +mkdir -p tobuild built toremove removed for p in `cat pkgs.txt`; do if [ -f "$SRCPKGS/$p/template" ]; then $XSC show-avail $p 2>/dev/null @@ -134,8 +150,14 @@ for p in `cat pkgs.txt`; do fi fi done +[ -f pkgs-removed.txt ] && cat pkgs-removed.txt | while read p old; do + if ! [ -f "$SRCPKGS/$p/template" ]; then + touch toremove/$p-$old + fi +done _TOBUILD="`find tobuild -type f`" +TOREMOVE="`find toremove -type f -printf '%f '`" concat() { local found=0 @@ -192,7 +214,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 @@ -201,6 +226,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 --remove --stage '{}' ';'\n" >> Makefile +printf "\t@touch \$@\n" >> Makefile +printf "\t@rm toremove/\${@F}\n\n" >> Makefile printf "INFO: Finding and adding dependencies...\n" @@ -228,9 +258,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