From 572ec38b08c296a37ee64dafab8759f22f2681c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E6=9C=94?= <565183519@qq.com> Date: Fri, 4 Sep 2026 02:18:26 +0800 Subject: [PATCH] fix(guanghu-os): make Chengyan provisioning idempotent --- .../provision-jd-chengyan-pncc-slot.sh | 31 ++++++++++--------- .../test-provision-jd-chengyan-pncc-slot.sh | 3 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/product-source/hololake-platform/guanghu-os/scripts/provision-jd-chengyan-pncc-slot.sh b/product-source/hololake-platform/guanghu-os/scripts/provision-jd-chengyan-pncc-slot.sh index a42834802..027b70f4a 100644 --- a/product-source/hololake-platform/guanghu-os/scripts/provision-jd-chengyan-pncc-slot.sh +++ b/product-source/hololake-platform/guanghu-os/scripts/provision-jd-chengyan-pncc-slot.sh @@ -20,26 +20,27 @@ readonly runtime=/usr/local/libexec/guanghu/pncc-runtime.mjs grep -Fq '"personaId": "ICE-P-CY0903"' "$source_dir/.hololake/persona/manifest.json" grep -Fq 'primaryNode": "JD-FD-PRIMARY"' "$source_dir/.hololake/persona/manifest.json" +install -d -o guanghu -g guanghu -m 0700 "$receipt_root" if [[ -e $destination ]]; then - echo "CHENGYAN_PNCC_REFUSED destination_exists=$destination" >&2 - exit 1 + [[ -d $destination && ! -L $destination ]] + diff -qr --exclude=.git "$source_dir" "$destination" >/dev/null +else + install -d -o guanghu -g guanghu -m 0700 "$destination" + cp -a "$source_dir"/. "$destination"/ + find "$destination" -type d -exec chmod 0700 {} + + find "$destination" -type f -exec chmod 0600 {} + + chown -R guanghu:guanghu "$destination" + + runuser -u guanghu -- git -C "$destination" init -q + runuser -u guanghu -- git -C "$destination" config user.name '澄言 / ICE-P-CY0903' + runuser -u guanghu -- git -C "$destination" config user.email 'ice-p-cy0903@persona.hololake.local' + runuser -u guanghu -- git -C "$destination" add --all + runuser -u guanghu -- git -C "$destination" commit -q -m 'establish Chengyan PNCC source slot' fi - -install -d -o guanghu -g guanghu -m 0700 "$destination" "$receipt_root" -cp -a "$source_dir"/. "$destination"/ -find "$destination" -type d -exec chmod 0700 {} + -find "$destination" -type f -exec chmod 0600 {} + -chown -R guanghu:guanghu "$destination" - -runuser -u guanghu -- git -C "$destination" init -q -runuser -u guanghu -- git -C "$destination" config user.name '澄言 / ICE-P-CY0903' -runuser -u guanghu -- git -C "$destination" config user.email 'ice-p-cy0903@persona.hololake.local' -runuser -u guanghu -- git -C "$destination" add --all -runuser -u guanghu -- git -C "$destination" commit -q -m 'establish Chengyan PNCC source slot' head=$(runuser -u guanghu -- git -C "$destination" rev-parse HEAD) tree=$(runuser -u guanghu -- git -C "$destination" rev-parse HEAD^{tree}) inspection=$(runuser -u guanghu -- /usr/bin/node "$runtime" inspect --repository "$destination" --node-id "$node_id") -printf '%s\n' "$inspection" | grep -Fq '"personaId":"ICE-P-CY0903"' +printf '%s\n' "$inspection" | python3 -c 'import json,sys; d=json.load(sys.stdin); assert d["personaId"]=="ICE-P-CY0903" and d["state"]=="PERSONA_REPOSITORY_BOUND_CARRIER_SEPARATE"' cat >"$receipt_root/PROVISION-RECEIPT.hldp" </dev/null for path in brain/ENTRY.hldp brain/B0.hldp checkpoints/CURRENT.hldp organs/read-current-self.hldp bindings/identity.hldp; do [[ -s $persona/$path ]]