Merge pull request #298 from aatchison/feature/remove-build-scripts

Feature/remove build scripts
pull/301/head
Arron Atchison 2016-07-21 12:19:43 -05:00 committed by GitHub
commit 6efdbaf97c
10 changed files with 0 additions and 599 deletions

View File

@ -1,9 +0,0 @@
Package: %%PACKAGE%%
Version: %%VERSION%%
Section: base
Priority: optional
Architecture: %%ARCHITECTURE%%
Depends: %%DEPENDS%%
Maintainer: Arron Atchison <arron.atchison@mycroft.ai>
Description: %%DESCRIPTION%%

View File

@ -1,69 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: %%NAME%%
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: %%DESCRIPTION%%
### END INIT INFO
# Ported from https://gist.github.com/naholyr/4275302
SCRIPT=%%COMMAND%%
RUNAS=%%USERNAME%%
PIDFILE=/var/run/%%NAME%%.pid
LOGFILE=/var/log/%%NAME%%.log
start() {
if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting service…' >&2
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping service…' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
uninstall() {
echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
local SURE
read SURE
if [ "$SURE" = "yes" ]; then
stop
rm -f "$PIDFILE"
echo "Notice: log file is not be removed: '$LOGFILE'" >&2
update-rc.d -f %%NAME%% remove
rm -fv "$0"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
uninstall)
uninstall
;;
retart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|uninstall}"
esac

View File

@ -1,66 +0,0 @@
#!/bin/bash
ARCH="$(name -m 2>/dev/null || dpkg --print-architecture || uname -m 2>/dev/null || echo "unknown")"
function initialize_service() {
local NAME=$1
chmod a+x /etc/init.d/${NAME}
update-rc.d ${NAME} defaults
touch /var/log/${NAME}.log
chown %%INSTALL_USER%% /var/log/${NAME}.log
}
function start_service() {
local NAME=$1
invoke-rc.d ${NAME} start
}
ARTIFACT_HOST="http://bootstrap.mycroft.ai"
ENCLOSURE_VERSION_FILE="/opt/enclosure-version.txt"
# check for previously installed Arduino enclosure version
function check_enclosure_version_file() {
if [ -f $ENCLOSURE_VERSION_FILE ]; then
echo "A previous Enclosure installation is present"
ENCLOSURE_VERSION=`cat ${ENCLOSURE_VERSION_FILE}`
else
echo "Enclosure version file is not present"
exit 1
fi
}
function upload_hex() {
if curl --output /dev/null --silent --head --fail "${ARTIFACT_HOST}/artifacts/armhf/enclosure/${ENCLOSURE_VERSION}/enclosure-armhf-${ENCLOSURE_VERSION}.tar.gz"; then
wget -q --continue "${ARTIFACT_HOST}/artifacts/armhf/enclosure/${ENCLOSURE_VERSION}/enclosure-armhf-${ENCLOSURE_VERSION}.tar.gz"
mkdir -p /opt/enclosure
tar -xzf enclosure-armhf-${ENCLOSURE_VERSION}.tar.gz -C /opt/enclosure
cd /opt/enclosure
if [ ! -e /opt/avrdude/bin/avrdude ]; then
./install-avrdude.sh
fi
./upload.sh
else
echo "Enclosure Artifact does not exist"
fi
}
if [ ${ARCH} = "armhf" ]; then
check_enclosure_version_file
upload_hex
fi
initialize_service "mycroft-messagebus"
initialize_service "mycroft-skills"
initialize_service "mycroft-speech-client"
start_service "mycroft-messagebus"
start_service "mycroft-skills"
start_service "mycroft-speech-client"
if [ ${ARCH} = "armhf" ]; then
start_service "mycroft-enclosure-client"
initialize_service "mycroft-enclosure-client"
fi

View File

@ -1,10 +0,0 @@
#!/bin/bash
#if [ "$1" = purge ]; then
# deluser %%INSTALL_USER%% input
# deluser %%INSTALL_USER%% audio
# deluser %%INSTALL_USER%% dialout
# userdel %%INSTALL_USER%%
# if [ -e /home/%%INSTALL_USER%% ]; then
# rm -R /home/%%INSTALL_USER%%
# fi
#fi

View File

@ -1,34 +0,0 @@
#!/bin/bash
function stop_service() {
local NAME=$1
invoke-rc.d ${NAME} stop
}
# shutdown existing services
if [[ -f "/etc/init.d/mycroft-speech-client" ]]; then
stop_service "mycroft-speech-client"
fi
if [[ -f "/etc/init.d/mycroft-skills" ]]; then
stop_service "mycroft-skills"
fi
if [[ -f "/etc/init.d/mycroft-messagebus" ]]; then
stop_service "mycroft-messagebus"
fi
if [[ -f "/etc/init.d/mycroft-enclosure-client" ]]; then
/etc/init.d/mycroft-enclosure-client stop
fi
id -u %%INSTALL_USER%% &>/dev/null || useradd %%INSTALL_USER%%
adduser %%INSTALL_USER%% input
adduser %%INSTALL_USER%% audio
adduser %%INSTALL_USER%% dialout
if [ ! -d /home/%%INSTALL_USER%% ]; then
mkdir -p /home/%%INSTALL_USER%%
chown -R %%INSTALL_USER%%:%%INSTALL_USER%% /home/%%INSTALL_USER%%
fi

View File

@ -1,22 +0,0 @@
#!/bin/bash
# shutdown existing services
function stop_service() {
local NAME=$1
invoke-rc.d ${NAME} stop
}
if [[ -f "/etc/init.d/mycroft-speech-client" ]]; then
stop_service "mycroft-speech-client"
fi
if [[ -f "/etc/init.d/mycroft-skills" ]]; then
stop_service "mycroft-skills"
fi
if [[ -f "/etc/init.d/mycroft-messagebus" ]]; then
stop_service "mycroft-messagebus"
fi
if [[ -f "/etc/init.d/mycroft-enclosure-client" ]]; then
stop_service "mycroft-enclosure-client"
fi

View File

@ -1,169 +0,0 @@
#!/usr/bin/env bash
TOP=$(cd $(dirname $0)/.. && pwd -L)
if [ "$1" = "-q" ]; then
QUIET="echo"
fi
# clean
cd ${TOP}
rm -rf dist
function _run() {
if [[ "$QUIET" ]]; then
echo "$*"
else
eval "$@"
fi
}
function python_package() {
local SETUP_SCRIPT=$1
cp ${SETUP_SCRIPT} ${TOP}/setup.py
python ${TOP}/setup.py clean
python ${TOP}/setup.py bdist_egg
python ${TOP}/setup.py sdist
_run python ${TOP}/setup.py sdist upload -r mycroft
rm ${TOP}/setup.py
}
VERSION="$(basename $(git describe --abbrev=0 --tags) | sed -e 's/v//g')"
echo "version=\"${VERSION}\"" > ${TOP}/mycroft/__version__.py
# build and upload pypi distribution to internal pypi mirror
cd ${TOP}
python_package mycroft-base-setup.py
python_package skills-sdk-setup.py
# build distributable virtualenv
ARCH="$(dpkg --print-architecture)"
SYSTEM_TARGET="/usr/local/"
ARTIFACT_BASE="mycroft-core-${ARCH}-${VERSION}"
MYCROFT_ARTIFACT_DIR=${TOP}/build/${ARTIFACT_BASE}
virtualenv --always-copy --clear ${MYCROFT_ARTIFACT_DIR}
virtualenv --always-copy --clear --relocatable ${MYCROFT_ARTIFACT_DIR}
. ${MYCROFT_ARTIFACT_DIR}/bin/activate
pip install -r ${TOP}/requirements.txt
cd ${TOP}/pocketsphinx-python
python setup.py install
cd ${TOP}
python mycroft-base-setup.py install
${TOP}/install-pygtk.sh
virtualenv --always-copy --relocatable ${MYCROFT_ARTIFACT_DIR}
mkdir -p ${TOP}/dist
cd ${TOP}/build
tar -czf ${TOP}/dist/${ARTIFACT_BASE}.tar.gz ${ARTIFACT_BASE}
# package distributable virtualenv into deb
function replace() {
local FILE=$1
local PATTERN=$2
local VALUE=$3
local TMP_FILE="/tmp/$$.replace"
cat ${FILE} | sed -e "s/${PATTERN}/${VALUE}/g" > ${TMP_FILE}
mv ${TMP_FILE} ${FILE}
}
DEB_BASE="mycroft-core-${ARCH}_${VERSION}-1"
DEB_DIR=${TOP}/build/${DEB_BASE}
mkdir -p ${DEB_DIR}/DEBIAN
echo "Creating debian control file"
# setup control file
CONTROL_FILE=${DEB_DIR}/DEBIAN/control
cp ${TOP}/publish-core/deb_base/control.template ${CONTROL_FILE}
replace ${CONTROL_FILE} "%%PACKAGE%%" "mycroft-core"
replace ${CONTROL_FILE} "%%VERSION%%" "${VERSION}"
replace ${CONTROL_FILE} "%%ARCHITECTURE%%" "${ARCH}"
replace ${CONTROL_FILE} "%%DESCRIPTION%%" "mycroft-core"
replace ${CONTROL_FILE} "%%DEPENDS%%" "portaudio19-dev, libglib2.0-0, flac, espeak, mpg123, mimic, avrdude"
echo "Creating debian preinst file"
PREINST_FILE=${DEB_DIR}/DEBIAN/preinst
cp ${TOP}/publish-core/deb_base/preinst.template ${PREINST_FILE}
replace ${PREINST_FILE} "%%INSTALL_USER%%" "mycroft"
chmod 0755 ${PREINST_FILE}
echo "Creating debian postinst file"
POSTINST_FILE=${DEB_DIR}/DEBIAN/postinst
cp ${TOP}/publish-core/deb_base/postinst.template ${POSTINST_FILE}
replace ${POSTINST_FILE} "%%INSTALL_USER%%" "mycroft"
chmod 0755 ${POSTINST_FILE}
echo "Creating debian prerm file"
PRERM_FILE=${DEB_DIR}/DEBIAN/prerm
cp ${TOP}/publish-core/deb_base/prerm.template ${PRERM_FILE}
replace ${PRERM_FILE} "%%INSTALL_USER%%" "mycroft"
chmod 0755 ${PRERM_FILE}
echo "Creating debian postrm file"
POSTRM_FILE=${DEB_DIR}/DEBIAN/postrm
cp ${TOP}/publish-core/deb_base/postrm.template ${POSTRM_FILE}
replace ${POSTRM_FILE} "%%INSTALL_USER%%" "mycroft"
chmod 0755 ${POSTRM_FILE}
# setup init scripts
function setup_init_script() {
local NAME=$1
echo "Creating init script for ${NAME}"
INIT_SCRIPT=${DEB_DIR}/etc/init.d/${NAME}
mkdir -p $(dirname ${INIT_SCRIPT})
cp ${TOP}/publish-core/deb_base/init.template ${INIT_SCRIPT}
replace ${INIT_SCRIPT} "%%NAME%%" "${NAME}"
replace ${INIT_SCRIPT} "%%DESCRIPTION%%" "${NAME}"
replace ${INIT_SCRIPT} "%%COMMAND%%" "\/usr\/local\/bin\/${NAME}"
replace ${INIT_SCRIPT} "%%USERNAME%%" "mycroft"
chmod a+x ${INIT_SCRIPT}
}
setup_init_script "mycroft-messagebus"
setup_init_script "mycroft-skills"
setup_init_script "mycroft-speech-client"
if [ ${ARCH} = "armhf" ]; then
setup_init_script "mycroft-enclosure-client"
fi
mkdir -p ${DEB_DIR}/${SYSTEM_TARGET}
cp -rf ${TOP}/build/${ARTIFACT_BASE}/* ${DEB_DIR}/${SYSTEM_TARGET}
mkdir -p ${DEB_DIR}/etc/mycroft
# write installed config file
cat > ${DEB_DIR}/etc/mycroft/mycroft.ini << EOM
[tts]
module = "mimic"
mimic.path = "/usr/local/bin/mimic"
mimic.voice = "ap"
[metrics_client]
enabled = True
EOM
#if [ ${ARCH} = "armhf" ]; then
# ensures enclosure version
ENCLOSURE_DIR=${DEB_DIR}/opt
mkdir -p ${ENCLOSURE_DIR}
cp ${TOP}/mycroft/client/enclosure/version.txt ${ENCLOSURE_DIR}/enclosure-version.txt
#fi
cd $(dirname ${DEB_DIR})
dpkg-deb --build ${DEB_BASE}
mv *.deb ${TOP}/dist
cd ${TOP}/dist
_run s3cmd -c ${HOME}/.s3cfg.mycroft-artifact-writer sync --acl-public . s3://bootstrap.mycroft.ai/artifacts/apt/${ARCH}/${VERSION}/
echo ${VERSION} > latest
_run s3cmd -c ${HOME}/.s3cfg.mycroft-artifact-writer put --acl-public ${TOP}/dist/latest s3://bootstrap.mycroft.ai/artifacts/apt/${ARCH}/latest #cd ${TOP}/dist
#_run s3cmd -c ${HOME}/.s3cfg.mycroft-artifact-writer sync --acl-public . s3://bootstrap.mycroft.ai/artifacts/${ARCH}/${VERSION}/
#echo ${VERSION} > ${TOP}/dist/latest
#_run s3cmd -c ${HOME}/.s3cfg.mycroft-artifact-writer put --acl-public ${TOP}/dist/latest s3://bootstrap.mycroft.ai/artifacts/${ARCH}/latest

View File

@ -1,9 +0,0 @@
Package: %%PACKAGE%%
Version: %%VERSION%%
Section: base
Priority: optional
Architecture: %%ARCHITECTURE%%
Depends: portaudio19-dev, libglib2.0-0, flac, espeak, mpg123, libffi-dev, libssl-dev
Maintainer: Sean Fitzgerald <sean.fitzgerald@mycroft.ai>
Description: %%DESCRIPTION%%

View File

@ -1,69 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: %%NAME%%
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: %%DESCRIPTION%%
### END INIT INFO
# Ported from https://gist.github.com/naholyr/4275302
SCRIPT=%%COMMAND%%
RUNAS=%%USERNAME%%
PIDFILE=/var/run/%%NAME%%.pid
LOGFILE=/var/log/%%NAME%%.log
start() {
if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting service…' >&2
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping service…' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
uninstall() {
echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
local SURE
read SURE
if [ "$SURE" = "yes" ]; then
stop
rm -f "$PIDFILE"
echo "Notice: log file is not be removed: '$LOGFILE'" >&2
update-rc.d -f %%NAME%% remove
rm -fv "$0"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
uninstall)
uninstall
;;
retart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|uninstall}"
esac

View File

@ -1,142 +0,0 @@
#!/usr/bin/env bash
TOP=$(cd $(dirname $0)/.. && pwd -L)
if [ "$1" = "-q" ]; then
QUIET="echo"
fi
# clean
cd ${TOP}
rm -rf dist
function _run() {
if [[ "$QUIET" ]]; then
echo "$*"
else
eval "$@"
fi
}
function python_package() {
local SETUP_SCRIPT=$1
cp ${SETUP_SCRIPT} ${TOP}/setup.py
python ${TOP}/setup.py clean
python ${TOP}/setup.py bdist_egg
python ${TOP}/setup.py sdist
_run python ${TOP}/setup.py sdist upload -r mycroft
rm ${TOP}/setup.py
}
VERSION="$(basename $(git describe --abbrev=0 --tags) | sed -e 's/v//g')"
echo "version=\"${VERSION}\"" > ${TOP}/mycroft/__version__.py
# build and upload pypi distribution to internal pypi mirror
cd ${TOP}
python_package mycroft-base-setup.py
python_package skills-sdk-setup.py
# build distributable virtualenv
ARCH="$(dpkg --print-architecture)"
ARTIFACT_BASE="mycroft-standalone-${ARCH}-${VERSION}"
MYCROFT_ARTIFACT_DIR=${TOP}/build/${ARTIFACT_BASE}
virtualenv --always-copy --clear ${MYCROFT_ARTIFACT_DIR}
virtualenv --always-copy --clear --relocatable ${MYCROFT_ARTIFACT_DIR}
. ${MYCROFT_ARTIFACT_DIR}/bin/activate
pip install -r ${TOP}/requirements.txt --trusted-host pypi.mycroft.team
cd ${TOP}/pocketsphinx-python
python setup.py install
cd ${TOP}
python mycroft-base-setup.py install
${TOP}/install-pygtk.sh
virtualenv --always-copy --relocatable ${MYCROFT_ARTIFACT_DIR}
mkdir -p ${TOP}/dist
cd ${TOP}/build
tar -czf ${TOP}/dist/${ARTIFACT_BASE}.tar.gz ${ARTIFACT_BASE}
# package distributable virtualenv into deb
function replace() {
local FILE=$1
local PATTERN=$2
local VALUE=$3
local TMP_FILE="/tmp/$$.replace"
cat ${FILE} | sed -e "s/${PATTERN}/${VALUE}/g" > ${TMP_FILE}
mv ${TMP_FILE} ${FILE}
}
DEB_BASE="mycroft-standalone_${VERSION}-1"
DEB_DIR=${TOP}/build/${DEB_BASE}
mkdir -p ${DEB_DIR}/DEBIAN
echo "Creating debian control file"
# setup control file
CONTROL_FILE=${DEB_DIR}/DEBIAN/control
cp ${TOP}/publish/deb_base/control.template ${CONTROL_FILE}
replace ${CONTROL_FILE} "%%PACKAGE%%" "mycroft-standalone"
replace ${CONTROL_FILE} "%%VERSION%%" "${VERSION}"
replace ${CONTROL_FILE} "%%ARCHITECTURE%%" "${ARCH}"
replace ${CONTROL_FILE} "%%DESCRIPTION%%" "mycroft-standalone"
# setup init scripts
function setup_init_script() {
local NAME=$1
echo "Creating init script for ${NAME}"
INIT_SCRIPT=${DEB_DIR}/etc/init.d/${NAME}
mkdir -p $(dirname ${INIT_SCRIPT})
cp ${TOP}/publish/deb_base/init.template ${INIT_SCRIPT}
replace ${INIT_SCRIPT} "%%NAME%%" "${NAME}"
replace ${INIT_SCRIPT} "%%DESCRIPTION%%" "${NAME}"
replace ${INIT_SCRIPT} "%%COMMAND%%" "\/opt\/mycroft\/bin\/${NAME}"
replace ${INIT_SCRIPT} "%%USERNAME%%" "mycroft"
chmod a+x ${INIT_SCRIPT}
}
setup_init_script "mycroft-messagebus"
setup_init_script "mycroft-skills"
setup_init_script "mycroft-speech-client"
setup_init_script "mycroft-enclosure-client"
mkdir -p ${DEB_DIR}/opt/mycroft
cp -rf ${TOP}/build/${ARTIFACT_BASE}/* ${DEB_DIR}/opt/mycroft
# install mimic
${TOP}/install-mimic.sh
MIMIC_INSTALL_DIR="${DEB_DIR}/opt/mycroft/bin"
mkdir -p ${MIMIC_INSTALL_DIR}
cp -rf ${TOP}/build/mimic/bin/mimic ${MIMIC_INSTALL_DIR}
mkdir -p ${DEB_DIR}/etc/mycroft
# write installed config file
cat > ${DEB_DIR}/etc/mycroft/mycroft.ini << EOM
[tts]
module = "mimic"
mimic.path = "/opt/mycroft/bin/mimic"
mimic.voice = "ap"
[metrics_client]
enabled = True
EOM
# ensures enclosure version
ENCLOSURE_DIR=${DEB_DIR}/opt/enclosure
mkdir -p ${ENCLOSURE_DIR}
cp ${TOP}/mycroft/client/enclosure/version.txt ${ENCLOSURE_DIR}
cd $(dirname ${DEB_DIR})
dpkg-deb --build ${DEB_BASE}
mv *.deb ${TOP}/dist
cd ${TOP}/dist
_run s3cmd -c ${HOME}/.s3cfg.mycroft-artifact-writer sync --acl-public . s3://bootstrap.mycroft.ai/artifacts/${ARCH}/${VERSION}/
echo ${VERSION} > ${TOP}/dist/latest
_run s3cmd -c ${HOME}/.s3cfg.mycroft-artifact-writer put --acl-public ${TOP}/dist/latest s3://bootstrap.mycroft.ai/artifacts/${ARCH}/latest