This commit is contained in:
parent
647d05be1f
commit
0c12ac59bb
@ -85,8 +85,17 @@ cleanup_before_test() {
|
||||
# Remove apt locks
|
||||
rm -f /var/lib/dpkg/lock-frontend /var/lib/dpkg/lock /var/cache/apt/archives/lock 2>/dev/null || true
|
||||
|
||||
# Remove existing keyrings to avoid overwrite prompts
|
||||
# Clean up broken repository files from previous tests
|
||||
# Remove all custom sources files
|
||||
rm -f /etc/apt/sources.list.d/*.sources 2>/dev/null || true
|
||||
rm -f /etc/apt/sources.list.d/*.list 2>/dev/null || true
|
||||
|
||||
# Remove all keyrings
|
||||
rm -f /etc/apt/keyrings/*.gpg 2>/dev/null || true
|
||||
rm -f /etc/apt/keyrings/*.asc 2>/dev/null || true
|
||||
|
||||
# Update package lists to ensure clean state
|
||||
apt-get update -qq 2>/dev/null || true
|
||||
|
||||
# Wait a moment for processes to clean up
|
||||
sleep 1
|
||||
@ -176,23 +185,23 @@ apt-get install -y curl wget gpg jq git build-essential ca-certificates &>/dev/n
|
||||
# ==============================================================================
|
||||
# TEST 2: ADMINER - Database Management
|
||||
# ==============================================================================
|
||||
test_function "Adminer" \
|
||||
"setup_adminer" \
|
||||
"dpkg -l adminer 2>/dev/null | grep -q '^ii' && a2query -c adminer 2>/dev/null && echo 'Adminer installed'"
|
||||
# test_function "Adminer" \
|
||||
# "setup_adminer" \
|
||||
# "dpkg -l adminer 2>/dev/null | grep -q '^ii' && a2query -c adminer 2>/dev/null && echo 'Adminer installed'"
|
||||
|
||||
# ==============================================================================
|
||||
# TEST 3: CLICKHOUSE
|
||||
# ==============================================================================
|
||||
test_function "ClickHouse" \
|
||||
"setup_clickhouse" \
|
||||
"clickhouse-server --version"
|
||||
# test_function "ClickHouse" \
|
||||
# "setup_clickhouse" \
|
||||
# "clickhouse-server --version"
|
||||
|
||||
# ==============================================================================
|
||||
# TEST 4: POSTGRESQL
|
||||
# ==============================================================================
|
||||
# test_function "PostgreSQL 17" \
|
||||
# "PG_VERSION=17 setup_postgresql" \
|
||||
# "psql --version"
|
||||
test_function "PostgreSQL 16" \
|
||||
"PG_VERSION=16 setup_postgresql" \
|
||||
"psql --version"
|
||||
|
||||
# ==============================================================================
|
||||
# TEST 6: MARIADB
|
||||
@ -218,13 +227,13 @@ test_function "MySQL 8.0" \
|
||||
# ==============================================================================
|
||||
# TEST 8: MONGODB (Check AVX support)
|
||||
# ==============================================================================
|
||||
if grep -q avx /proc/cpuinfo; then
|
||||
test_function "MongoDB 8.0" \
|
||||
"MONGO_VERSION=8.0 setup_mongodb" \
|
||||
"mongod --version"
|
||||
else
|
||||
skip_test "MongoDB 8.0" "CPU does not support AVX"
|
||||
fi
|
||||
# if grep -q avx /proc/cpuinfo; then
|
||||
# test_function "MongoDB 8.0" \
|
||||
# "MONGO_VERSION=8.0 setup_mongodb" \
|
||||
# "mongod --version"
|
||||
# else
|
||||
# skip_test "MongoDB 8.0" "CPU does not support AVX"
|
||||
# fi
|
||||
|
||||
# ==============================================================================
|
||||
# TEST 9: NODE.JS
|
||||
@ -278,9 +287,9 @@ test_function "Ruby 3.4.1 with Rails" \
|
||||
# ==============================================================================
|
||||
# TEST 16: RUST
|
||||
# ==============================================================================
|
||||
test_function "Rust (stable)" \
|
||||
"RUST_TOOLCHAIN=stable RUST_CRATES='cargo-edit' setup_rust" \
|
||||
"source \$HOME/.cargo/env && rustc --version"
|
||||
# test_function "Rust (stable)" \
|
||||
# "RUST_TOOLCHAIN=stable RUST_CRATES='cargo-edit' setup_rust" \
|
||||
# "source \$HOME/.cargo/env && rustc --version"
|
||||
|
||||
# ==============================================================================
|
||||
# TEST 17: GHOSTSCRIPT
|
||||
|
@ -88,11 +88,20 @@ ensure_dependencies() {
|
||||
fi
|
||||
|
||||
if ((current_time - last_update > 300)); then
|
||||
$STD apt update
|
||||
# Ensure orphaned sources are cleaned before updating
|
||||
cleanup_orphaned_sources 2>/dev/null || true
|
||||
|
||||
if ! $STD apt update; then
|
||||
msg_warn "apt update failed, attempting to fix..."
|
||||
ensure_apt_working || return 1
|
||||
fi
|
||||
echo "$current_time" >"$apt_cache_file"
|
||||
fi
|
||||
|
||||
$STD apt install -y "${missing[@]}"
|
||||
$STD apt install -y "${missing[@]}" || {
|
||||
msg_error "Failed to install dependencies: ${missing[*]}"
|
||||
return 1
|
||||
}
|
||||
msg_ok "Installed dependencies"
|
||||
fi
|
||||
}
|
||||
@ -536,6 +545,7 @@ cleanup_old_repo_files() {
|
||||
# ------------------------------------------------------------------------------
|
||||
# Cleanup orphaned .sources files that reference missing keyrings
|
||||
# This prevents APT signature verification errors
|
||||
# Call this at the start of any setup function to ensure APT is in a clean state
|
||||
# ------------------------------------------------------------------------------
|
||||
cleanup_orphaned_sources() {
|
||||
local sources_dir="/etc/apt/sources.list.d"
|
||||
@ -554,6 +564,37 @@ cleanup_orphaned_sources() {
|
||||
rm -f "$sources_file"
|
||||
fi
|
||||
done < <(find "$sources_dir" -name "*.sources" -print0 2>/dev/null)
|
||||
|
||||
# Also check for broken symlinks in keyrings directory
|
||||
if [[ -d "$keyrings_dir" ]]; then
|
||||
find "$keyrings_dir" -type l ! -exec test -e {} \; -delete 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Ensure APT is in a working state before installing packages
|
||||
# This should be called at the start of any setup function
|
||||
# ------------------------------------------------------------------------------
|
||||
ensure_apt_working() {
|
||||
# Clean up orphaned sources first
|
||||
cleanup_orphaned_sources
|
||||
|
||||
# Try to update package lists
|
||||
if ! apt-get update -qq 2>/dev/null; then
|
||||
msg_warn "APT update failed, attempting to fix..."
|
||||
|
||||
# More aggressive cleanup
|
||||
rm -f /etc/apt/sources.list.d/*.sources 2>/dev/null || true
|
||||
cleanup_orphaned_sources
|
||||
|
||||
# Try again
|
||||
if ! apt-get update -qq 2>/dev/null; then
|
||||
msg_error "Cannot update package lists - APT is critically broken"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
@ -2055,17 +2096,19 @@ setup_mariadb() {
|
||||
$STD apt purge -y 'mariadb*' || true
|
||||
fi
|
||||
|
||||
# Install required dependencies first (MariaDB needs these from main repos)
|
||||
msg_info "Installing MariaDB dependencies"
|
||||
$STD apt update
|
||||
$STD apt install -y gawk rsync socat libdbi-perl pv || {
|
||||
msg_error "Failed to install MariaDB dependencies"
|
||||
return 1
|
||||
}
|
||||
# Ensure APT is working before proceeding
|
||||
ensure_apt_working || return 1
|
||||
|
||||
# Cleanup old repository files
|
||||
cleanup_old_repo_files "mariadb"
|
||||
|
||||
# Install required dependencies first (MariaDB needs these from main repos)
|
||||
msg_info "Installing MariaDB dependencies"
|
||||
ensure_dependencies gawk rsync socat libdbi-perl pv || {
|
||||
msg_error "Failed to install MariaDB dependencies"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Use helper function to get fallback suite
|
||||
local SUITE
|
||||
SUITE=$(get_fallback_suite "$DISTRO_ID" "$DISTRO_CODENAME" "http://mirror.mariadb.org/repo/${MARIADB_VERSION}/${DISTRO_ID}")
|
||||
@ -2286,17 +2329,26 @@ function setup_mysql() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! apt-cache policy mysql-server | grep -q 'Candidate:'; then
|
||||
# Check for either mysql-server meta package or mysql-community-server
|
||||
if ! apt-cache policy mysql-server mysql-community-server 2>/dev/null | grep -q 'Candidate:'; then
|
||||
msg_error "MySQL ${MYSQL_VERSION} package not available for suite ${SUITE}"
|
||||
msg_info "Available MySQL components:"
|
||||
apt-cache search "^mysql-" | grep "^mysql-" | head -20 | sed 's/^/ /'
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! $STD apt install -y mysql-server; then
|
||||
# Try to install mysql-server first (meta package), fallback to mysql-community-server
|
||||
if apt-cache policy mysql-server 2>/dev/null | grep -q 'Candidate:'; then
|
||||
if ! $STD apt install -y mysql-server mysql-client; then
|
||||
msg_error "Failed to install MySQL ${MYSQL_VERSION}"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
if ! $STD apt install -y mysql-community-server mysql-community-client; then
|
||||
msg_error "Failed to install MySQL ${MYSQL_VERSION}"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Verify installation
|
||||
if ! command -v mysql >/dev/null 2>&1; then
|
||||
@ -2719,6 +2771,9 @@ function setup_ruby() {
|
||||
|
||||
msg_info "Installing Ruby $RUBY_VERSION"
|
||||
|
||||
# Ensure APT is working before installing dependencies
|
||||
ensure_apt_working || return 1
|
||||
|
||||
# Install all required build dependencies
|
||||
ensure_dependencies jq autoconf patch build-essential rustc libssl-dev libyaml-dev \
|
||||
libreadline6-dev zlib1g-dev libgmp-dev libncurses5-dev libffi-dev libgdbm6 \
|
||||
|
Loading…
x
Reference in New Issue
Block a user