Commit 0fdee308 authored by satmandu's avatar satmandu Committed by GitHub

Use grep in crew whatprovides (#5797)

* Use grep in crew whatprovides

* Add check for working grep.

* uprev
parent 003b8772
......@@ -35,7 +35,7 @@ Usage:
crew search [options] [<name> ...]
crew update [options] [<compatible>]
crew upgrade [options] [-k|--keep] [-s|--build-from-source] [<name> ...]
crew whatprovides [options] <name> ...
crew whatprovides [options] <pattern> ...
-c --color Use colors even if standard out is not a tty.
-d --no-color Disable colors even if standard out is a tty.
......@@ -486,20 +486,13 @@ def files (pkgName)
end
def whatprovides (regexPat)
fileArray = []
needle = regexPat.gsub(/-/,',').gsub(/,/,'\-')
Dir[CREW_META_PATH + '*.filelist'].each do |packageList|
packageName = File.basename packageList, '.filelist'
File.readlines(packageList).each do |line|
found = line[/#{needle}/] if line.ascii_only?
if found
fileLine = packageName + ': ' + line
unless fileArray.include? fileLine
fileArray.push(fileLine)
end
end
end
# Use grep version command to ascertain whether we have a working grep.
unless system('grep -V > /dev/null 2>&1')
abort 'Grep is not working. Please install it with \'crew install grep\''.lightred
end
fileArray = []
@grepresults = %x[grep "#{regexPat}" #{CREW_META_PATH}*.filelist].chomp.gsub('.filelist','').gsub(':',': ').gsub(CREW_META_PATH,'').split(/$/).map(&:strip)
@grepresults.each { |fileLine| fileArray.push(fileLine) }
unless fileArray.empty?
fileArray.sort.each do |item|
puts item
......@@ -1397,7 +1390,7 @@ def upgrade_command(args)
end
def whatprovides_command(args)
args["<name>"].each do |name|
args["<pattern>"].each do |name|
whatprovides name
end
end
......
# Defines common constants used in different parts of crew
CREW_VERSION = '1.10.4'
CREW_VERSION = '1.10.5'
ARCH_ACTUAL = `uname -m`.strip
# This helps with virtualized builds on aarch64 machines
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment