mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-09 15:37:56 -05:00
* use grep to speed up crew remove Signed-off-by: Satadru Pramanik <satadru@gmail.com> * bump version Signed-off-by: Satadru Pramanik <satadru@gmail.com> * adjust logic Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add back CREW_ESSENTIAL_FILES to handle files like libC.so.6 Signed-off-by: Satadru Pramanik <satadru@gmail.com> * adjust CREW_ESSENTIAL_FILES logic Signed-off-by: Satadru Pramanik <satadru@gmail.com> * fix package_files_that_overlap Signed-off-by: Satadru Pramanik <satadru@gmail.com> * cleanup output of package_files_that_overlap Signed-off-by: Satadru Pramanik <satadru@gmail.com> * debug Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Back out CREW_ESSENTIAL_FILES change, and use Package.load_package('pkg.rb').get_deps_list to find dependent packages of CREW_ESSENTIAL_PACKAGES in commands/remove.rb, and also fix Package.load_package('pkg.rb').get_deps_list to enable using it from commands/remove.rb Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust removal message in crew. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust some punctuation and capitalization. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * fix pkg_file path detection Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Only use CREW_LOCAL_REPO_ROOT file if it exists. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * suggested changes Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Fix ESSENTIAL_PACKAGE dependency expansion. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Fix essential_deps logic. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust remove logic to return quietly if in_upgrade, else exit 1, and also properly figure out essential_packages list. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Fix docopt so options like '-d' work. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add suggested changes for testing, add testing file for remove.rb, also in testing. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * fixup Signed-off-by: Satadru Pramanik <satadru@gmail.com> * more testing Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Move recursive package function to package.rb Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust function name. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * simplify Signed-off-by: Satadru Pramanik <satadru@gmail.com> * simplify Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Use File.mtime for @last_update_check as per suggestion by @Zopolis4. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Move essential package determination to crew:generate_compatible. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Move load_json and save_json to package_utils and just use symbols for the json array in remove and package_utils. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Unify json usage globally. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Fix one remove test. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update remove.rb test. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * cleanup Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust remove test. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Try to use new Unit Tests... Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Fix installsh: git config --local commands cannot be run unless the git repo is already setup. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Move json functions to package_utils. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Fix docopt for real, add docopt unit test, have install.sh generate ruby gem filelists just like a regular buildsystems/ruby gem install. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Use CREW_META_PATH in install.sh. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Cleanup remove.rb tests. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add 'crew list essential'. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add unit test for list command. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Cleanup remove.rb test. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Cleanup wording. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Move print_deps_tree to lib/package.rb. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Return changes from #10317 Signed-off-by: Satadru Pramanik <satadru@gmail.com> --------- Signed-off-by: Satadru Pramanik <satadru@gmail.com>
54 lines
1.9 KiB
Ruby
54 lines
1.9 KiB
Ruby
require 'fileutils'
|
|
require 'json'
|
|
require_relative '../lib/color'
|
|
require_relative '../lib/const'
|
|
require_relative '../lib/package'
|
|
require_relative '../lib/package_utils'
|
|
|
|
class Command
|
|
def self.list(available, compatible, incompatible, essential, installed, verbose)
|
|
device_json = JSON.load_file(File.join(CREW_CONFIG_PATH, 'device.json'), symbolize_names: true)
|
|
installed_packages = {}
|
|
device_json[:installed_packages].each do |package|
|
|
installed_packages[package[:name]] = package[:version]
|
|
end
|
|
|
|
if available
|
|
Dir["#{CREW_PACKAGES_PATH}/*.rb"].each do |filename|
|
|
pkg_name = File.basename(filename, '.rb')
|
|
next if installed_packages.key?(pkg_name)
|
|
pkg = Package.load_package(filename)
|
|
puts pkg_name if PackageUtils.compatible?(pkg)
|
|
end
|
|
elsif compatible
|
|
Dir["#{CREW_PACKAGES_PATH}/*.rb"].each do |filename|
|
|
pkg_name = File.basename(filename, '.rb')
|
|
pkg = Package.load_package(filename)
|
|
puts pkg_name.lightgreen if PackageUtils.compatible?(pkg) && installed_packages.key?(pkg_name)
|
|
puts pkg_name if PackageUtils.compatible?(pkg)
|
|
end
|
|
elsif incompatible
|
|
Dir["#{CREW_PACKAGES_PATH}/*.rb"].each do |filename|
|
|
pkg_name = File.basename(filename, '.rb')
|
|
pkg = Package.load_package(filename)
|
|
puts pkg_name.lightred unless PackageUtils.compatible?(pkg)
|
|
end
|
|
elsif essential
|
|
puts device_json[:essential_deps].join("\n")
|
|
elsif installed
|
|
if verbose
|
|
installed_packages['======='] = '======='
|
|
installed_packages['Package'] = 'Version'
|
|
first_col_width = installed_packages.keys.max { |a, b| a.size <=> b.size }.size
|
|
installed_packages.sort.to_h.each do |package, version|
|
|
puts "#{package.ljust(first_col_width)} #{version}".lightgreen
|
|
end
|
|
else
|
|
installed_packages.each_key do |package|
|
|
puts package.lightgreen
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|