Add support for manage deps folder (#273)

* Add support for manage deps folder

* Update Dockerfile

* Update run.sh

* Update run.sh

* Update run.sh

* Update Dockerfile

* Add files via upload

* Create CHANGELOG.md
This commit is contained in:
Pascal Vizeli
2018-03-27 22:15:28 +02:00
committed by GitHub
parent 1a0d5e85ae
commit 48f007bd46
5 changed files with 68 additions and 0 deletions

4
custom_deps/CHANGELOG.md Normal file
View File

@@ -0,0 +1,4 @@
# Changelog
## 0.1
- Initial release

15
custom_deps/Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
ARG BUILD_FROM
FROM $BUILD_FROM
# Add env
ENV LANG C.UTF-8
# Setup base
RUN apk add --no-cache \
jq python3 gcc g++ make cmake git python3-dev
# Copy data
COPY run.sh /
RUN chmod a+x /run.sh
CMD [ "/run.sh" ]

19
custom_deps/config.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "Custom deps deployment",
"version": "0.1",
"slug": "custom_deps",
"description": "Manage custom python modules in Home Assistant deps",
"url": "https://home-assistant.io/addons/custom_deps/",
"startup": "once",
"boot": "manual",
"map": ["config:rw"],
"options": {
"pypi": [],
"apk": []
},
"schema": {
"pypi": ["str"],
"apk": ["str"]
},
"image": "homeassistant/{arch}-addon-custom_deps"
}

BIN
custom_deps/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

30
custom_deps/run.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
set -e
CONFIG_PATH=/data/options.json
PYPI=$(jq --raw-output ".pypi[]" $CONFIG_PATH)
APK=$(jq --raw-output ".apk[] // empy" $CONFIG_PATH)
# Cleanup old deps
echo "[Info] Remove old deps"
rm -rf /config/deps/*
# Need custom apk for build?
if [ ! -z "$APK" ]; then
echo "[Info] Install apks for build"
if ! ERROR="$(apk add --no-cache "${APK[@]}")"; then
echo "[Error] Can't install packages!"
echo "$ERROR" && exit 1
fi
fi
# Install pypi modules
echo "[Info] Install pypi modules into deps"
export PYTHONUSERBASE=/config/deps
if ! ERROR="$(pip3 install --user --no-cache-dir --no-dependencies "${PYPI[@]}")"; then
echo "[Error] Can't install pypi packages!"
echo "$ERROR" && exit 1
fi
echo "[Info] done"