Luna/ports/remove-port.sh

44 lines
717 B
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
cd $(dirname $0)/..
source tools/env.sh
cd ports
export listdir=$PWD
if [ -z $1 ]
then
echo "Usage: remove-port.sh <port-name>"
exit 1
fi
if [ -d $1 ]
then
pkgscript=$1/package.sh
elif [ -f $1 ]
then
pkgscript=$1
else
echo "Unrecognized argument: $1"
exit 1
fi
export portdir=$(realpath $(dirname $pkgscript))
export workdir=$portdir/workdir
mkdir -p $workdir
source $pkgscript
echo "Removing $pkgname version $pkgver..."
cd $installdir
port_uninstall | filter-lines $pkgname "uninstall"
rm -rf $workdir
cat $listdir/ports.list | sort | uniq | grep -v $pkgname | tee $listdir/ports.list >/dev/null
echo "Success! Removed port: $pkgname version $pkgver."