oh-my-devpod 0.15.5 → 0.15.6

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.5",
3
+ "version": "0.15.6",
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.5
1
+ 0.15.6
package/runtime/bin/omd CHANGED
Binary file
@@ -201,14 +201,6 @@ trusted_prefix_resolved() {
201
201
  printf '%s\n' "${resolved}"
202
202
  }
203
203
 
204
- trusted_prefixes_equivalent() {
205
- local first="$1" second="$2" first_resolved second_resolved
206
- [[ "${first}" == /* && "${second}" == /* ]] || return 1
207
- first_resolved="$(trusted_prefix_resolved "${first}")" || return 1
208
- second_resolved="$(trusted_prefix_resolved "${second}")" || return 1
209
- [[ "${first_resolved}" == "${second_resolved}" ]]
210
- }
211
-
212
204
  prepare_prefix_parent() {
213
205
  if path_has_no_symlink_components "$(dirname "${prefix}")"; then
214
206
  ensure_safe_parent "${prefix}"
@@ -509,41 +501,25 @@ write_inventory_record() {
509
501
  mv -f "${temporary}" "${destination}"
510
502
  }
511
503
 
512
- legacy_formula_is_managed() {
513
- local owner_home="$1" formula="$2" owner_uid="${3:-}" marker marker_prefix
514
- marker="${owner_home}/.local/state/oh-my-devpod/managed/${formula}"
515
- [[ -f "${marker}" && ! -L "${marker}" ]] || return 1
516
- if [[ "${test_mode}" != "1" && -n "${owner_uid}" ]]; then
517
- [[ "$(stat_uid "${marker}")" == "${owner_uid}" ]] || return 1
518
- fi
519
- grep -qx 'managed_by=oh-my-devpod' "${marker}" || return 1
520
- grep -Fqx "component=${formula}" "${marker}" || return 1
521
- grep -qx 'kind=brew-formula' "${marker}" || return 1
522
- grep -Fqx "artifact=${formula}" "${marker}" || return 1
523
- marker_prefix="$(sed -n 's/^brew_prefix=//p' "${marker}")"
524
- [[ -n "${marker_prefix}" ]] || return 1
525
- trusted_prefixes_equivalent "${marker_prefix}" "${prefix}"
526
- }
527
-
528
504
  stage_legacy_inventory() {
529
- local owner_home="$1" owner_uid="$2" installation_id="$3" staging="$4" formula state provenance
505
+ local installation_id="$1" staging="$2" formula
530
506
  mkdir -p "${staging}"
531
507
  [[ -d "${prefix}/Cellar" ]] || return 0
532
508
  while IFS= read -r formula; do
533
509
  [[ -n "${formula}" ]] || continue
534
- state=external
535
- provenance=legacy-preexisting
536
- if legacy_formula_is_managed "${owner_home}" "${formula}" "${owner_uid}"; then
537
- state=managed
538
- provenance=legacy-marker
539
- fi
540
- write_inventory_record "${formula}" "${installation_id}" "${state}" "${provenance}" "${staging}/${formula}"
510
+ write_inventory_record "${formula}" "${installation_id}" managed legacy-managed-prefix "${staging}/${formula}"
541
511
  done < <(find "${prefix}/Cellar" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | LC_ALL=C sort -u)
542
512
  }
543
513
 
544
514
  legacy_inventory_record_is_recoverable() {
545
- local record="$1" formula="$2" installation_id="$3"
515
+ local record="$1" formula="$2" installation_id="$3" service_uid="$4" service_gid="$5" mode
546
516
  [[ -f "${record}" && ! -L "${record}" ]] || return 1
517
+ if [[ "${test_mode}" != "1" ]]; then
518
+ [[ "$(stat_uid "${record}")" == "${service_uid}" && "$(stat_gid "${record}")" == "${service_gid}" ]] || return 1
519
+ mode="$(stat_mode "${record}")" || return 1
520
+ [[ "${mode}" =~ ^[0-7]{3,4}$ ]] || return 1
521
+ (( (8#${mode} & 8#022) == 0 )) || return 1
522
+ fi
547
523
  grep -qx 'managed_by=oh-my-devpod' "${record}" || return 1
548
524
  grep -Fqx "component=${formula}" "${record}" || return 1
549
525
  grep -qx 'kind=brew-formula' "${record}" || return 1
@@ -554,33 +530,8 @@ legacy_inventory_record_is_recoverable() {
554
530
  grep -qx 'provenance=legacy-preexisting' "${record}"
555
531
  }
556
532
 
557
- member_identity_for_recovery() {
558
- local record="$1" user uid home mode current_uid current_home
559
- [[ -f "${record}" && ! -L "${record}" ]] || return 1
560
- user="$(basename "${record}")"
561
- valid_account_name "${user}" || return 1
562
- if [[ "${test_mode}" != "1" ]]; then
563
- [[ "$(stat_uid "${record}")" == "0" && "$(stat_gid "${record}")" == "0" ]] || return 1
564
- mode="$(stat_mode "${record}")" || return 1
565
- [[ "${mode}" =~ ^[0-7]{3,4}$ ]] || return 1
566
- (( (8#${mode} & 8#022) == 0 )) || return 1
567
- fi
568
- grep -qx 'managed_by=oh-my-devpod' "${record}" || return 1
569
- grep -Fqx "user=${user}" "${record}" || return 1
570
- uid="$(sed -n 's/^uid=//p' "${record}")"
571
- home="$(sed -n 's/^home=//p' "${record}")"
572
- [[ "${uid}" =~ ^[0-9]+$ ]] || return 1
573
- [[ "${home}" == /* && -d "${home}" && ! -L "${home}" ]] || return 1
574
- if [[ "${test_mode}" != "1" ]]; then
575
- current_uid="$(id -u "${user}" 2>/dev/null)" || return 1
576
- current_home="$(passwd_home "${user}")"
577
- [[ "${uid}" == "${current_uid}" && "${home}" == "${current_home}" ]] || return 1
578
- fi
579
- printf '%s\t%s\n' "${uid}" "${home}"
580
- }
581
-
582
533
  recover_legacy_inventory() {
583
- local installation_id service_uid service_gid record formula member identity member_uid member_home recovered
534
+ local installation_id service_uid service_gid record formula recovered
584
535
  installation_id="$(manifest_value installation_id || true)"
585
536
  [[ -n "${installation_id}" ]] || return 0
586
537
  service_uid="$(account_uid "${service_user}")"
@@ -588,21 +539,14 @@ recover_legacy_inventory() {
588
539
  while IFS= read -r -d '' record; do
589
540
  formula="$(basename "${record}")"
590
541
  valid_formula_name "${formula}" || continue
591
- legacy_inventory_record_is_recoverable "${record}" "${formula}" "${installation_id}" || continue
592
- while IFS= read -r -d '' member; do
593
- identity="$(member_identity_for_recovery "${member}" || true)"
594
- [[ -n "${identity}" ]] || continue
595
- IFS=$'\t' read -r member_uid member_home <<< "${identity}"
596
- legacy_formula_is_managed "${member_home}" "${formula}" "${member_uid}" || continue
597
- recovered="${inventory_dir}/.${formula}.recovered.$$"
598
- write_inventory_record "${formula}" "${installation_id}" managed legacy-marker-recovered "${recovered}"
599
- chmod 0644 "${recovered}"
600
- if [[ "${test_mode}" != "1" ]]; then
601
- chown "${service_uid}:${service_gid}" "${recovered}"
602
- fi
603
- mv -f "${recovered}" "${record}"
604
- break
605
- done < <(find "${members_dir}" -mindepth 1 -maxdepth 1 -type f -print0)
542
+ legacy_inventory_record_is_recoverable "${record}" "${formula}" "${installation_id}" "${service_uid}" "${service_gid}" || continue
543
+ recovered="${inventory_dir}/.${formula}.recovered.$$"
544
+ write_inventory_record "${formula}" "${installation_id}" managed legacy-managed-prefix-recovered "${recovered}"
545
+ chmod 0644 "${recovered}"
546
+ if [[ "${test_mode}" != "1" ]]; then
547
+ chown "${service_uid}:${service_gid}" "${recovered}"
548
+ fi
549
+ mv -f "${recovered}" "${record}"
606
550
  done < <(find "${inventory_dir}" -mindepth 1 -maxdepth 1 -type f -print0)
607
551
  }
608
552
 
@@ -672,7 +616,7 @@ initialize_shared_state() {
672
616
  if [[ -e "${prefix}" || -L "${prefix}" ]]; then
673
617
  legacy_info="$(validate_legacy_prefix)"
674
618
  IFS=$'\t' read -r legacy_owner legacy_uid legacy_gid legacy_home <<< "${legacy_info}"
675
- stage_legacy_inventory "${legacy_home}" "${legacy_uid}" "${installation_id}" "${inventory_staging}"
619
+ stage_legacy_inventory "${installation_id}" "${inventory_staging}"
676
620
  else
677
621
  created_prefix=1
678
622
  if ! initialize_prefix "${mirror_profile}"; then