crew: Fix remove on reinstall/upgrade (#12520)

* Fix container test workflow

Signed-off-by: SupeChicken666 <supechicken666@gmail.com>

* Set `force: true` when reinstalling/upgrading

Signed-off-by: SupeChicken666 <supechicken666@gmail.com>

* Bump version

Signed-off-by: SupeChicken666 <supechicken666@gmail.com>

* Do not remove user configs on reinstallation

Signed-off-by: SupeChicken666 <supechicken666@gmail.com>

---------

Signed-off-by: SupeChicken666 <supechicken666@gmail.com>
This commit is contained in:
SupeChicken666
2025-08-17 02:42:07 +08:00
committed by GitHub
parent 354c0d028a
commit 2ba4b64453
4 changed files with 6 additions and 8 deletions

View File

@@ -1258,7 +1258,7 @@ def install
# remove it just before the file copy
if @pkg.in_upgrade
puts 'Attempting removal since this is an upgrade or reinstall...'
Command.remove(@pkg, verbose: CREW_VERBOSE, force: @opt_force)
Command.remove(@pkg, verbose: CREW_VERBOSE, force: true, only_remove_files: true)
end
if @pkg.is_fake?

View File

@@ -6,7 +6,7 @@ require_relative '../lib/package'
require_relative '../lib/package_utils'
class Command
def self.remove(pkg, verbose: false, force: false)
def self.remove(pkg, verbose: false, force: false, only_remove_files: false)
device_json = JSON.load_file(File.join(CREW_CONFIG_PATH, 'device.json'))
# Make sure the package is actually installed before we attempt to remove it.
@@ -19,8 +19,6 @@ class Command
# CREW_ESSENTIAL_PACKAGES is nil if overriding package upgrade list...
return if CREW_ESSENTIAL_PACKAGES.nil?
if CREW_ESSENTIAL_PACKAGES.include?(pkg.name) && !force
return if pkg.in_upgrade
# Exit with failure if attempt to remove an essential package
# is made.
abort <<~ESSENTIAL_PACKAGE_WARNING_EOF.gsub(/^(?=\w)/, ' ').chomp.lightred
@@ -52,7 +50,7 @@ class Command
end
# Perform any operations required prior to package removal.
pkg.preremove
pkg.preremove unless only_remove_files
# Use gem to first try to remove gems...
if pkg.name.start_with?('ruby_')
@@ -128,7 +126,7 @@ class Command
ConvenienceFunctions.save_json(device_json)
# Perform any operations required after package removal.
pkg.postremove
pkg.postremove unless only_remove_files
puts "#{pkg.name} removed!".lightgreen
end

View File

@@ -4,7 +4,7 @@ require 'etc'
require 'open3'
OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
CREW_VERSION ||= '1.64.8' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
CREW_VERSION ||= '1.64.9' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
# Kernel architecture.
KERN_ARCH ||= Etc.uname[:machine]

View File

@@ -65,7 +65,7 @@ if [[ -n ${CHANGED_PACKAGES-} ]]; then
yes | time crew remove "${pkg}" || true
else
echo "Testing removal of ${pkg}."
yes | time crew remove "${pkg}"
yes | time crew remove -f "${pkg}"
fi
else
echo "${pkg^} is not compatible."