mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 23:18:10 -05:00
Split whatprovides command into separate file (#9828)
This commit is contained in:
committed by
GitHub
parent
33dabec87d
commit
e0ff6b1c0e
22
bin/crew
22
bin/crew
@@ -11,6 +11,7 @@ require_relative '../commands/list'
|
||||
require_relative '../commands/prop'
|
||||
require_relative '../commands/remove'
|
||||
require_relative '../commands/sysinfo'
|
||||
require_relative '../commands/whatprovides'
|
||||
require_relative '../lib/color'
|
||||
require_relative '../lib/const'
|
||||
require_relative '../lib/crewlog'
|
||||
@@ -279,23 +280,6 @@ def cache_build
|
||||
end
|
||||
end
|
||||
|
||||
def whatprovides(regex_pat)
|
||||
matched_list = `grep -R "#{regex_pat}" #{CREW_LIB_PATH}/manifest/#{ARCH}`.lines(chomp: true).flat_map do |result|
|
||||
filelist, matched_file = result.split(':', 2)
|
||||
pkg_name = File.basename(filelist, '.filelist')
|
||||
pkg_name_status = pkg_name
|
||||
if @device[:compatible_packages].any? { |elem| elem[:name] == pkg_name }
|
||||
pkg_name_status = pkg_name.lightgreen if File.file? "#{CREW_META_PATH}/#{pkg_name}.filelist"
|
||||
else
|
||||
pkg_name_status = pkg_name.lightred
|
||||
end
|
||||
|
||||
"#{pkg_name_status}: #{matched_file}"
|
||||
end.sort
|
||||
|
||||
puts matched_list, "\nTotal found: #{matched_list.length}".lightgreen if matched_list.any?
|
||||
end
|
||||
|
||||
def update
|
||||
abort "'crew update' is used to update crew itself. Use 'crew upgrade <package1> [<package2> ...]' to update specific packages.".orange if @pkg_name
|
||||
|
||||
@@ -1894,8 +1878,8 @@ def upload_command(args)
|
||||
end
|
||||
|
||||
def whatprovides_command(args)
|
||||
args['<pattern>'].each do |name|
|
||||
whatprovides name
|
||||
args['<pattern>'].each do |regex|
|
||||
Command.whatprovides(regex)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
22
commands/whatprovides.rb
Normal file
22
commands/whatprovides.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
require_relative '../lib/const'
|
||||
require_relative '../lib/package'
|
||||
require_relative '../lib/package_utils'
|
||||
|
||||
class Command
|
||||
def self.whatprovides(regex)
|
||||
matched_list = `grep -R "#{regex}" #{CREW_LIB_PATH}/manifest/#{ARCH}`.lines(chomp: true).flat_map do |result|
|
||||
filelist, matched_file = result.split(':', 2)
|
||||
pkg_name = File.basename(filelist, '.filelist')
|
||||
pkg_name_status = pkg_name
|
||||
if PackageUtils.compatible?(Package.load_package(File.join(CREW_PACKAGES_PATH, "#{pkg_name}.rb")))
|
||||
pkg_name_status = pkg_name.lightgreen if PackageUtils.installed?(pkg_name)
|
||||
else
|
||||
pkg_name_status = pkg_name.lightred
|
||||
end
|
||||
|
||||
"#{pkg_name_status}: #{matched_file}"
|
||||
end.sort
|
||||
|
||||
puts matched_list, "\nTotal found: #{matched_list.length}".lightgreen if matched_list.any?
|
||||
end
|
||||
end
|
||||
@@ -2,7 +2,7 @@
|
||||
# Defines common constants used in different parts of crew
|
||||
require 'etc'
|
||||
|
||||
CREW_VERSION = '1.48.1'
|
||||
CREW_VERSION = '1.48.2'
|
||||
|
||||
# kernel architecture
|
||||
KERN_ARCH = Etc.uname[:machine]
|
||||
@@ -365,7 +365,7 @@ CREW_DOCOPT = <<~DOCOPT
|
||||
crew update [options] [-v|--verbose] [<compatible>]
|
||||
crew upgrade [options] [-k|--keep] [-s|--source] [-v|--verbose] [<name> ...]
|
||||
crew upload [options] [-v|--verbose] [<name> ...]
|
||||
crew whatprovides [options] [-v|--verbose] <pattern> ...
|
||||
crew whatprovides <pattern> ...
|
||||
|
||||
-b --include-build-deps Include build dependencies in output.
|
||||
-t --tree Print dependencies in a tree-structure format.
|
||||
|
||||
Reference in New Issue
Block a user