2022-10-23 14:44:50 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd $(dirname $0)/..
|
|
|
|
|
|
|
|
source tools/env.sh
|
|
|
|
|
|
|
|
cd ports
|
|
|
|
|
2022-10-23 15:15:38 +00:00
|
|
|
unset pkgname
|
|
|
|
unset pkgver
|
|
|
|
unset pkgurl
|
|
|
|
unset pkgmode
|
|
|
|
unset setupdir
|
|
|
|
unset builddir
|
|
|
|
unset installdir
|
|
|
|
unset srcdir
|
|
|
|
unset port_unpack
|
|
|
|
unset port_patch
|
|
|
|
unset port_configure
|
|
|
|
unset port_build
|
|
|
|
unset port_install
|
|
|
|
unset port_uninstall
|
|
|
|
|
2022-10-23 14:44:50 +00:00
|
|
|
export DESTDIR=${DESTDIR:-"$LUNA_ROOT/initrd"}
|
|
|
|
|
|
|
|
export listdir=$PWD
|
|
|
|
|
|
|
|
if [ -z $1 ]
|
|
|
|
then
|
|
|
|
echo "Usage: add-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 "Building $pkgname version $pkgver..."
|
|
|
|
|
|
|
|
cd $workdir
|
|
|
|
|
|
|
|
if ! [ -d $srcdir ]
|
|
|
|
then
|
|
|
|
mkdir -p $setupdir
|
|
|
|
cd $setupdir
|
|
|
|
|
|
|
|
echo "Downloading $pkgname version $pkgver..."
|
|
|
|
|
|
|
|
case $pkgmode in
|
|
|
|
"web") wget $pkgurl;;
|
|
|
|
"git") git clone $pkgurl;;
|
|
|
|
*) echo "Don't know how to download package mode '$pkgmode'"; exit 1;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
command -v port_unpack >/dev/null
|
|
|
|
if [ "$?" = "0" ]
|
|
|
|
then
|
|
|
|
echo "Unpacking $pkgname version $pkgver..."
|
|
|
|
port_unpack
|
|
|
|
fi
|
|
|
|
|
|
|
|
command -v port_patch >/dev/null
|
|
|
|
if [ "$?" = "0" ]
|
|
|
|
then
|
|
|
|
echo "Patching $pkgname version $pkgver..."
|
|
|
|
port_patch
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $workdir
|
|
|
|
|
|
|
|
mkdir -p $builddir
|
|
|
|
cd $builddir
|
|
|
|
|
|
|
|
command -v port_configure >/dev/null
|
|
|
|
if [ "$?" = "0" ]
|
|
|
|
then
|
|
|
|
echo "Configuring $pkgname version $pkgver..."
|
|
|
|
port_configure
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Making $pkgname version $pkgver..."
|
|
|
|
port_build # this one is required
|
|
|
|
|
|
|
|
cd $workdir
|
|
|
|
|
|
|
|
mkdir -p $installdir
|
|
|
|
cd $installdir
|
|
|
|
|
|
|
|
echo "Installing $pkgname version $pkgver..."
|
|
|
|
port_install
|
|
|
|
|
2022-10-23 15:15:38 +00:00
|
|
|
if ! [ "$SKIP_ADD_TO_PORTS_LIST" = "1" ]
|
|
|
|
then
|
|
|
|
echo "$pkgname" >> $listdir/ports.list
|
|
|
|
cat $listdir/ports.list | sort | uniq | tee $listdir/ports.list >/dev/null # avoid duplicates
|
2022-10-23 14:44:50 +00:00
|
|
|
|
2022-10-23 15:15:38 +00:00
|
|
|
echo "Success! Registered port: $pkgname version $pkgver."
|
|
|
|
fi
|