Skip to content

Commit

Permalink
Squashed 'scripts/lib/' changes from c5c60b7c..38cfc618
Browse files Browse the repository at this point in the history
38cfc618 feat: support termux pkg

git-subtree-dir: scripts/lib
git-subtree-split: 38cfc618986cc5db5f594d7524c9d866b8af433a
  • Loading branch information
1995parham committed Dec 5, 2024
1 parent 8e03b28 commit 91d2132
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ main_xbps() {
return 0
}

main_pkg() {
return 0
}

main_apt() {
return 0
}
Expand Down Expand Up @@ -93,6 +97,10 @@ main_apt() {
return 1
}
main_pkg() {
return 1
}
main_brew() {
return 1
}
Expand Down
18 changes: 18 additions & 0 deletions require.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ function not_require_pacman() {
fi
}

# install packages using pkg
function require_pkg() {
declare -a to_install_pkg
to_install_pkg=()

for pkg in "$@"; do
running "require" " pkg ${pkg}"
if ! pkg list-installed | grep "${pkg}" &>/dev/null; then
to_install_pkg+=("${pkg}")
fi
done

if [[ ${#to_install_pkg[@]} -ne 0 ]]; then
action "require" " pkg install ${to_install_pkg[*]}"
pkg install "${to_install_pkg[@]}"
fi
}

# install packages using brew
function require_brew() {
declare -a to_install_pkg
Expand Down
13 changes: 13 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,19 @@ install() {
return
fi

if [[ "${OSTYPE}" == "linux-android" ]]; then
msg " android (termux), using pkg"

if declare -f main_pkg >/dev/null; then
main_brew
else
msg "main_pkg not found, there is nothing to do" "error"
exit
fi

return
fi

if [[ -n "$(command -v apt)" ]]; then
msg " linux with apt installed, using apt"

Expand Down

0 comments on commit 91d2132

Please sign in to comment.