Files
chromebrew/packages/nvm.rb
Satadru Pramanik, DO, MPH, MEng 5621163c84 Refactor ruby gems in packages, crew cleanup of debugging, install.sh refactor for gems (#10294)
* Some ruby gem updates and cleanup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* bump version

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* move gem installs to core install

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add webkitgtk_6 binaries for x86_64, add librsvg binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add rebuilt librsvg binary for x86_64.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* rename gem function internals to make more sense

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* adjust webkitgtk_6 deps

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* update ruby gem packages, add a ruby gem package update script to tools

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* suggested changes

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* rebuild parted

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add parted binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* suggested changes

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* refactor ruby buildsystem

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add libsdl2, freerdp binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* sync crew function to lib/fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* shellcheck fix

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add const for CREW_UPDATE_CHECK_INTERVAL

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Move time_difference into function for neatness.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* suggested changes from @uberhacker

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* @Zopolis4 suggested change: Use git last update time

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add .blank? usage to downloader to avoid undefined method `empty?' for nil (NoMethodError)

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
2024-08-13 11:25:39 -05:00

47 lines
1.6 KiB
Ruby

require 'package'
class Nvm < Package
description 'Node Version Manager - Simple bash script to manage multiple active node.js versions.'
homepage 'https://github.com/nvm-sh/nvm'
version '0.39.3'
license 'MIT'
compatibility 'all'
source_url 'https://github.com/nvm-sh/nvm.git'
git_hashtag "v#{version}"
no_compile_needed
print_source_bashrc
def self.install
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/share/nvm"
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/etc/bash.d"
system "sed -i 's,$HOME/.nvm,#{CREW_DEST_PREFIX}/share/nvm,g' install.sh"
system "sed -i 's,$(nvm_detect_profile),#{CREW_DEST_PREFIX}/etc/bash.d/10-nvm.sh,' install.sh"
system "NVM_DIR=#{CREW_DEST_PREFIX}/share/nvm && bash install.sh"
system "sed -i 's,#{CREW_DEST_PREFIX},#{CREW_PREFIX},' #{CREW_DEST_PREFIX}/etc/bash.d/10-nvm.sh"
FileUtils.rm_rf Dir["#{CREW_DEST_PREFIX}/share/nvm/.git*"]
FileUtils.rm_rf "#{CREW_DEST_PREFIX}/share/nvm/test"
end
def self.postinstall
if Gem::Version.new(LIBC_VERSION.to_s) < Gem::Version.new('2.28')
puts "\nNode.js 18.x and above requires GLIBC 2.28.".orange
puts "ChromeOS is currently running GLIBC #{LIBC_VERSION}.".orange
end
end
def self.postremove
config_dir = "#{CREW_PREFIX}/share/nvm"
if Dir.exist? config_dir
print "Would you like to remove the #{config_dir} directory? [y/N] "
case $stdin.gets.chomp.downcase
when 'y', 'yes'
FileUtils.rm_rf config_dir
puts "#{config_dir} removed.".lightblue
else
puts "#{config_dir} saved.".lightgreen
end
end
end
end