oh-my-devpod 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-devpod",
3
- "version": "0.15.3",
3
+ "version": "0.15.4",
4
4
  "description": "Ubuntu productivity tool manager with the omd terminal interface",
5
5
  "license": "MIT",
6
6
  "author": "zhangdw156",
package/runtime/VERSION CHANGED
@@ -1 +1 @@
1
- 0.15.3
1
+ 0.15.4
package/runtime/bin/omd CHANGED
Binary file
@@ -8,6 +8,7 @@ bin_dir="${OHMYDEVPOD_BIN_DIR:-${HOME}/.local/bin}"
8
8
  target_arch="${TARGETARCH:-}"
9
9
  repo="oschina/gitee-cli"
10
10
  staged_path=""
11
+ tar_version=""
11
12
 
12
13
  fail() {
13
14
  printf 'error: %s\n' "$*" >&2
@@ -110,7 +111,12 @@ actual_sha="$(sha256_file "${archive_path}")"
110
111
 
111
112
  extract_dir="${tmp_dir}/extract"
112
113
  mkdir -p "${extract_dir}"
113
- tar -xzf "${archive_path}" -C "${extract_dir}" gitee ||
114
+ tar_extract_args=(-xzf "${archive_path}" -C "${extract_dir}")
115
+ tar_version="$(tar --version 2>/dev/null || true)"
116
+ if [[ "${tar_version%%$'\n'*}" == *"GNU tar"* ]]; then
117
+ tar_extract_args=(--warning=no-unknown-keyword "${tar_extract_args[@]}")
118
+ fi
119
+ tar "${tar_extract_args[@]}" gitee ||
114
120
  fail "failed to extract Gitee CLI binary"
115
121
  [[ -f "${extract_dir}/gitee" && ! -L "${extract_dir}/gitee" ]] ||
116
122
  fail "release archive does not contain a regular gitee binary"
@@ -377,8 +377,12 @@ install_policy() {
377
377
  profile_tmp="${profile_file}.tmp.$$"
378
378
  {
379
379
  printf '%s\n' '# Generated by oh-my-devpod. Shared Linuxbrew gateway.'
380
- printf 'case ":$PATH:" in *":%s:"*) ;; *) PATH="%s:$PATH" ;; esac\n' "${libexec_dir}/bin" "${libexec_dir}/bin"
381
- printf '%s\n' 'export PATH'
380
+ printf '%s\n' 'case " $(id -nG 2>/dev/null) " in'
381
+ printf ' *" %s "*)\n' "${manager_group}"
382
+ printf ' PATH="%s:%s/bin:%s/sbin:$PATH"\n' "${libexec_dir}/bin" "${prefix}" "${prefix}"
383
+ printf '%s\n' ' export PATH'
384
+ printf '%s\n' ' ;;'
385
+ printf '%s\n' 'esac'
382
386
  } > "${profile_tmp}"
383
387
  chmod 0644 "${profile_tmp}"
384
388
  if [[ "${test_mode}" != "1" ]]; then chown root:root "${profile_tmp}"; fi
@@ -237,6 +237,9 @@ omd_install_archive() {
237
237
  omd_warn "Shared Linuxbrew activation failed; restored the previous omd release"
238
238
  return 1
239
239
  fi
240
+ if ! omd_repair_managed_login_shell_if_present "${release_dir}"; then
241
+ omd_warn "Updated omd, but could not repair the managed login shell; run omd to retry"
242
+ fi
240
243
  [[ -z "${previous_dir}" ]] || rm -rf "${previous_dir}" || true
241
244
  printf '%s\n' "${version}"
242
245
  }
@@ -430,6 +433,25 @@ omd_activate_shared_linuxbrew_profile_if_present() {
430
433
  bash -c 'set -euo pipefail; source "$1"; omd_shared_linuxbrew_activate_if_present "$2" "$3"' _ "${helper}" "${release_root}" "${profile}"
431
434
  }
432
435
 
436
+ omd_repair_managed_login_shell_if_present() {
437
+ local release_root="$1" postflight managed_dir marker managed=0
438
+ managed_dir="${OHMYDEVPOD_MANAGED_DIR:-${OHMYDEVPOD_STATE_DIR:-${XDG_STATE_HOME:-${HOME}/.local/state}/oh-my-devpod}/managed}"
439
+ for marker in "${managed_dir}/zsh" "${managed_dir}/zsh-config"; do
440
+ if [[ -f "${marker}" && ! -L "${marker}" ]] &&
441
+ grep -Fqx 'managed_by=oh-my-devpod' "${marker}"; then
442
+ managed=1
443
+ break
444
+ fi
445
+ done
446
+ [[ "${managed}" == "1" ]] || return 0
447
+ postflight="${release_root}/modules/lib/postflight.sh"
448
+ [[ -f "${postflight}" && ! -L "${postflight}" ]] || {
449
+ omd_warn "Installed release cannot repair an existing managed login shell"
450
+ return 1
451
+ }
452
+ bash "${postflight}" repair-login-shell >&2
453
+ }
454
+
433
455
  omd_activate_shared_linuxbrew_if_present() {
434
456
  local release_root="$1" source="$2" profile
435
457
  profile="$(omd_source_mirror_profile "${source}")" || return 1
@@ -448,6 +448,16 @@ omd_module_zsh_path() {
448
448
  command -v zsh
449
449
  }
450
450
 
451
+ omd_module_target_user() {
452
+ if [[ -n "${OHMYDEVPOD_TARGET_USER:-}" ]]; then
453
+ printf '%s\n' "${OHMYDEVPOD_TARGET_USER}"
454
+ elif [[ "$(id -u)" -eq 0 && -n "${SUDO_USER:-}" ]]; then
455
+ printf '%s\n' "${SUDO_USER}"
456
+ else
457
+ id -un
458
+ fi
459
+ }
460
+
451
461
  omd_module_set_login_shell() {
452
462
  local zsh_path="$1" target_user current_shell shells_file sudo_bin
453
463
  [[ -x "${zsh_path}" ]] || {
@@ -455,7 +465,7 @@ omd_module_set_login_shell() {
455
465
  return 1
456
466
  }
457
467
 
458
- target_user="${OHMYDEVPOD_TARGET_USER:-${SUDO_USER:-$(id -un)}}"
468
+ target_user="$(omd_module_target_user)"
459
469
  shells_file="${OHMYDEVPOD_SHELLS_FILE:-/etc/shells}"
460
470
  sudo_bin="${OHMYDEVPOD_SUDO_BIN:-sudo}"
461
471
  if [[ -n "${OHMYDEVPOD_CURRENT_SHELL:-}" ]]; then
@@ -5,23 +5,26 @@ source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
5
5
  # shellcheck source=source-config.sh
6
6
  source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/source-config.sh"
7
7
 
8
- case "${1:-}" in
9
- install|update) ;;
8
+ action="${1:-}"
9
+ case "${action}" in
10
+ install|update|repair-login-shell) ;;
10
11
  *) omd_module_unknown_action "${1:-}" ;;
11
12
  esac
12
13
 
13
- case "${OHMYDEVPOD_MIRROR_PROFILE:-upstream}" in
14
- cn) source_name="gitee" ;;
15
- upstream) source_name="github" ;;
16
- *)
17
- omd_module_info notice "unknown mirror profile; native source configuration was not changed"
18
- source_name=""
19
- ;;
20
- esac
21
- if [[ -n "${source_name}" ]] &&
22
- ! omd_source_config_apply_transactional "${source_name}"; then
23
- omd_module_info error "failed to apply native source configuration"
24
- exit 1
14
+ if [[ "${action}" != "repair-login-shell" ]]; then
15
+ case "${OHMYDEVPOD_MIRROR_PROFILE:-upstream}" in
16
+ cn) source_name="gitee" ;;
17
+ upstream) source_name="github" ;;
18
+ *)
19
+ omd_module_info notice "unknown mirror profile; native source configuration was not changed"
20
+ source_name=""
21
+ ;;
22
+ esac
23
+ if [[ -n "${source_name}" ]] &&
24
+ ! omd_source_config_apply_transactional "${source_name}"; then
25
+ omd_module_info error "failed to apply native source configuration"
26
+ exit 1
27
+ fi
25
28
  fi
26
29
 
27
30
  if ! omd_module_is_managed zsh && ! omd_module_is_managed zsh-config; then