Skip to content

Commit

Permalink
fix(install): copy files over only when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
massix committed Jun 27, 2024
1 parent eaefb3b commit 70460e9
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions termux/install_termux.fish
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,41 @@ set -l cache_dir "$HOME/.cache/installer"
mkdir -p {$cache_dir}/font

set -l font_url "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/Recursive.zip"
set -l font_fn "RecMonoCasualNerdFontMono-Regular.ttf"

check_install curl curl

if test -f {$termux_dir}/termux.properties
backup_file "$termux_dir/termux.properties" "$backup_dir/termux-$(date +'%s').properties"
set -l existing_tprop_sha (shafile {$termux_dir}/termux.properties)
set -l tprop_sha (shafile {$current_dir}/termux.properties)

if test {$existing_tprop_sha} = {$tprop_sha}
info "Properties file up to date"
else
backup_file {$termux_dir}/termux.properties {$backup_dir}/termux-(date +'%s').properties
info "Copying termux properties"
cp {$current_dir}/termux.properties {$termux_dir}/termux.properties
end
else
info "Copying termux properties"
cp {$current_dir}/termux.properties {$termux_dir}/termux.properties
end

info "Copying termux properties"
cp {$current_dir}/termux.properties "$termux_dir/termux.properties"

info "Downloading font"
curl -sL "$font_url" -o "$cache_dir/font.zip"
curl -sL {$font_url} -o {$cache_dir}/font.zip

info "Unpacking font"
unzip -qq -o -x "$cache_dir/font.zip" -d "$cache_dir/font/"
unzip -qq -o -x {$cache_dir}/font.zip -d {$cache_dir}/font/

set -l tf_sha (shafile {$termux_dir}/font.ttf)
set -l newtf_sha (shafile {$cache_dir}/font/{$font_fn})

info "Copying patched font"
cp {$cache_dir}/font/RecMonoCasualNerdFontMono-Regular.ttf {$termux_dir}/font.ttf
if test {$tf_sha} = {$newtf_sha}
info "Already using latest font version"
else
info "Copying patched font"
cp {$cache_dir}/font/{$font_fn} {$termux_dir}/font.ttf
end

info "Cleaning cache folder"
rm -rf {$cache_dir}/font/*
Expand Down

0 comments on commit 70460e9

Please sign in to comment.