mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 23:18:10 -05:00
Add check_free_disk_space misc function (#10536)
* Add check_free_disk_space misc function * Remove require 'matrix' line in misc_functions.rb
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# lib/misc_functions.rb
|
||||
# Generic implementations of various functions/algorithms that are not crew-specific.
|
||||
require_relative 'color'
|
||||
|
||||
def require_gem(gem_name_and_require = nil, require_override = nil)
|
||||
# Allow only loading gems when needed.
|
||||
return if gem_name_and_require.nil?
|
||||
@@ -91,4 +93,10 @@ class MiscFunctions
|
||||
time_seconds_string = "#{time_seconds} second#{time_seconds == 1 ? '' : 's'}"
|
||||
return time_hour_string + time_minutes_string + time_seconds_string
|
||||
end
|
||||
|
||||
def self.check_free_disk_space(bytes = 0)
|
||||
formatted_size = human_size(bytes)
|
||||
free_space = `echo $(($(stat -f --format="%a*%S" #{CREW_PREFIX})))`.chomp.to_i
|
||||
abort "\nNot enough free disk space. You need at least #{formatted_size} to install.\n".lightred if free_space < bytes
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
require 'package'
|
||||
require 'misc_functions'
|
||||
|
||||
class Android_studio < Package
|
||||
description 'Android Studio is the official IDE for Android development.'
|
||||
@@ -14,8 +15,7 @@ class Android_studio < Package
|
||||
depends_on 'sommelier'
|
||||
|
||||
def self.preflight
|
||||
free_space = `echo $(($(stat -f --format="%a*%S" #{CREW_PREFIX})))`.chomp.to_i
|
||||
abort 'Not enough free disk space. You need at least 6 GB to install.'.lightred if free_space < 6442450944
|
||||
MiscFunctions.check_free_disk_space(6442450944)
|
||||
end
|
||||
|
||||
def self.install
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
require 'package'
|
||||
require 'misc_functions'
|
||||
|
||||
class Codelobster < Package
|
||||
description 'Free cross-platform IDE for PHP/HTML/CSS/JavaScript development'
|
||||
@@ -19,8 +20,7 @@ class Codelobster < Package
|
||||
|
||||
def self.preflight
|
||||
abort 'Please remove qt5_base before installing.'.lightred if File.exist? "#{CREW_LIB_PREFIX}/libQt5Core.so.5"
|
||||
free_space = `echo $(($(stat -f --format="%a*%S" .)))`.chomp.to_i
|
||||
abort 'Not enough free disk space. You need at least 1.2 GB to install.'.lightred if free_space < 1288490188
|
||||
MiscFunctions.check_free_disk_space(1288490188)
|
||||
end
|
||||
|
||||
def self.patch
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
require 'package'
|
||||
require 'misc_functions'
|
||||
|
||||
class Freecad < Package
|
||||
description 'A free and opensource multiplatform 3D parametric modeler.'
|
||||
@@ -14,8 +15,7 @@ class Freecad < Package
|
||||
depends_on 'sommelier'
|
||||
|
||||
def self.preflight
|
||||
free_space = `echo $(($(stat -f --format="%a*%S" .)))`.chomp.to_i
|
||||
abort 'Not enough free disk space. You need at least 5.2 GB to install.'.lightred if free_space < 5583457485
|
||||
MiscFunctions.check_free_disk_space(5583457485)
|
||||
end
|
||||
|
||||
def self.patch
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
require 'package'
|
||||
require 'misc_functions'
|
||||
|
||||
class Repo < Package
|
||||
description 'The Multiple Git Repository Tool'
|
||||
@@ -14,8 +15,7 @@ class Repo < Package
|
||||
no_compile_needed
|
||||
|
||||
def self.preflight
|
||||
free_space = `echo $(($(stat -f --format="%a*%S" #{CREW_PREFIX})))`.chomp.to_i
|
||||
abort 'Not enough free disk space. You need at least 1 MB to install.'.lightred if free_space < 1000000
|
||||
MiscFunctions.check_free_disk_space(1000000000)
|
||||
end
|
||||
|
||||
def self.install
|
||||
|
||||
Reference in New Issue
Block a user