Luna/tools/package-helper.sh

97 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
source $(dirname $0)/env.sh
cd $LUNA_ROOT
SUBCOMMAND=$1
PORT_NAME=$2
if [ "$SUBCOMMAND" = "help" ]; then
echo "TODO: add help"
exit 1
fi
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
export preserve_workdir=1
export WORKDIR=$LUNA_ROOT/ports/dev
case $SUBCOMMAND in
download)
export skip_configure=1
export skip_build=1
export skip_install=1
export skip_dependencies=1
export skip_patch=1
tools/make-package.sh $PORT_NAME
if [ "$format" = "tar" ]; then
cd ${srcdir:-$WORKDIR/$name-$version}
git init
git add .
git commit -m "Temporary development git repository for diffs."
cd $LUNA_ROOT
fi
echo "Created dev source tree in ${srcdir:-$WORKDIR/$name-$version}."
;;
setup-dependencies)
export skip_download_sources=1
export skip_build=1
export skip_install=1
export skip_configure=1
export skip_patch=1
tools/make-package.sh $PORT_NAME
;;
patch)
export skip_download_sources=1
export skip_build=1
export skip_install=1
export skip_configure=1
export skip_dependencies=1
tools/make-package.sh $PORT_NAME
;;
configure)
export skip_download_sources=1
export skip_build=1
export skip_install=1
export skip_dependencies=1
export skip_patch=1
tools/make-package.sh $PORT_NAME
;;
compile)
export skip_download_sources=1
export skip_configure=1
export skip_dependencies=1
export skip_patch=1
tools/make-package.sh $PORT_NAME
echo "Packaged dev build as $LUNA_ROOT/ports/out/$name-$version.tar.gz. Install it using tools/install-package.sh."
;;
generate-diff)
cd ${srcdir:-$WORKDIR/$name-$version}
git add -N .
git diff > $LUNA_ROOT/ports/$name/$name.patch
echo "Created $LUNA_ROOT/ports/$name/$name.patch. Remember to add patching code to the PACKAGE file!"
;;
cleanup)
rm -rfv $WORKDIR/*$name*
;;
*)
echo "No such subcommand. Run 'tools/package-helper.sh help $name' for help."
;;
esac