-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
801 lines (708 loc) · 20.4 KB
/
install.sh
File metadata and controls
801 lines (708 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
#!/usr/bin/env bash
set -euo pipefail
REPO_OWNER="xooooooooox"
REPO_NAME="radp-bash-framework"
tmp_dir=""
# Defaults (overridable by CLI args, then env vars)
OPT_MODE="${RADP_BF_INSTALL_MODE:-auto}"
OPT_REF="${RADP_BF_REF:-}"
OPT_VERSION="${RADP_BF_VERSION:-}"
OPT_INSTALL_DIR="${RADP_BF_INSTALL_DIR:-}"
OPT_BIN_DIR="${RADP_BF_BIN_DIR:-}"
# ============================================================================
# Logging
# ============================================================================
log() {
printf "%s\n" "$*"
}
err() {
printf "radp-bash-framework install: %s\n" "$*" >&2
}
die() {
err "$@"
exit 1
}
have() {
command -v "$1" >/dev/null 2>&1
}
# ============================================================================
# Usage
# ============================================================================
usage() {
cat <<'EOF'
radp-bash-framework installer
Usage:
install.sh [OPTIONS]
curl -fsSL .../install.sh | bash -s -- [OPTIONS]
Options:
--ref <ref> Install from a git ref (branch, tag, or SHA).
Implies manual installation. If a package-manager
version is already installed, it is removed first.
--mode <mode> Installation mode (default: auto)
auto - use package manager if available, else manual
manual - always download from GitHub
homebrew - force Homebrew
dnf - force dnf
yum - force yum
apt - force apt
zypper - force zypper
--install-dir <dir> Manual install location
(default: $HOME/.local/lib/radp-bash-framework)
--bin-dir <dir> Symlink location (default: $HOME/.local/bin)
-h, --help Show this help
Environment variables:
RADP_BF_REF Same as --ref
RADP_BF_VERSION Pin to a release version (e.g. v1.0.0)
RADP_BF_INSTALL_MODE Same as --mode
RADP_BF_INSTALL_DIR Same as --install-dir
RADP_BF_BIN_DIR Same as --bin-dir
Examples:
# Default: auto-detect package manager
bash install.sh
# Install latest from main branch (removes pkm version if present)
bash install.sh --ref main
# Install a specific tag via manual download
bash install.sh --ref v1.0.0-rc1
# Force manual mode (latest release)
bash install.sh --mode manual
EOF
}
# ============================================================================
# Argument Parsing
# ============================================================================
parse_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
--ref)
[[ $# -lt 2 ]] && die "--ref requires a value"
OPT_REF="$2"
shift 2
;;
--mode)
[[ $# -lt 2 ]] && die "--mode requires a value"
OPT_MODE="$2"
shift 2
;;
--install-dir)
[[ $# -lt 2 ]] && die "--install-dir requires a value"
OPT_INSTALL_DIR="$2"
shift 2
;;
--bin-dir)
[[ $# -lt 2 ]] && die "--bin-dir requires a value"
OPT_BIN_DIR="$2"
shift 2
;;
-h | --help)
usage
exit 0
;;
*)
die "Unknown option: $1 (use --help for usage)"
;;
esac
done
}
# ============================================================================
# Package Manager Detection and Installation
# ============================================================================
detect_os() {
local os=""
if [[ "${OSTYPE:-}" == darwin* ]]; then
os="macos"
elif [[ -f /etc/os-release ]]; then
# shellcheck disable=SC1091
source /etc/os-release
case "${ID:-}" in
fedora | centos | rhel | rocky | almalinux | ol)
os="rhel"
;;
debian | ubuntu | linuxmint | pop)
os="debian"
;;
opensuse* | sles)
os="suse"
;;
*)
os="linux"
;;
esac
else
os="unknown"
fi
echo "${os}"
}
# Detect available package manager
# Returns: homebrew, dnf, yum, apt, zypper, or empty string
detect_package_manager() {
local os
os="$(detect_os)"
# Homebrew (macOS and Linux)
if have brew; then
echo "homebrew"
return 0
fi
# Linux package managers
case "${os}" in
rhel)
if have dnf; then
echo "dnf"
return 0
elif have yum; then
echo "yum"
return 0
fi
;;
debian)
if have apt-get; then
echo "apt"
return 0
fi
;;
suse)
if have zypper; then
echo "zypper"
return 0
fi
;;
esac
echo ""
}
# Detect if radp-bash-framework is installed via a package manager
# Returns: the pkm name (homebrew, dnf, apt, ...) or empty string
detect_pkm_installed() {
# Homebrew
if have brew && brew list --formula radp-bash-framework &>/dev/null; then
echo "homebrew"
return 0
fi
# RPM-based (dnf/yum)
if have rpm && rpm -q radp-bash-framework &>/dev/null; then
if have dnf; then
echo "dnf"
elif have yum; then
echo "yum"
else
echo "rpm"
fi
return 0
fi
# Debian-based
if have dpkg && dpkg -s radp-bash-framework &>/dev/null; then
echo "apt"
return 0
fi
# zypper
if have zypper && zypper se -i radp-bash-framework &>/dev/null; then
echo "zypper"
return 0
fi
echo ""
}
# Uninstall package-manager-installed version
uninstall_pkm() {
local pkm="$1"
log "Removing package-manager version (${pkm}) to avoid conflicts..."
case "${pkm}" in
homebrew)
brew uninstall radp-bash-framework || return 1
;;
dnf)
sudo dnf remove -y radp-bash-framework || return 1
;;
yum)
sudo yum remove -y radp-bash-framework || return 1
;;
rpm)
sudo rpm -e radp-bash-framework || return 1
;;
apt)
sudo apt-get remove -y radp-bash-framework || return 1
;;
zypper)
sudo zypper remove -y radp-bash-framework || return 1
;;
*)
err "Don't know how to uninstall via: ${pkm}"
return 1
;;
esac
log "Package-manager version removed"
}
# Check if package manager repository is configured
check_repo_configured() {
local pkm="$1"
case "${pkm}" in
homebrew)
# Check if tap is configured
if brew tap 2>/dev/null | grep -q "xooooooooox/radp"; then
return 0
fi
return 1
;;
dnf | yum)
# Check if COPR repo is enabled
if [[ -f /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:xooooooooox:radp.repo ]] ||
[[ -f /etc/yum.repos.d/radp.repo ]]; then
return 0
fi
return 1
;;
apt)
# Check if OBS repo is configured
if [[ -f /etc/apt/sources.list.d/home:xooooooooox:radp.list ]]; then
return 0
fi
return 1
;;
zypper)
# Check if OBS repo is configured
if zypper repos 2>/dev/null | grep -q "xooooooooox"; then
return 0
fi
return 1
;;
esac
return 1
}
# Setup repository for package manager
setup_repo() {
local pkm="$1"
log "Setting up repository for ${pkm}..."
case "${pkm}" in
homebrew)
log "Adding Homebrew tap..."
brew tap xooooooooox/radp
;;
dnf)
log "Enabling COPR repository..."
sudo dnf install -y dnf-plugins-core >/dev/null 2>&1 || true
sudo dnf copr enable -y xooooooooox/radp
;;
yum)
log "Enabling COPR repository..."
sudo yum install -y yum-plugin-copr >/dev/null 2>&1 || true
sudo yum copr enable -y xooooooooox/radp
;;
apt)
log "Adding OBS repository..."
# Detect distro for OBS
local distro=""
if [[ -f /etc/os-release ]]; then
# shellcheck disable=SC1091
source /etc/os-release
case "${ID:-}" in
ubuntu)
distro="xUbuntu_${VERSION_ID}"
;;
debian)
distro="Debian_${VERSION_ID}"
;;
*)
err "Unsupported distribution for apt: ${ID:-unknown}"
return 1
;;
esac
fi
if [[ -z "${distro}" ]]; then
err "Cannot detect distribution for OBS repository"
return 1
fi
echo "deb http://download.opensuse.org/repositories/home:/xooooooooox:/radp/${distro}/ /" |
sudo tee /etc/apt/sources.list.d/home:xooooooooox:radp.list >/dev/null
curl -fsSL "https://download.opensuse.org/repositories/home:xooooooooox:radp/${distro}/Release.key" |
gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_xooooooooox_radp.gpg >/dev/null
sudo apt-get update >/dev/null
;;
zypper)
log "Adding OBS repository..."
# Detect distro for OBS
local distro=""
if [[ -f /etc/os-release ]]; then
# shellcheck disable=SC1091
source /etc/os-release
case "${ID:-}" in
opensuse-tumbleweed)
distro="openSUSE_Tumbleweed"
;;
opensuse-leap)
distro="openSUSE_Leap_${VERSION_ID}"
;;
sles)
distro="SLE_${VERSION_ID}"
;;
*)
err "Unsupported distribution for zypper: ${ID:-unknown}"
return 1
;;
esac
fi
if [[ -z "${distro}" ]]; then
err "Cannot detect distribution for OBS repository"
return 1
fi
sudo zypper addrepo -f "https://download.opensuse.org/repositories/home:/xooooooooox:/radp/${distro}/home:xooooooooox:radp.repo"
;;
*)
err "Unknown package manager: ${pkm}"
return 1
;;
esac
}
# Refresh package manager cache
refresh_cache() {
local pkm="$1"
log "Refreshing package cache..."
case "${pkm}" in
homebrew)
brew update >/dev/null 2>&1 || true
;;
dnf)
sudo dnf clean all >/dev/null 2>&1 || true
sudo dnf makecache >/dev/null 2>&1 || true
;;
yum)
sudo yum clean all >/dev/null 2>&1 || true
sudo yum makecache >/dev/null 2>&1 || true
;;
apt)
sudo apt-get update >/dev/null 2>&1 || true
;;
zypper)
sudo zypper refresh >/dev/null 2>&1 || true
;;
esac
}
# Install using package manager
install_via_pkm() {
local pkm="$1"
# Refresh cache to ensure we get the latest version
refresh_cache "${pkm}"
log "Installing ${REPO_NAME} via ${pkm}..."
case "${pkm}" in
homebrew)
brew install radp-bash-framework
;;
dnf)
sudo dnf install -y radp-bash-framework
;;
yum)
sudo yum install -y radp-bash-framework
;;
apt)
sudo apt-get install -y radp-bash-framework
;;
zypper)
sudo zypper install -y radp-bash-framework
;;
*)
err "Unknown package manager: ${pkm}"
return 1
;;
esac
}
# ============================================================================
# Manual Installation
# ============================================================================
detect_fetcher() {
if have curl; then
echo "curl"
return 0
fi
if have wget; then
echo "wget"
return 0
fi
if have fetch; then
echo "fetch"
return 0
fi
return 1
}
fetch_url() {
local tool="$1"
local url="$2"
local out="$3"
case "${tool}" in
curl)
curl -fsSL "${url}" -o "${out}"
;;
wget)
wget -qO "${out}" "${url}"
;;
fetch)
fetch -qo "${out}" "${url}"
;;
*)
return 1
;;
esac
}
fetch_text() {
local tool="$1"
local url="$2"
case "${tool}" in
curl)
curl -fsSL "${url}"
;;
wget)
wget -qO- "${url}"
;;
fetch)
fetch -qo- "${url}"
;;
*)
return 1
;;
esac
}
resolve_ref() {
if [[ -n "${OPT_REF}" ]]; then
echo "${OPT_REF}"
return 0
fi
if [[ -n "${OPT_VERSION}" ]]; then
echo "${OPT_VERSION}"
return 0
fi
local api_url="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest"
local json
json="$(fetch_text "${FETCH_TOOL}" "${api_url}" || true)"
if [[ -z "${json}" ]]; then
die "Failed to fetch latest release; use --ref <branch|tag> to specify."
fi
local tag
tag="$(sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' <<<"${json}")"
tag="${tag%%$'\n'*}"
if [[ -z "${tag}" ]]; then
die "Failed to parse latest tag; use --ref <branch|tag> to specify."
fi
echo "${tag}"
}
cleanup() {
if [[ -n "${tmp_dir:-}" ]]; then
rm -rf "${tmp_dir}"
fi
}
install_manual() {
FETCH_TOOL="$(detect_fetcher)" || die "Requires curl, wget, or fetch."
local install_dir="${OPT_INSTALL_DIR:-$HOME/.local/lib/${REPO_NAME}}"
local bin_dir="${OPT_BIN_DIR:-$HOME/.local/bin}"
local ref
ref="$(resolve_ref)"
if [[ -z "${install_dir}" || "${install_dir}" == "/" ]]; then
die "Unsafe install dir: ${install_dir}"
fi
if [[ "${RADP_BF_ALLOW_ANY_DIR:-0}" != "1" ]]; then
if [[ "$(basename "${install_dir}")" != "${REPO_NAME}" ]]; then
die "Install dir must end with ${REPO_NAME} (set RADP_BF_ALLOW_ANY_DIR=1 to override)."
fi
fi
local tar_url="https://github.com/${REPO_OWNER}/${REPO_NAME}/archive/${ref}.tar.gz"
tmp_dir="$(mktemp -d 2>/dev/null || mktemp -d -t "${REPO_NAME}")"
local tarball="${tmp_dir}/${REPO_NAME}.tar.gz"
trap cleanup EXIT
log "Downloading ${tar_url}"
if ! fetch_url "${FETCH_TOOL}" "${tar_url}" "${tarball}"; then
die "Failed to download ${tar_url}"
fi
local tar_listing
tar_listing="$(tar -tzf "${tarball}")"
local root_dir="${tar_listing%%/*}"
if [[ -z "${root_dir}" ]]; then
die "Unable to read archive structure."
fi
tar -xzf "${tarball}" -C "${tmp_dir}"
local src_root="${tmp_dir}/${root_dir}"
if [[ ! -d "${src_root}/bin" || ! -d "${src_root}/src/main/shell/framework" ]]; then
die "Archive layout unexpected; missing bin/ or src/main/shell/."
fi
rm -rf "${install_dir}"
mkdir -p "${install_dir}/src/main/shell"
cp -R "${src_root}/bin" "${install_dir}/"
cp -R "${src_root}/src/main/shell/commands" "${install_dir}/src/main/shell/"
cp -R "${src_root}/src/main/shell/config" "${install_dir}/src/main/shell/"
cp -R "${src_root}/src/main/shell/framework" "${install_dir}/src/main/shell/"
cp -R "${src_root}/completions" "${install_dir}/"
chmod 0755 "${install_dir}/bin/radp-bf"
find "${install_dir}/src/main/shell/framework" -type f -name "*.sh" -exec chmod 0755 {} \;
# Write install metadata
echo "${REPO_OWNER}/${REPO_NAME}" >"${install_dir}/.install-repo"
echo "manual" >"${install_dir}/.install-method"
echo "${ref}" >"${install_dir}/.install-ref"
# Write actual installed version for banner display
local installed_version
if [[ "${ref}" =~ ^v[0-9]+\.[0-9]+ ]]; then
# ref is a version tag, use it directly
installed_version="${ref}"
else
# ref is branch/SHA, append to base version from source
local base_version
base_version=$(sed -n 's/^declare -gr gr_fw_version=//p' \
"${install_dir}/src/main/shell/framework/bootstrap/context/vars/constants/constants.sh" 2>/dev/null \
| head -n 1)
[[ -z "$base_version" ]] && base_version="v0.0.0"
installed_version="${base_version}+${ref}"
fi
echo "${installed_version}" >"${install_dir}/.install-version"
mkdir -p "${bin_dir}"
local target="${install_dir}/bin/radp-bf"
local link_path
for link_name in radp-bf radp-bash-framework; do
link_path="${bin_dir}/${link_name}"
if [[ -e "${link_path}" && ! -L "${link_path}" ]]; then
die "Refusing to overwrite existing file: ${link_path}"
fi
ln -sf "${target}" "${link_path}"
done
# Install shell completions
install_completions "${install_dir}"
log ""
log "Installed ${REPO_NAME} (ref: ${ref}) to ${install_dir}"
log "Symlinked to ${bin_dir}/radp-bf and ${bin_dir}/radp-bash-framework"
log "Ensure ${bin_dir} is in your PATH."
log "Run: hash -r && source \"\$(radp-bf path init)\""
}
# ============================================================================
# Shell Completion Installation
# ============================================================================
install_completions() {
local install_dir="$1"
local completions_dir="${install_dir}/completions"
if [[ ! -d "${completions_dir}" ]]; then
log "Completions directory not found, skipping completion installation"
return 0
fi
local bash_completion_installed=false
local zsh_completion_installed=false
# Determine bash completion directory
local bash_comp_dir=""
if [[ -d "${HOME}/.local/share/bash-completion/completions" ]]; then
bash_comp_dir="${HOME}/.local/share/bash-completion/completions"
elif [[ -d "${HOME}/.bash_completion.d" ]]; then
bash_comp_dir="${HOME}/.bash_completion.d"
else
# Create user-local completion directory
mkdir -p "${HOME}/.local/share/bash-completion/completions"
bash_comp_dir="${HOME}/.local/share/bash-completion/completions"
fi
# Install bash completion
if [[ -n "${bash_comp_dir}" && -f "${completions_dir}/radp-bf" ]]; then
cp "${completions_dir}/radp-bf" "${bash_comp_dir}/radp-bf"
bash_completion_installed=true
log "Installed bash completion to ${bash_comp_dir}/radp-bf"
fi
# Determine zsh completion directory
local zsh_comp_dir=""
if [[ -d "${HOME}/.zfunc" ]]; then
zsh_comp_dir="${HOME}/.zfunc"
elif [[ -d "${HOME}/.local/share/zsh/site-functions" ]]; then
zsh_comp_dir="${HOME}/.local/share/zsh/site-functions"
else
# Create user-local zsh completion directory
mkdir -p "${HOME}/.zfunc"
zsh_comp_dir="${HOME}/.zfunc"
fi
# Install zsh completion
if [[ -n "${zsh_comp_dir}" && -f "${completions_dir}/_radp-bf" ]]; then
cp "${completions_dir}/_radp-bf" "${zsh_comp_dir}/_radp-bf"
zsh_completion_installed=true
log "Installed zsh completion to ${zsh_comp_dir}/_radp-bf"
fi
# Provide instructions if zsh fpath might need updating
if [[ "${zsh_completion_installed}" == "true" && "${zsh_comp_dir}" == "${HOME}/.zfunc" ]]; then
if ! grep -q 'fpath=.*\.zfunc' "${HOME}/.zshrc" 2>/dev/null; then
log ""
log "Note: Add the following to your ~/.zshrc for zsh completion:"
log " fpath=(~/.zfunc \$fpath)"
log " autoload -Uz compinit && compinit"
fi
fi
}
# ============================================================================
# Main
# ============================================================================
main() {
parse_args "$@"
local mode="${OPT_MODE}"
# --ref implies manual installation with pkm conflict resolution
if [[ -n "${OPT_REF}" ]]; then
log "Installing from ref: ${OPT_REF}"
# Check for existing package-manager installation and remove it
local existing_pkm
existing_pkm="$(detect_pkm_installed)"
if [[ -n "${existing_pkm}" ]]; then
log "Detected existing package-manager installation (${existing_pkm})"
uninstall_pkm "${existing_pkm}" || die "Failed to remove package-manager version"
fi
install_manual
return 0
fi
local pkm=""
# Determine installation method
case "${mode}" in
manual)
log "Using manual installation (--mode manual)"
install_manual
return 0
;;
homebrew | dnf | yum | apt | zypper)
# Force specific package manager
pkm="${mode}"
if ! have "${pkm}" && [[ "${pkm}" != "homebrew" ]]; then
die "Package manager '${pkm}' not found"
fi
if [[ "${pkm}" == "homebrew" ]] && ! have brew; then
die "Homebrew not found"
fi
;;
auto | "")
# Auto-detect package manager
pkm="$(detect_package_manager)"
if [[ -z "${pkm}" ]]; then
log "No supported package manager detected, using manual installation"
install_manual
return 0
fi
log "Detected package manager: ${pkm}"
;;
*)
die "Unknown install mode: ${mode}. Use: auto, manual, homebrew, dnf, yum, apt, zypper"
;;
esac
# Check for existing manual installation and remove it
local manual_install_dir="${OPT_INSTALL_DIR:-$HOME/.local/lib/${REPO_NAME}}"
if [[ -f "${manual_install_dir}/.install-method" ]] &&
[[ "$(cat "${manual_install_dir}/.install-method")" == "manual" ]]; then
log "Detected existing manual installation at ${manual_install_dir}"
log "Removing manual installation to avoid conflicts..."
local manual_bin_dir="${OPT_BIN_DIR:-$HOME/.local/bin}"
for link_name in radp-bf radp-bash-framework; do
local manual_link="${manual_bin_dir}/${link_name}"
if [[ -L "${manual_link}" ]]; then
rm -f "${manual_link}"
fi
done
rm -rf "${manual_install_dir}"
log "Manual installation removed"
fi
# Setup repository if needed
if ! check_repo_configured "${pkm}"; then
log "Repository not configured for ${pkm}"
setup_repo "${pkm}" || {
err "Failed to setup repository, falling back to manual installation"
install_manual
return 0
}
fi
# Install via package manager
install_via_pkm "${pkm}" || {
err "Package manager installation failed, falling back to manual installation"
install_manual
return 0
}
log "Successfully installed ${REPO_NAME} via ${pkm}"
log "Shell completions have been installed automatically."
log "Run: hash -r && source \"\$(radp-bf path init)\""
}
main "$@"