浏览代码

Rewrite deciveConfigPri-dir

Joachim M. Giæver 3 年之前
父节点
当前提交
642dcf9caf
共有 2 个文件被更改,包括 22 次插入13 次删除
  1. 14 13
      snap/snapcraft.yaml
  2. 8 0
      src/hooks/post-refresh

+ 14 - 13
snap/snapcraft.yaml

@@ -36,9 +36,9 @@ assumes:
   - command-chain
 
 architectures:
-  - build-on: amd64
+  # - build-on: amd64
   - build-on: arm64
-  - build-on: armhf
+  # - build-on: armhf
 
 apps:
   zwavejs2mqtt:
@@ -98,20 +98,19 @@ parts:
       - jq
     override-build: |
       set -x
-      #sed -i 's/"zwave-js".*$/"zwave-js"\: "8.3.2-0-pr-3262-f5cdbca"/g' ${SNAPCRAFT_PART_BUILD}/package.json
-      printenv
+      sed -i 's/"zwave-js".*$/"zwave-js"\: "v8.5.1-beta.1"/g' ${SNAPCRAFT_PART_BUILD}/package.json
       if [ -n "${http_proxy-}" ]; then
-        export GLOBAL_AGENT_HTTP_PROXY="${http_proxy}"
         yarn config set httpProxy "${http_proxy}"
-        export GLOBAL_AGENT_HTTPS_PROXY="${http_proxy}"
-        yarn config set httpsProxy "${http_proxy}"
       fi
-      yarn install --immutable
+      if [ -n "${https_proxy-}" ]; then
+        yarn config set httpsProxy "${https_proxy}"
+      fi
+      yarn install
       yarn run build \
-        && yarn remove $(cat $SNAPCRAFT_PART_INSTALL/package.json | jq -r '.devDependencies | keys | join(" ")') \
-        && mkdir -p $SNAPCRAFT_PART_INSTALL/lib/node_modules \
-        && cp --archive --link --no-dereference $SNAPCRAFT_PART_BUILD \
-          $SNAPCRAFT_PART_INSTALL/lib/node_modules/zwavejs2mqtt \
+        && yarn remove $(cat "${SNAPCRAFT_PART_INSTALL}/package.json" | jq -r '.devDependencies | keys | join(" ")') \
+        && mkdir -p "${SNAPCRAFT_PART_INSTALL}/lib/node_modules" \
+        && cp --archive --link --no-dereference "${SNAPCRAFT_PART_BUILD}" \
+          "${SNAPCRAFT_PART_INSTALL}/lib/node_modules/zwavejs2mqtt" \
     organize:
       lib/node_modules/zwavejs2mqtt/dist: lib/node_modules/zwavejs2mqtt/server/dist
       lib/node_modules/zwavejs2mqtt/views: lib/node_modules/zwavejs2mqtt/server/views
@@ -137,7 +136,8 @@ parts:
       - git
       - udev
       - rsync
-      - musl-dev
+    override-stage:
+      snapcraftctl stage
   nodejs:
     plugin: dump
     source:
@@ -149,6 +149,7 @@ parts:
         - libatomic1
     override-stage: |
       npm install --global yarn
+      #yarn set version berry
       snapcraftctl stage
     organize:
       '*.md' : nodejs/

+ 8 - 0
src/hooks/post-refresh

@@ -11,3 +11,11 @@ source $SNAP/helper/functions
 # fi
 
 test_default_config
+
+# Update deviceConfigPriorityDir to match new revision
+PRIORITY_DIR=$(echo "$(sed -E "s#$(dirname ${SNAP_DATA})/(current|[0-9]+)#${SNAP_DATA}#g" <<< $(cat "${SNAP_DATA}/settings.json" | jq '.zwave.deviceConfigPriorityDir'))" | tr -d '"')
+
+if [ -d $(dirname "${PRIORITY_DIR}") ]; then
+    jq --arg deviceConfigPriorityDir ${PRIORITY_DIR} '.zwave.deviceConfigPriorityDir = $deviceConfigPriorityDir' $SNAP_DATA/settings.json > $SNAP_DATA/tmp.json
+    mv $SNAP_DATA/tmp.json $SNAP_DATA/settings.json
+fi