Luna/tools/install-package.sh
apio 9a00b29304
All checks were successful
continuous-integration/drone/push Build is passing
ports: Basic ports system + nasm port
2023-07-24 17:07:49 +02:00

50 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
source $(dirname $0)/env.sh
cd $LUNA_ROOT
PORT_NAME=$1
if ! [ -f ports/$PORT_NAME/PACKAGE ]
then
echo "Package $PORT_NAME does not exist. Make sure there is a valid PACKAGE file in the appropriate directory!"
exit 1
fi
source ports/$PORT_NAME/PACKAGE
if [ -f ports/local/$name-$version.tar.gz ]; then
echo "Package $PORT_NAME is already installed and up to date!"
exit 1
fi
if ! [ -f ports/out/$name-$version.tar.gz ]; then
tools/make-package.sh $PORT_NAME
fi
PORT_FILES=$LUNA_BASE/usr/share/pkgdb/$PORT_NAME.files
if [ -f $PORT_FILES ]
then
echo "Package $PORT_NAME is installed, but is an outdated version. Updating."
tools/uninstall-package.sh $PORT_NAME
fi
cp ports/out/$name-$version.tar.gz ports/local/
mkdir -p $LUNA_BASE/usr/share/pkgdb/
cd $LUNA_BASE
find -type f > /tmp/before.list
tar -C $LUNA_BASE -xf $LUNA_ROOT/ports/local/$name-$version.tar.gz
find -type f > /tmp/after.list
awk 'FNR==NR {a[$0]++; next} !($0 in a)' /tmp/before.list /tmp/after.list > $LUNA_BASE/usr/share/pkgdb/$name.files
echo "Package $name version $version successfully installed!"