mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 23:18:10 -05:00
Fix crew files command (#13806)
This commit is contained in:
@@ -5,12 +5,6 @@ require_relative '../lib/package_utils'
|
|||||||
|
|
||||||
class Command
|
class Command
|
||||||
def self.files(pkg)
|
def self.files(pkg)
|
||||||
# Check if the package is even installed first, as this is the most likely reason we cannot find a filelist.
|
|
||||||
unless PackageUtils.installed?(pkg.name)
|
|
||||||
puts "Package #{pkg.name} is not installed.".lightred
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
# Fake packages do not have any files.
|
# Fake packages do not have any files.
|
||||||
if pkg.is_fake?
|
if pkg.is_fake?
|
||||||
puts "Package #{pkg.name} is fake and has no files.".lightred
|
puts "Package #{pkg.name} is fake and has no files.".lightred
|
||||||
@@ -18,19 +12,33 @@ class Command
|
|||||||
end
|
end
|
||||||
|
|
||||||
# We can't do anything if we don't have the filelist.
|
# We can't do anything if we don't have the filelist.
|
||||||
unless File.file?(filelist_path = File.join(CREW_META_PATH, "#{pkg.name}.filelist"))
|
filelist_path = File.join("#{CREW_LIB_PATH}/manifest/#{ARCH}/#{pkg.name[0]}/", "#{pkg.name}.filelist")
|
||||||
puts "Package #{pkg.name} does not have a filelist :(".lightred
|
puts "Manifest file: #{filelist_path}".yellow if CREW_VERBOSE
|
||||||
|
unless File.file?(filelist_path)
|
||||||
|
if PackageUtils.compatible?(pkg)
|
||||||
|
puts "Package #{pkg.name} does not have a filelist but should since #{ARCH} is compatible. :(".lightred
|
||||||
|
else
|
||||||
|
puts "Package #{pkg.name} does not have a filelist since #{ARCH} is not compatible. :(".lightred
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# Print the name and description of the package.
|
# Installed packages have green names, incompatible packages have red, and compatible but not installed have blue.
|
||||||
puts pkg.name.lightgreen + ": #{pkg.description}".lightblue
|
if PackageUtils.installed?(pkg.name)
|
||||||
|
print pkg.name.lightgreen
|
||||||
|
elsif !PackageUtils.compatible?(pkg)
|
||||||
|
print pkg.name.lightred
|
||||||
|
else
|
||||||
|
print pkg.name.lightblue
|
||||||
|
end
|
||||||
|
puts ": #{pkg.description}".lightblue
|
||||||
|
|
||||||
size, filelist = ConvenienceFunctions.read_filelist(filelist_path, always_calcuate_from_disk: true)
|
# Extract the filelist and the total size of those files.
|
||||||
|
filesize, filelist = ConvenienceFunctions.read_filelist(filelist_path)
|
||||||
|
|
||||||
# Print the filelist, the total number of files, and the total size of those files.
|
# Print the filelist, the total number of files, and the total size of those files.
|
||||||
puts filelist
|
puts filelist
|
||||||
puts "\nTotal found: #{filelist.count}".lightgreen
|
puts "\nTotal found: #{filelist.count - 1}".lightgreen
|
||||||
puts "Disk usage: #{MiscFunctions.human_size(size)}".lightgreen
|
puts "Disk usage: #{MiscFunctions.human_size(filesize)}".lightgreen
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -50,9 +50,8 @@ class Command
|
|||||||
EOT
|
EOT
|
||||||
when 'files'
|
when 'files'
|
||||||
puts <<~EOT
|
puts <<~EOT
|
||||||
Display installed files of package(s).
|
Display files of package(s).
|
||||||
Usage: crew files <package1> [<package2> ...]
|
Usage: crew files [-v|--verbose] <package1> [<package2> ...]
|
||||||
The package(s) must be currently installed.
|
|
||||||
EOT
|
EOT
|
||||||
when 'install'
|
when 'install'
|
||||||
puts <<~EOT
|
puts <<~EOT
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ require 'etc'
|
|||||||
require 'open3'
|
require 'open3'
|
||||||
|
|
||||||
OLD_CREW_VERSION = defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
|
OLD_CREW_VERSION = defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
|
||||||
CREW_VERSION = '1.68.8' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
|
CREW_VERSION = '1.68.9' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
|
||||||
|
|
||||||
# Kernel architecture.
|
# Kernel architecture.
|
||||||
KERN_ARCH = Etc.uname[:machine]
|
KERN_ARCH = Etc.uname[:machine]
|
||||||
@@ -497,7 +497,7 @@ CREW_DOCOPT = <<~DOCOPT
|
|||||||
crew deps [options] [--deep] [-t|--tree] [-b|--include-build-deps] [--exclude-buildessential] [-v|--verbose] <name> ...
|
crew deps [options] [--deep] [-t|--tree] [-b|--include-build-deps] [--exclude-buildessential] [-v|--verbose] <name> ...
|
||||||
crew diskstat [options] [-a|--all] [<count>]
|
crew diskstat [options] [-a|--all] [<count>]
|
||||||
crew download [options] [-s|--source] [-v|--verbose] <name> ...
|
crew download [options] [-s|--source] [-v|--verbose] <name> ...
|
||||||
crew files [options] <name> ...
|
crew files [options] [-v|--verbose] <name> ...
|
||||||
crew help [options] [<command>] [-v|--verbose] [<subcommand>]
|
crew help [options] [<command>] [-v|--verbose] [<subcommand>]
|
||||||
crew install [options] [-f|--force] [-k|--keep] [--regenerate-filelist] [-s|--source] [-S|--recursive-build] [-v|--verbose] <name> ...
|
crew install [options] [-f|--force] [-k|--keep] [--regenerate-filelist] [-s|--source] [-S|--recursive-build] [-v|--verbose] <name> ...
|
||||||
crew list [options] [-v|--verbose] (available|compatible|incompatible|essential|installed)
|
crew list [options] [-v|--verbose] (available|compatible|incompatible|essential|installed)
|
||||||
|
|||||||
@@ -64,10 +64,8 @@ class ConvenienceFunctions
|
|||||||
|
|
||||||
def self.read_filelist(path, always_calcuate_from_disk: false)
|
def self.read_filelist(path, always_calcuate_from_disk: false)
|
||||||
filelist = File.readlines(path, chomp: true)
|
filelist = File.readlines(path, chomp: true)
|
||||||
|
|
||||||
if filelist.first&.start_with?('# Total size') && !always_calcuate_from_disk
|
if filelist.first&.start_with?('# Total size') && !always_calcuate_from_disk
|
||||||
total_size, *contents = filelist
|
return [filelist.first[/Total size: (\d+)/, 1].to_i, filelist]
|
||||||
return [total_size[/Total size: (\d+)/, 1].to_i, contents]
|
|
||||||
else
|
else
|
||||||
return [get_package_disk_size(filelist), filelist]
|
return [get_package_disk_size(filelist), filelist]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user