From 5727edf45545cb7013f2eccbe8e10b97a17f319b Mon Sep 17 00:00:00 2001 From: Jan De Landtsheer Date: Fri, 5 Sep 2025 16:22:38 +0200 Subject: [PATCH] Fix APK database preservation and add NTP configuration - Preserve essential APK database files in /lib/apk/db for apk update functionality - Only remove cache archives and backup files, not core database structure - Add ntpd.conf with Google NTP servers for reliable time synchronization - Create /var/lib/ntp directory for drift file - Fixes 'Unable to lock database' error in Zero-OS --- scripts/lib/alpine.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/lib/alpine.sh b/scripts/lib/alpine.sh index 51e4ac4..9910753 100644 --- a/scripts/lib/alpine.sh +++ b/scripts/lib/alpine.sh @@ -240,8 +240,8 @@ function alpine_aggressive_cleanup() { log_info "Removing static libraries" find "${initramfs_dir}" -name "*.a" -type f -delete 2>/dev/null || true - # Clean APK cache and databases but keep directories for apk update capability - log_info "Cleaning APK cache and databases (keeping directories for apk update)" + # Clean APK cache but preserve essential database files for apk update capability + log_info "Cleaning APK cache and non-essential databases (preserving apk update capability)" # Clean cache files but keep directory structure if [[ -d "${initramfs_dir}/var/cache/apk" ]]; then @@ -249,16 +249,21 @@ function alpine_aggressive_cleanup() { log_info "✓ Cleaned APK cache files (directory preserved)" fi - # Clean database files but keep directories for apk functionality + # Only remove specific database files, not the core ones needed for apk to function if [[ -d "${initramfs_dir}/lib/apk/db" ]]; then - find "${initramfs_dir}/lib/apk/db" -type f -delete 2>/dev/null || true - log_info "✓ Cleaned APK database files (directory preserved)" + # Remove only download cache and backup files, keep essential database structure + find "${initramfs_dir}/lib/apk/db" -name "*.tar.gz" -delete 2>/dev/null || true + find "${initramfs_dir}/lib/apk/db" -name "*.old" -delete 2>/dev/null || true + log_info "✓ Cleaned APK cache archives (essential database preserved)" fi - # Remove old backup files - find "${initramfs_dir}/var/lib/apk" -name "*.old" -delete 2>/dev/null || true + # Clean old backup files in var/lib/apk but preserve world file + if [[ -d "${initramfs_dir}/var/lib/apk" ]]; then + find "${initramfs_dir}/var/lib/apk" -name "*.old" -delete 2>/dev/null || true + log_info "✓ Cleaned APK backup files (world file preserved)" + fi - log_info "APK directories preserved for 'apk update' functionality" + log_info "APK database preserved for 'apk update' functionality" # Remove kernel source and headers if present log_info "Removing kernel development files"