Skip to content

Instantly share code, notes, and snippets.

@gierdo
Last active November 22, 2017 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gierdo/05503381f26dcd3556c4fd1661db1545 to your computer and use it in GitHub Desktop.
Save gierdo/05503381f26dcd3556c4fd1661db1545 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
getopt --test > /dev/null
if [[ $? -ne 4 ]]; then
echo "I’m sorry, `getopt --test` failed in this environment."
exit 1
fi
set -o errexit
set -o pipefail
set +o nounset
set +o xtrace
# Set magic variable for current dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OPTIONS=b,r,i,h
LONGOPTIONS=build,remove,install,help
PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@")
if [[ $? -ne 0 ]]; then
exit 2
fi
eval set -- "$PARSED"
while true; do
case "$1" in
-b|--build)
build=y
shift
;;
-r|--remove)
remove=y
shift
;;
-i|--install)
install=y
shift
;;
-h|--help)
showHelp=y
shift
;;
--)
shift
break
;;
*)
echo "Programming error"
exit 3
;;
esac
done
function showHelp {
echo "This script builds an installs dptf for ubuntu linux."
echo "Options:"
echo "-b | --build: build dptf"
echo "-r | --remove: Uninstall dptf"
echo "-i | --install: Install dptf"
echo "-h | --help: show this help"
exit 0
}
function build {
(
pushd DPTF/Linux/build
cmake ..
make -j 4
popd
pushd ESIF/Products/ESIF_UF/Linux
make
popd
pushd ESIF/Products/ESIF_CMP/Linux
make
popd
pushd ESIF/Products/ESIF_WS/Linux
make
popd
)
}
function install {
(
pushd DPTF/Linux/build/x64/release
sudo mkdir -p /usr/share/dptf/ufx64
sudo cp Dptf*.so /usr/share/dptf/ufx64
popd
pushd ESIF/Packages/DSP
sudo mkdir -p /etc/dptf
sudo cp dsp.dv /etc/dptf
popd
pushd ESIF/Products/ESIF_UF/Linux
sudo cp esif_ufd /usr/bin
popd
pushd ESIF/Products/ESIF_CMP/Linux
sudo cp esif_cmp.so /usr/share/dptf/ufx64
popd
pushd ESIF/Products/ESIF_WS/Linux
sudo cp esif_ws.so /usr/share/dptf/ufx64
popd
pushd ESIF/Packages/Installers/linux/
sudo cp dptf.service /lib/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable dptf
sudo systemctl start dptf
popd
)
}
function remove {
(
set +o errexit
set +o pipefail
sudo systemctl stop dptf
sudo systemctl disable dptf
sudo rm /lib/systemd/system/dptf.service
sudo systemctl daemon-reload
sudo rm -r /usr/share/dptf/ufx64
sudo rm -r /etc/dptf
sudo rm /usr/bin/esif_ufd
)
}
cd "$__dir"
if [[ $showHelp == y ]]; then
showHelp
fi
if [[ $remove == y ]]; then
remove
fi
if [[ $build == y ]]; then
build
fi
if [[ $install == y ]]; then
install
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment