#!/bin/sh

if [ "$1" = "-u" ]; then
	update=1
fi

prt-get dup | grep crux-musl | while read -r p1 v1 _ p2 v2; do
	if [ "$v1" != "$v2" ]; then
		if [ "$update" = 1 ]; then
			ver=${v2%-*}
			rel=${v2##*-}
			sed "s/^version=.*/version=$ver/" -i $p1/Pkgfile
			sed "s/^release=.*/release=$rel/" -i $p1/Pkgfile
			rm -f $p1/.md5sum $p1/.footprint
		else
			echo "${p1##*/}: $v1 $v2"
		fi
	fi
done
