Luna/ports/remove-port.sh
apio 1a82bbb234 ports: Add a port system
The only port right now is bc, which works... kind of.
It compiles, and runs, but is really janky. At least it runs!!
2022-10-23 16:44:50 +02:00

44 lines
681 B
Bash
Executable File

#!/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
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."