@@ -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,24 @@ 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+ 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
114124xbps-uhelper pkgmatch " xbps-$( $RCV -V | cut -d' ' -f2) _1" ' xbps>=0.54_1'
115125case " $? " in
@@ -123,9 +133,15 @@ case "$?" in
123133 ;;
124134esac
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+
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,15 +214,27 @@ 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: allbuilt allremoved\n" >> Makefile
196221printf " \t@echo \" [Done]\" \n\n" >> Makefile
222+ printf " allbuilt: \$ (BUILT)\n\n" >> Makefile
223+ printf " allremoved: \$ (REMOVED)\n\n" >> Makefile
197224printf " print_pkgs:\n" >> Makefile
198225printf " \t@echo \$ (PKGS)\n\n" >> Makefile
226+ printf " print_pkgs_removed:\n" >> Makefile
227+ printf " \t@echo \$ (PKGS_REMOVED)\n\n" >> Makefile
199228printf " built/%%: tobuild/%%\n" >> Makefile
200229printf " \t@echo \" [xbps-src]\t\$ {@F}\" \n" >> Makefile
201230printf " \t@( $XSC pkg \$ {@F}; rval=\$\$ ?; [ \$\$ rval -eq 2 ] && exit 0 || exit \$\$ rval )\n" >> Makefile
202231printf " \t@touch \$ @\n" >> Makefile
203232printf " \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
206240printf " INFO: Finding and adding dependencies...\n"
@@ -228,11 +262,16 @@ for p in $TOBUILD; do
228262 printf " built/$p : $deps \n" >> Makefile
229263done
230264
265+ for p in $TOREMOVE ; do
266+ printf " removed/$p :\n" >> Makefile
267+ done
268+
231269printf " \n" >> Makefile
232270printf " clean:\n" >> Makefile
233271printf " \t@rm -f built/*\n" >> Makefile
272+ printf " \t@rm -f removed/*\n" >> Makefile
234273printf " \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
237276printf " INFO: 'Makefile' generated.\n"
238277printf " INFO: Type 'make'\n"
0 commit comments