Luna/ports/remove-port.sh

45 lines
750 B
Bash
Executable File

#!/usr/bin/env bash
set -e
cd $(dirname $0)/..
source tools/env.sh
cd ports
export DESTDIR=${DESTDIR:-"$LUNA_ROOT/initrd"}
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 | grep -v $pkgname | tee $listdir/ports.list >/dev/null
echo "Success! Removed port: $pkgname version $pkgver."