@@ -5,6 +5,7 @@ CFG_CMDLINE=
55CFG_CROSS=
66CFG_REPO=
77CROSS_ARCH=
8+ PKG_ARCH=
89DISTDIR=
910MASTERDIR=
1011HOSTDIR=
1314_append=" "
1415RCV=` command -v xbps-checkvers 2> /dev/null`
1516RCV_F=" repo-checkvers.txt"
17+ RCV_FR=" repo-checkvers-remove.txt"
1618TOBUILD=
1719_TOBUILD=
1820USAGE=" 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)}
9396SRCPKGS=$DISTDIR /srcpkgs
9497XBPS_SRCPKGDIR=$SRCPKGS
9598
@@ -99,17 +102,23 @@ if [ -n "$CFG_CROSS" ]; then
99102 export XBPS_TARGET_ARCH=$CROSS_ARCH
100103fi
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
114123xbps-uhelper pkgmatch " xbps-$( $RCV -V | cut -d' ' -f2) _1" ' xbps>=0.54_1'
115124case " $? " in
@@ -123,9 +132,16 @@ case "$?" in
123132 ;;
124133esac
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+
126142printf " 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
129145for 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
136152done
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
140162concat () {
141163 local found=0
@@ -192,7 +214,10 @@ printf "# Generated by configure, do not modify.\n\n" >> Makefile
192214printf " PKGS = $TOBUILD \n" >> Makefile
193215printf " TOBUILD = \$ (patsubst %%,tobuild/%%,\$ (PKGS))\n" >> Makefile
194216printf " 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
196221printf " \t@echo \" [Done]\" \n\n" >> Makefile
197222printf " print_pkgs:\n" >> Makefile
198223printf " \t@echo \$ (PKGS)\n\n" >> Makefile
@@ -201,6 +226,11 @@ printf "\t@echo \"[xbps-src]\t\${@F}\"\n" >> Makefile
201226printf " \t@( $XSC pkg \$ {@F}; rval=\$\$ ?; [ \$\$ rval -eq 2 ] && exit 0 || exit \$\$ rval )\n" >> Makefile
202227printf " \t@touch \$ @\n" >> Makefile
203228printf " \t@rm tobuild/\$ {@F}\n\n" >> Makefile
229+ printf " removed/%%: toremove/%%\n" >> Makefile
230+ printf " \t@echo \" [xbps-rindex -R]\t\$ {@F}\" \n" >> Makefile
231+ 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
232+ printf " \t@touch \$ @\n" >> Makefile
233+ printf " \t@rm toremove/\$ {@F}\n\n" >> Makefile
204234
205235
206236printf " INFO: Finding and adding dependencies...\n"
@@ -228,9 +258,14 @@ for p in $TOBUILD; do
228258 printf " built/$p : $deps \n" >> Makefile
229259done
230260
261+ for p in $TOREMOVE ; do
262+ printf " removed/$p :\n" >> Makefile
263+ done
264+
231265printf " \n" >> Makefile
232266printf " clean:\n" >> Makefile
233267printf " \t@rm -f built/*\n" >> Makefile
268+ printf " \t@rm -f removed/*\n" >> Makefile
234269printf " \t@echo \" [Clean]\" \n\n" >> Makefile
235270printf " .PHONY: all print_pkgs clean\n" >> Makefile
236271
0 commit comments