Luna/tools/install-package.sh

50 lines
1.1 KiB
Bash
Raw Normal View History

2023-07-24 15:07:49 +00:00
#!/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
IS_NEW_VERSION=0
2023-07-24 15:07:49 +00:00
if ! [ -f ports/out/$name-$version.tar.gz ]; then
tools/make-package.sh $PORT_NAME
IS_NEW_VERSION=1
2023-07-24 15:07:49 +00:00
fi
PORT_FILES=$LUNA_BASE/usr/share/pkgdb/$name.files
2023-07-24 15:07:49 +00:00
if [ -f $PORT_FILES ]
then
if [ "$IS_NEW_VERSION" -eq "0" ]; then
echo "Package $PORT_NAME version $version is already installed!"
exit 0
fi
echo "Package $PORT_NAME is already installed! Updating to version $version."
tools/uninstall-package.sh $name
2023-07-24 15:07:49 +00:00
fi
mkdir -p $LUNA_BASE/usr/share/pkgdb/
cd $LUNA_BASE
find -type f | sed 's|^./||' > /tmp/before.list
2023-07-24 15:07:49 +00:00
tar -C $LUNA_BASE -xf $LUNA_ROOT/ports/out/$name-$version.tar.gz
2023-07-24 15:07:49 +00:00
find -type f | sed 's|^./||' > /tmp/after.list
2023-07-24 15:07:49 +00:00
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!"