Files
chromebrew/lib/convenience_functions.rb
github-actions[bot] e85da25bf9 Post GLIBC upgrade updates WIP (#11807)
* build gcc 15.1 RC

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add rust build dep to gcc.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* back out rust

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add conflicts_ok.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add built packages for linux/386 to gcc15

* Add built packages for linux/amd64 to gcc15

* Add built packages for linux/arm/v7 to gcc15

* remove gcc_lib dep from gcc_build.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add back rust.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add more binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* cleanup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* update hashes

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add no_shrink to llvm20_build

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* alphabetize

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Testing changes

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* more gcc build adjustments

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* rust adjustments

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* binutils, gcc_build adjustments

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust crew to handle adding hashes for remote binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add binaries, adjust getrealdeps

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Revert BASH_ENV changes

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add some gdb builds

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add more arm binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add arm binaries for gdb

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust rustflags.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* update rust package, add rust buildsystem, add zellij

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update packages/gcc_dev.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/gcc_dev.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/gcc_lib.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/gcc_lib.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/libssp.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/libssp.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/libssp.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/libssp.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Add CREW_GCC_VER case binaries for binutils.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Move valid buildsystems list into const.rb

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add zellij to packages.yaml.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add gcc14 build hashes for gdb

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add glibc 2.37 compat

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update gcc 15.1 RC version to 15.1.0-RC-20250423.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add update gcc_build builds

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update uutils_coreutils build to use rust buildsystem

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update uutils package

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* rust fixes...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add built packages for linux/386 to gcc15

* Add built packages for linux/amd64 to gcc15

* Add built packages for linux/arm/v7 to gcc15

* Add final gcc15.1 version

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add gcc 15.1 binaries.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update packages/gcc_build.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/gcc_build.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/libssp.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/libssp.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/gcc_lib.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/gcc_lib.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/gcc_dev.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update packages/gcc_dev.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update crew

* Update rust for new glibc.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Remove glibc versioning from gcc builds, adjust crew to add CREW_GLIBC_PREFIX to existing rpaths during installs.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update bin/crew

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix crew lint garbage.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* rejigger gcc build

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust gcc build args.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* sync with master

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add WIP gcc_build package.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* iterate on gcc_build

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust gcc_build...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Rationalize env variable names.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* lint

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* More gcc_build adjustments.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust fixup to not break existing rpaths.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update gcc_build.rb for new Chromebrew glibc.

* Sync  gcc_build.rb with master.

* Sync binutils.rb with master.

* remove core

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add shell replacement to filefix.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* update rubygems

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update crew_profile_base to 0.0.27

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update crew_profile_base again.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Always run filefix in autotools buildsystem.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add packages, make adjustments.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* cleanup binutils

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust fixup and gcc_build

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
Co-authored-by: Satadru Pramanik <satadru@gmail.com>
Co-authored-by: satmandu <satmandu@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ed Reel <edreel@gmail.com>
2025-05-21 18:00:34 +00:00

145 lines
5.4 KiB
Ruby

# lib/convenience_functions.rb
# Extracted bits of crew-specific code that we use frequently enough that it makes sense to split them out to here.
require 'json'
require_relative 'color'
require_relative 'const'
require_relative 'crewlog'
require_relative 'downloader'
class ConvenienceFunctions
def self.determine_conflicts(pkg_name, filelist = File.join(CREW_META_PATH, "#{pkg_name}.filelist"), exclude_suffix = nil, verbose: false)
conflicts = {}
target_filelist = File.readlines(filelist, chomp: true)
puts 'Checking for conflicts with files from installed packages...'.orange if verbose
Dir[File.join(CREW_META_PATH, '*.filelist')].each do |filelist|
filelist_name = File.basename(filelist, '.filelist')
# skip filelist belongs to the same package/explicitly excluded
next if pkg_name == filelist_name || (exclude_suffix && filelist_name.end_with?(exclude_suffix))
# find out identical file paths with intersection
conflict = (target_filelist & File.readlines(filelist, chomp: true)).reject(&:empty?)
conflicts[filelist_name] = conflict if conflict.any?
end
return conflicts
end
def self.load_symbolized_json
return JSON.load_file(File.join(CREW_CONFIG_PATH, 'device.json'), symbolize_names: true).transform_values! { |val| val.is_a?(String) ? val.to_sym : val }
end
def self.save_json(json_object)
crewlog 'Saving device.json...'
begin
File.write File.join(CREW_CONFIG_PATH, 'device.json.tmp'), JSON.pretty_generate(JSON.parse(json_object.to_json))
rescue StandardError
puts 'Error writing updated packages json file!'.lightred
abort
end
# Copy over original if the write to the tmp file succeeds.
FileUtils.cp("#{CREW_CONFIG_PATH}/device.json.tmp", File.join(CREW_CONFIG_PATH, 'device.json')) && FileUtils.rm("#{CREW_CONFIG_PATH}/device.json.tmp")
end
def self.libtoolize(library, lib_pkg_name = nil)
lib_pkg_name = library if lib_pkg_name.nil?
libname = library.to_s.start_with?('lib') ? library.downcase : "lib#{library.downcase}"
puts "Generating libtool file for #{lib_pkg_name}".orange
puts "grep \"#{CREW_LIB_PREFIX}/#{libname}.so\\\|#{CREW_DEST_LIB_PREFIX}/#{libname}-*.so\" #{CREW_META_PATH}/#{lib_pkg_name}.filelist" if CREW_VERBOSE
libnames = `grep "#{CREW_LIB_PREFIX}/#{libname}.so\\\|#{CREW_DEST_LIB_PREFIX}/#{libname}-*.so*" #{CREW_META_PATH}/#{lib_pkg_name}.filelist`.chomp.split(/$/).map(&:strip)
libnames.each do |s|
s.gsub!("#{CREW_LIB_PREFIX}/", '')
end
return if libnames.empty?
dlname = libnames.grep(/.so./).first
libname = dlname.gsub(/.so.\d+/, '')
longest_libname = libnames.max_by(&:length)
libvars = longest_libname.rpartition('.so.')[2].split('.')
libtool_file = <<~LIBTOOLEOF
# #{libname}.la - a libtool library file
# Generated by libtool (GNU libtool) (Created by Chromebrew)
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='#{dlname}'
# Names of this library.
library_names='#{libnames.reverse.join(' ')}'
# The name of the static archive.
old_library='#{libname}.a'
# Linker flags that cannot go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=''
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for #{library}.
current=#{libvars[1]}
age=#{libvars[1]}
revision=#{libvars[2]}
# Is this an already installed library?
installed=yes
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='#{CREW_LIB_PREFIX}'
LIBTOOLEOF
File.write("#{CREW_LIB_PREFIX}/#{libname}.la", libtool_file)
puts "Generated #{CREW_LIB_PREFIX}/#{libname}.la..."
end
def self.patch(patch_array = [])
return if patch_array.empty?
patch_array.each do |patch_item|
abort 'Patch array is not valid!'.lightred unless patch_item[0]
abort 'Patch sha256sum does not exist!'.lightred unless patch_item[1]
patch_file = File.basename(patch_item[0])
puts "downloader #{patch_item[0]}, #{patch_item[1]}" if CREW_VERBOSE
downloader patch_item[0], patch_item[1]
puts "patch -Np1 -i #{patch_file}" if CREW_VERBOSE
system "patch -Np1 -i #{patch_file}"
end
end
def self.set_default_browser(browser_name, browser_binary)
print "\nSet #{browser_name} as your default browser? [Y/n]: "
case $stdin.gets.chomp.downcase
when '', 'y', 'yes'
Dir.chdir("#{CREW_PREFIX}/bin") do
FileUtils.ln_sf browser_binary, 'x-www-browser'
end
puts "#{browser_name} is now your default browser.".lightgreen
else
puts 'No change has been made.'.orange
end
ExitMessage.add "\nType '#{browser_binary}' to get started.\n"
end
def self.unset_default_browser(browser_name, browser_binary)
Dir.chdir("#{CREW_PREFIX}/bin") do
if File.exist?('x-www-browser') && File.symlink?('x-www-browser') &&
File.realpath('x-www-browser') == "#{CREW_PREFIX}/share/#{browser_name.downcase}/#{browser_binary}"
FileUtils.rm "#{CREW_PREFIX}/bin/x-www-browser"
end
end
end
end