diff options
author | Jonas Heinrich | 2019-02-09 19:25:11 +0100 |
---|---|---|
committer | Jonas Heinrich | 2019-02-09 19:25:11 +0100 |
commit | 0a2dd7f52592b59f1a904e6e0a70b3f04cc247b6 (patch) | |
tree | 39bcd2984312dd43c91c474725586c0d3caefffe | |
parent | 7c810e2c3de60ba844a35679c827b3bdab31b6ce (diff) | |
download | aur-0a2dd7f52592b59f1a904e6e0a70b3f04cc247b6.tar.gz |
add headless mode
-rw-r--r-- | .SRCINFO | 8 | ||||
-rw-r--r-- | PKGBUILD | 12 | ||||
-rw-r--r-- | avs-alexa-sampleapp.install | 2 | ||||
-rw-r--r-- | avs-alexa-sampleapp.service | 2 | ||||
-rw-r--r-- | headless.patch | 163 |
5 files changed, 178 insertions, 9 deletions
@@ -1,9 +1,9 @@ # Generated by mksrcinfo v8 -# Fri Feb 8 12:36:07 UTC 2019 +# Sat Feb 9 18:25:01 UTC 2019 pkgbase = avs-alexa-sampleapp pkgdesc = Alexa sample app originally packaged with the AVS SDK pkgver = 1.11 - pkgrel = 3 + pkgrel = 4 url = https://github.com/alexa/avs-device-sdk install = avs-alexa-sampleapp.install arch = any @@ -17,10 +17,12 @@ pkgbase = avs-alexa-sampleapp source = CMakeLists.txt_1 source = CMakeLists.txt_2 source = avs-alexa-sampleapp.service + source = headless.patch sha512sums = 8ddac6a258c8bc054e4eac3a65da1626294112c88da18e50d7359d980c380b392d0c81f5ac1f5faaceca7d19a72b408708a7f4d247246d5f6f24390b5236b1aa sha512sums = 085f58cc2c2a9947e9887ab9fd14497ec2238781821a19decea61496501a5d54d958fbd4372abefae6be8f8540d1b846dce84f1a17b736132e8a6adc3bfe613a sha512sums = cdb9c17b5ba872aaa0c098af910fd74dd769c96909980d0143b0a02b0442db3cec7385cfb5c489b583db25ecd92b2fc53e613a59bf2a643cd3213e1981132504 - sha512sums = 2809638f18a91d37cd773ef2b62b294780e11e2cfa570e6fbfc7bf4b86741b96f1e990cd04acc472f8303472ac12d52e9088b26e47a7fb228de7fd8ab495be5b + sha512sums = 1d272b710e631fcd3526e8aa453a9283f7b113406a863e675c7a9dd2ee211e9a241e8514c3d85327e297c202a923e5909917c3ada4ff8594e68aaf5d0e0c0721 + sha512sums = 3b87661cece96ed3a9c8fbdb34d5da256613090c6282ba20a16c84be5223023b60fcf3033020a3afbdcee7fb652aa6466dcaa47a02f27ff90496e8b2338f47f7 pkgname = avs-alexa-sampleapp @@ -3,7 +3,7 @@ pkgname=avs-alexa-sampleapp pkgver=1.11 -pkgrel=3 +pkgrel=4 pkgdesc="Alexa sample app originally packaged with the AVS SDK" arch=('any') url="https://github.com/alexa/avs-device-sdk" @@ -13,17 +13,21 @@ depends=('portaudio' 'gstreamer' 'gst-plugins-base-libs' 'avs-device-sdk') source=("${pkgname}-${pkgver}.tar.gz::https://github.com/alexa/avs-device-sdk/archive/v${pkgver}.tar.gz" "CMakeLists.txt_1" "CMakeLists.txt_2" - "avs-alexa-sampleapp.service") + "avs-alexa-sampleapp.service" + "headless.patch") sha512sums=('8ddac6a258c8bc054e4eac3a65da1626294112c88da18e50d7359d980c380b392d0c81f5ac1f5faaceca7d19a72b408708a7f4d247246d5f6f24390b5236b1aa' '085f58cc2c2a9947e9887ab9fd14497ec2238781821a19decea61496501a5d54d958fbd4372abefae6be8f8540d1b846dce84f1a17b736132e8a6adc3bfe613a' 'cdb9c17b5ba872aaa0c098af910fd74dd769c96909980d0143b0a02b0442db3cec7385cfb5c489b583db25ecd92b2fc53e613a59bf2a643cd3213e1981132504' - '2809638f18a91d37cd773ef2b62b294780e11e2cfa570e6fbfc7bf4b86741b96f1e990cd04acc472f8303472ac12d52e9088b26e47a7fb228de7fd8ab495be5b') + '1d272b710e631fcd3526e8aa453a9283f7b113406a863e675c7a9dd2ee211e9a241e8514c3d85327e297c202a923e5909917c3ada4ff8594e68aaf5d0e0c0721' + '3b87661cece96ed3a9c8fbdb34d5da256613090c6282ba20a16c84be5223023b60fcf3033020a3afbdcee7fb652aa6466dcaa47a02f27ff90496e8b2338f47f7') install="avs-alexa-sampleapp.install" prepare() { cd "${srcdir}" cp "CMakeLists.txt_1" "avs-device-sdk-${pkgver}/SampleApp/CMakeLists.txt" cp "CMakeLists.txt_2" "avs-device-sdk-${pkgver}/SampleApp/src/CMakeLists.txt" + cd "avs-device-sdk-${pkgver}/SampleApp" + patch -p1 < "${srcdir}/headless.patch" } build() { @@ -43,7 +47,7 @@ build() { -DPORTAUDIO=ON \ -DPORTAUDIO_LIB_PATH="/usr/lib/libportaudio.so" \ -DPORTAUDIO_INCLUDE_DIR="/usr/include" - make -j4 + make } package() { diff --git a/avs-alexa-sampleapp.install b/avs-alexa-sampleapp.install index 42d5d6148066..eaa2e1983185 100644 --- a/avs-alexa-sampleapp.install +++ b/avs-alexa-sampleapp.install @@ -1,5 +1,5 @@ post_install() { - getent passwd alexa > /dev/null || useradd -d /var/lib/avs-alexa-sampleapp alexa > /dev/null + getent passwd alexa > /dev/null || useradd -d /var/lib/avs-alexa-sampleapp -G audio alexa > /dev/null getent group alexa > /dev/null || groupadd -r alexa > /dev/null chown alexa:alexa -R /var/lib/avs-alexa-sampleapp } diff --git a/avs-alexa-sampleapp.service b/avs-alexa-sampleapp.service index 98526c484d16..835ef5aa9b30 100644 --- a/avs-alexa-sampleapp.service +++ b/avs-alexa-sampleapp.service @@ -5,7 +5,7 @@ After=network.target [Service] User=alexa Type=simple -ExecStart=/usr/bin/avs-alexa-sampleapp /var/lib/avs-alexa-sampleapp/AlexaClientSDKConfig.json +ExecStart=/usr/bin/avs-alexa-sampleapp -C /var/lib/avs-alexa-sampleapp/AlexaClientSDKConfig.json -K /usr/share/snowboy/resources --headless [Install] WantedBy=multi-user.target diff --git a/headless.patch b/headless.patch new file mode 100644 index 000000000000..d56908b35b2f --- /dev/null +++ b/headless.patch @@ -0,0 +1,163 @@ +diff -ux '*.txt' -r SampleApp_org/include/SampleApp/SampleApplication.h SampleApp_patched/include/SampleApp/SampleApplication.h +--- SampleApp_org/include/SampleApp/SampleApplication.h 2018-12-19 20:13:36.000000000 +0100 ++++ SampleApp_patched/include/SampleApp/SampleApplication.h 2019-02-09 13:43:59.973245132 +0100 +@@ -67,7 +67,8 @@ + std::shared_ptr<alexaClientSDK::sampleApp::ConsoleReader> consoleReader, + const std::vector<std::string>& configFiles, + const std::string& pathToInputFolder, +- const std::string& logLevel = ""); ++ const std::string& logLevel = "", ++ bool headless = false); + + /** + * Runs the application, blocking until the user asks the application to quit or a device reset is triggered. +@@ -158,7 +159,8 @@ + std::shared_ptr<alexaClientSDK::sampleApp::ConsoleReader> consoleReader, + const std::vector<std::string>& configFiles, + const std::string& pathToInputFolder, +- const std::string& logLevel); ++ const std::string& logLevel, ++ bool headless); + + /** + * Create an application media player. +diff -ux '*.txt' -r SampleApp_org/include/SampleApp/UserInputManager.h SampleApp_patched/include/SampleApp/UserInputManager.h +--- SampleApp_org/include/SampleApp/UserInputManager.h 2018-12-19 20:13:36.000000000 +0100 ++++ SampleApp_patched/include/SampleApp/UserInputManager.h 2019-02-09 13:43:59.973245132 +0100 +@@ -43,7 +43,8 @@ + */ + static std::unique_ptr<UserInputManager> create( + std::shared_ptr<InteractionManager> interactionManager, +- std::shared_ptr<ConsoleReader> consoleReader); ++ std::shared_ptr<ConsoleReader> consoleReader, ++ bool headless); + + /** + * Processes user input until a quit command or a device reset is triggered. +@@ -63,7 +64,8 @@ + */ + UserInputManager( + std::shared_ptr<InteractionManager> interactionManager, +- std::shared_ptr<ConsoleReader> consoleReader); ++ std::shared_ptr<ConsoleReader> consoleReader, ++ bool headless); + + /** + * Reads an input from the console. This is a blocking call until an input is read from the console or if m_restart +@@ -127,6 +129,8 @@ + /// the app. + std::atomic_bool m_limitedInteraction; + ++ bool headless; ++ + /// Flag to indicate that the @c run() should stop and return @c SampleAppReturnCode::RESTART. + std::atomic_bool m_restart; + }; +diff -ux '*.txt' -r SampleApp_org/src/main.cpp SampleApp_patched/src/main.cpp +--- SampleApp_org/src/main.cpp 2018-12-19 20:13:36.000000000 +0100 ++++ SampleApp_patched/src/main.cpp 2019-02-09 13:43:59.976578511 +0100 +@@ -51,6 +51,7 @@ + std::vector<std::string> configFiles; + std::string pathToKWDInputFolder; + std::string logLevel; ++ bool headless = false; + + if (usesOptStyleArgs(argc, argv)) { + for (int i = 1; i < argc; i++) { +@@ -73,6 +74,8 @@ + return SampleAppReturnCode::ERROR; + } + logLevel = std::string(argv[++i]); ++ } else if (strcmp(argv[i], "--headless") == 0) { ++ headless = true; + } else { + ConsolePrinter::simplePrint( + "USAGE: " + std::string(argv[0]) + " -C <config1.json> -C <config2.json> ... -C <configN.json> " + +@@ -114,7 +117,7 @@ + SampleAppReturnCode returnCode = SampleAppReturnCode::OK; + + do { +- sampleApplication = SampleApplication::create(consoleReader, configFiles, pathToKWDInputFolder, logLevel); ++ sampleApplication = SampleApplication::create(consoleReader, configFiles, pathToKWDInputFolder, logLevel, headless); + if (!sampleApplication) { + ConsolePrinter::simplePrint("Failed to create to SampleApplication!"); + return SampleAppReturnCode::ERROR; +diff -ux '*.txt' -r SampleApp_org/src/SampleApplication.cpp SampleApp_patched/src/SampleApplication.cpp +--- SampleApp_org/src/SampleApplication.cpp 2018-12-19 20:13:36.000000000 +0100 ++++ SampleApp_patched/src/SampleApplication.cpp 2019-02-09 13:43:59.976578511 +0100 +@@ -202,9 +202,10 @@ + std::shared_ptr<alexaClientSDK::sampleApp::ConsoleReader> consoleReader, + const std::vector<std::string>& configFiles, + const std::string& pathToInputFolder, +- const std::string& logLevel) { ++ const std::string& logLevel, ++ const bool headless) { + auto clientApplication = std::unique_ptr<SampleApplication>(new SampleApplication); +- if (!clientApplication->initialize(consoleReader, configFiles, pathToInputFolder, logLevel)) { ++ if (!clientApplication->initialize(consoleReader, configFiles, pathToInputFolder, logLevel, headless)) { + ACSDK_CRITICAL(LX("Failed to initialize SampleApplication")); + return nullptr; + } +@@ -321,7 +322,8 @@ + std::shared_ptr<alexaClientSDK::sampleApp::ConsoleReader> consoleReader, + const std::vector<std::string>& configFiles, + const std::string& pathToInputFolder, +- const std::string& logLevel) { ++ const std::string& logLevel, ++ bool headless) { + /* + * Set up the SDK logging system to write to the SampleApp's ConsolePrinter. Also adjust the logging level + * if requested. +@@ -854,7 +856,7 @@ + #endif + + // Creating the input observer. +- m_userInputManager = alexaClientSDK::sampleApp::UserInputManager::create(m_interactionManager, consoleReader); ++ m_userInputManager = alexaClientSDK::sampleApp::UserInputManager::create(m_interactionManager, consoleReader, headless); + if (!m_userInputManager) { + ACSDK_CRITICAL(LX("Failed to create UserInputManager!")); + return false; +diff -ux '*.txt' -r SampleApp_org/src/UserInputManager.cpp SampleApp_patched/src/UserInputManager.cpp +--- SampleApp_org/src/UserInputManager.cpp 2018-12-19 20:13:36.000000000 +0100 ++++ SampleApp_patched/src/UserInputManager.cpp 2019-02-09 13:43:59.976578511 +0100 +@@ -96,7 +96,8 @@ + + std::unique_ptr<UserInputManager> UserInputManager::create( + std::shared_ptr<InteractionManager> interactionManager, +- std::shared_ptr<ConsoleReader> consoleReader) { ++ std::shared_ptr<ConsoleReader> consoleReader, ++ bool headless) { + if (!interactionManager) { + ACSDK_CRITICAL(LX("Invalid InteractionManager passed to UserInputManager")); + return nullptr; +@@ -107,15 +108,17 @@ + return nullptr; + } + +- return std::unique_ptr<UserInputManager>(new UserInputManager(interactionManager, consoleReader)); ++ return std::unique_ptr<UserInputManager>(new UserInputManager(interactionManager, consoleReader, headless)); + } + + UserInputManager::UserInputManager( + std::shared_ptr<InteractionManager> interactionManager, +- std::shared_ptr<ConsoleReader> consoleReader) : ++ std::shared_ptr<ConsoleReader> consoleReader, ++ bool headless) : + m_interactionManager{interactionManager}, + m_consoleReader{consoleReader}, + m_limitedInteraction{false}, ++ headless{headless}, + m_restart{false} { + } + +@@ -132,6 +135,10 @@ + bool userTriggeredLogout = false; + m_interactionManager->begin(); + while (true) { ++ if (headless) { ++ std::this_thread::sleep_for(std::chrono::hours(100)); ++ continue; ++ } + char x; + if (!readConsoleInput(&x)) { + break; |