Fix chemoi init to work with /tmp noexec

This commit is contained in:
Lockszmith (@kateryna) 2025-03-11 08:08:29 -04:00
parent 634455175a
commit e05ac4411f
3 changed files with 12 additions and 5 deletions

View File

@ -2,6 +2,7 @@
# It collects information about the system in order to determine
# which of the _home.* dirs will be set as the .chezmoiroot
#
{{- $scriptTempDir := "~/.cache/chezmoi/tmp" }}
{{- $chassisType := "desktop" }}
{{- $sysType := "posix" }}
{{- if eq .chezmoi.os "darwin" }}
@ -18,7 +19,10 @@
{{- $chassisType = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "if ((Get-CimInstance -Class Win32_Battery | Measure-Object).Count -gt 0) { Write-Output 'laptop' } else { Write-Output 'desktop' }") | trim }}
{{- end }}
scriptTempDir={{- $scriptTempDir | quote }}
[scriptEnv]
CZ_CHASSIS="{{- $chassisType }}"
CZ_SYS="{{- $sysType }}"
CZ_OS="{{- .chezmoi.os }}"
CZ_SCRIPT_TEMPDIR={{- $scriptTempDir | quote }}
CZ_CHASSIS={{- $chassisType | quote }}
CZ_SYS={{- $sysType | quote }}
CZ_OS={{- .chezmoi.os | quote }}

View File

@ -2,9 +2,9 @@
set -e
#env | grep -E 'chezmoi|^CZ'
env | grep -E 'chezmoi|^CZ'
cd "$CHEZMOI_SOURCE_DIR"
CZ_MODEL="$(ioreg -l | grep "product-name" | sed -Ee 's/^.*\<"(.*)\"\>.*$/\1/')"
#CZ_MODEL="$(ioreg -l | grep "product-name" | sed -Ee 's/^.*\<"(.*)\"\>.*$/\1/')"
set | grep '^CZ_'
printf 'System detected as %s/%s, setting up .chezmoiroot and initializing...\n' "$CZ_SYS" "$CZ_CHASSIS"
if [ -r "base.chezmoiroot.$CZ_SYS.$CZ_CHASSIS" ]; then

View File

@ -4,6 +4,9 @@
{{- $gitEmail := promptStringOnce . "gitEmail" "email address (for git commits)" -}}
{{- $gitName := promptStringOnce . "gitName" "Full name (for git commits)" -}}
{{- $scriptTempDir := "~/.cache/chezmoi/tmp" }}
scriptTempDir={{- $scriptTempDir | quote }}
[data]
{{- if ($sysname) }}
sysname = {{ $sysname | quote }}