initial attempt at functionalizing replaces in python3 package (#7708)

* initial attempt at functionalizing replaces in python3 package

* remove commented code

* preinstall now forces device.json reload; run crew remove only once

* bump version

* linted
This commit is contained in:
Satadru Pramanik
2022-12-03 01:02:30 -05:00
committed by GitHub
parent 61c49dcbc6
commit 6df679a5ef
3 changed files with 22 additions and 5 deletions

View File

@@ -959,6 +959,17 @@ def pre_install(dest_dir)
Dir.chdir dest_dir do
puts 'Performing pre-install...'
@pkg.preinstall
# Reload device.json in case preinstall modified it via
# running 'crew remove packages...'
@device = JSON.parse(File.read("#{CREW_CONFIG_PATH}device.json"), symbolize_names: true)
# symbolize also values
@device.each do |key, _elem|
@device[key] = begin
@device[key].to_sym
rescue StandardError
@device[key]
end
end
end
end

View File

@@ -1,6 +1,6 @@
# Defines common constants used in different parts of crew
CREW_VERSION = '1.28.5'
CREW_VERSION = '1.28.6'
# kernel architecture
KERN_ARCH = `uname -m`.chomp

View File

@@ -47,7 +47,16 @@ class Python3 < Package
conflicts_ok
def self.preinstall
system 'crew remove py3_setuptools py3_pip', exception: false
@device = JSON.load_file("#{CREW_CONFIG_PATH}/device.json", symbolize_names: true)
@replaces = %w[py3_pip py3_setuptools]
@replaces_installed = []
@replaces.each do |package|
@replaces_installed.push(package) if @device[:installed_packages].any? { |elem| elem[:name] == package }
end
unless @replaces_installed.empty?
puts "Removing superseded package(s): #{@replaces_installed.join(' ')}...".orange
system "crew remove #{@replaces_installed.join(' ')}", exception: false
end
end
def self.patch
@@ -123,9 +132,6 @@ class Python3 < Package
system 'make', "DESTDIR=#{CREW_DEST_DIR}", 'install'
end
# Remove conflicting binaries
# FileUtils.rm_f "#{CREW_DEST_PREFIX}/bin/wheel"
# Make python3 the default python
FileUtils.ln_sf 'python3', "#{CREW_DEST_PREFIX}/bin/python"
end