Created
April 23, 2022 03:39
-
-
Save dvinciguerra/2a4b9c1d817444f49a4b6da9a8d793e6 to your computer and use it in GitHub Desktop.
Termux recipe using Itamae
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Specinfra::Helper::DetectOs::Termux < Specinfra::Helper::DetectOs | |
def detect | |
if (termux_properties = run_command('cat /data/data/com.termux/files/usr/share/examples/termux/termux.properties')) && termux_properties.success? | |
distro ||= 'termux' | |
release ||= '' | |
{ :family => 'termux', :release => release } | |
end | |
end | |
end | |
class Specinfra::Command::Termux; end | |
class Specinfra::Command::Termux::Base < Specinfra::Command::Linux::Base; end | |
class Specinfra::Command::Termux::Base::Package < Specinfra::Command::Linux::Base::Package | |
class << self | |
def check_is_installed(package, version=nil) | |
escaped_package = escape(package) | |
if version | |
cmd = "dpkg-query -f '${Status} ${Version}' -W #{escaped_package} | grep -E '^(install|hold) ok installed #{Regexp.escape(version)}$'" | |
else | |
cmd = "dpkg-query -f '${Status}' -W #{escaped_package} | grep -E '^(install|hold) ok installed$'" | |
end | |
cmd | |
end | |
alias :check_is_installed_by_apt :check_is_installed | |
def install(package, version=nil, option='') | |
if version | |
full_package = "#{package}=#{version}" | |
else | |
full_package = package | |
end | |
"DEBIAN_FRONTEND='noninteractive' apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' #{option} install #{escape(full_package)}" | |
end | |
def get_version(package, opts=nil) | |
"dpkg-query -f '${Status} ${Version}' -W #{package} | sed -n 's/^install ok installed //p'" | |
end | |
def remove(package, option='') | |
"DEBIAN_FRONTEND='noninteractive' apt-get -y #{option} remove #{package}" | |
end | |
end | |
end | |
package "git" | |
package "neovim" | |
package "curl" | |
package "tmux" | |
package "zsh" | |
execute "git clone https://github.com/anyenv/anyenv ~/.anyenv" do | |
not_if 'test -d ~/.anyenv' | |
end | |
execute %[echo 'export PATH="$HOME/.anyenv/bin:$PATH"' >> ~/.zshrc] do | |
not_if 'test -n "cat ~/.zshrc | grep .anyenv' | |
end | |
execute '~/.anyenv/bin/anyenv install --force-init' | |
execute "~/.anyenv/bin/anyenv install rbenv" | |
execute "~/.anyenv/bin/anyenv install pyenv" | |
execute "~/.anyenv/bin/anyenv install nodenv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment