Browse Source

migrate to apt mirror 2

Denys Bashkatov 3 weeks ago
parent
commit
b2dd04daa8

+ 6 - 2
Dockerfile

@@ -1,9 +1,10 @@
 # Multi-stage build for apt-mirror with nginx
-FROM ubuntu:24.04 as base
+FROM ubuntu:24.04 AS base
 
 # Install system dependencies
 RUN apt-get update && apt-get install -y \
-    apt-mirror \
+    python3 \
+    python3-pip \
     nginx \
     openssl \
     curl \
@@ -14,6 +15,9 @@ RUN apt-get update && apt-get install -y \
     net-tools \
     && rm -rf /var/lib/apt/lists/*
 
+# Install apt-mirror from PyPI (using --break-system-packages for Ubuntu 24.04)
+RUN pip3 install --break-system-packages apt-mirror
+
 # Create necessary directories
 RUN mkdir -p /var/spool/apt-mirror \
     && mkdir -p /var/www/mirror.intra \

+ 5 - 4
README.md

@@ -4,7 +4,7 @@ A comprehensive APT mirror solution with a modern web interface, built with Dock
 
 ## ๐Ÿš€ Features
 
-- **APT Mirror**: Local Ubuntu package repository with automatic synchronization
+- **APT Mirror**: Local Ubuntu package repository with automatic synchronization using apt-mirror2 (Python/asyncio version) from PyPI
 - **Web Interface**: web UI for all services
 - **Multi-Host Setup**: Three distinct web services:
   - `mirror.intra` - DEB packages repository
@@ -28,8 +28,9 @@ A comprehensive APT mirror solution with a modern web interface, built with Dock
 โ”‚                    UI APT Mirror Container                  โ”‚
 โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
 โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”‚
-โ”‚  โ”‚   nginx     โ”‚  โ”‚ apt-mirror  โ”‚  โ”‚ health-checkโ”‚        โ”‚
+โ”‚  โ”‚   nginx     โ”‚  โ”‚ apt-mirror2 โ”‚  โ”‚ health-checkโ”‚        โ”‚
 โ”‚  โ”‚   (web)     โ”‚  โ”‚   (sync)    โ”‚  โ”‚  (monitor)  โ”‚        โ”‚
+โ”‚  โ”‚             โ”‚  โ”‚  (Python)   โ”‚  โ”‚             โ”‚        โ”‚
 โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
 โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
 โ”‚  mirror.intra  โ”‚  admin.mirror.intra  โ”‚  files.mirror.intra โ”‚
@@ -109,7 +110,7 @@ The following directories are automatically created and mounted:
 
 ### APT Mirror Configuration
 
-The apt-mirror configuration is automatically generated and includes:
+The apt-mirror2 configuration is automatically generated and includes:
 - Ubuntu 24.04 (Noble Numbat) repositories
 - Debian 12 (Bookworm) repositories
 - Main, restricted, universe, and multiverse components
@@ -282,6 +283,6 @@ This project is licensed under the MIT License - see the LICENSE file for detail
 
 ## ๐Ÿ™ Acknowledgments
 
-- [apt-mirror](https://github.com/apt-mirror/apt-mirror) - The APT mirroring tool
+- [apt-mirror2](https://gitlab.com/apt-mirror2/apt-mirror2) - The Python/asyncio APT mirroring tool from PyPI
 - [nginx](https://nginx.org/) - Web server
 - [Docker](https://docker.com/) - Containerization platform

+ 4 - 4
admin/app/routes/documentation/documentation.tsx

@@ -37,7 +37,7 @@ export default function Documentation() {
 {`data/
 โ”œโ”€โ”€ conf/
 โ”‚   โ”œโ”€โ”€ apt-mirror/
-โ”‚   โ”‚   โ””โ”€โ”€ mirror.list          # apt-mirror configuration
+โ”‚   โ”‚   โ””โ”€โ”€ mirror.list          # apt-mirror2 configuration
 โ”‚   โ””โ”€โ”€ nginx/
 โ”‚       โ”œโ”€โ”€ .htpasswd            # Admin authentication file
 โ”‚       โ””โ”€โ”€ sites-available/     # Nginx site configurations
@@ -45,14 +45,14 @@ export default function Documentation() {
 โ”‚           โ”œโ”€โ”€ admin.mirror.intra.conf
 โ”‚           โ””โ”€โ”€ files.mirror.intra.conf
 โ”œโ”€โ”€ data/
-โ”‚   โ”œโ”€โ”€ apt-mirror/              # apt-mirror working directory
+โ”‚   โ”œโ”€โ”€ apt-mirror/              # apt-mirror2 working directory
 โ”‚   โ”‚   โ”œโ”€โ”€ mirror/              # Downloaded package mirrors
 โ”‚   โ”‚   โ”œโ”€โ”€ skel/                # Skeleton files
 โ”‚   โ”‚   โ””โ”€โ”€ var/                 # Variable data
 โ”‚   โ””โ”€โ”€ files/                   # Custom file repository
 โ””โ”€โ”€ logs/
-    โ”œโ”€โ”€ apt-mirror/              # apt-mirror logs
-    โ”‚   โ””โ”€โ”€ apt-mirror.log       # Main apt-mirror log file
+    โ”œโ”€โ”€ apt-mirror/              # apt-mirror2 logs
+    โ”‚   โ””โ”€โ”€ apt-mirror.log       # Main apt-mirror2 log file
     โ””โ”€โ”€ nginx/                   # Nginx access and error logs`}
           </pre>
         </div>

+ 2 - 2
admin/app/routes/file-manager/file-manager.tsx

@@ -36,10 +36,10 @@ export function shouldRevalidate({
   return defaultShouldRevalidate;
 }
 
-export function meta() {
+export function meta({}: any) {
   return [
     { title: "File Manager" },
-    { name: "description", content: "File Manager for apt-mirror" },
+    { name: "description", content: "File Manager for apt-mirror2" },
   ];
 }
 

+ 5 - 5
entrypoint.sh

@@ -77,14 +77,14 @@ fi
 
 echo "โœ… nginx started successfully (PID: $NGINX_PID)"
 
-# Start apt-mirror sync in background if configuration exists
+# Start apt-mirror2 sync in background if configuration exists
 if [ -f /etc/apt/mirror.list ]; then
-    echo "๐Ÿ”„ Starting apt-mirror sync..."
+    echo "๐Ÿ”„ Starting apt-mirror2 sync..."
     /usr/local/bin/mirror-sync.sh &
     MIRROR_PID=$!
-    echo "โœ… apt-mirror sync started (PID: $MIRROR_PID)"
+    echo "โœ… apt-mirror2 sync started (PID: $MIRROR_PID)"
 else
-    echo "โš ๏ธ  No apt-mirror configuration found. Skipping sync."
+    echo "โš ๏ธ  No apt-mirror2 configuration found. Skipping sync."
 fi
 
 # Start health check service
@@ -96,7 +96,7 @@ echo "๐ŸŽ‰ All services started successfully!"
 echo "๐Ÿ“Š Services running:"
 echo "   - nginx (PID: $NGINX_PID)"
 if [ -n "$MIRROR_PID" ]; then
-    echo "   - apt-mirror sync (PID: $MIRROR_PID)"
+    echo "   - apt-mirror2 sync (PID: $MIRROR_PID)"
 fi
 echo "   - health check (PID: $HEALTH_PID)"
 

+ 3 - 3
scripts/health-check.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 
-# Health check script for apt-mirror container
-# This script monitors the health of nginx and apt-mirror services
+# Health check script for apt-mirror2 container
+# This script monitors the health of nginx and apt-mirror2 services
 
 HEALTH_LOG="/var/log/health-check.log"
 NGINX_PID_FILE="/var/run/nginx.pid"
@@ -36,7 +36,7 @@ check_nginx() {
     fi
 }
 
-# Function to check apt-mirror status
+# Function to check apt-mirror2 status
 check_mirror() {
     if [ -f "$MIRROR_LOCK_FILE" ]; then
         local pid=$(cat "$MIRROR_LOCK_FILE")

+ 4 - 4
scripts/mirror-sync.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 
-# apt-mirror sync script
-# This script handles the synchronization of apt repositories
+# apt-mirror2 sync script
+# This script handles the synchronization of apt repositories using the Python version (apt-mirror2)
 
 MIRROR_CONFIG="/etc/apt/mirror.list"
 MIRROR_LOG="/var/log/apt-mirror/apt-mirror.log"
@@ -42,7 +42,7 @@ remove_lock() {
 
 # Function to perform sync
 do_sync() {
-    log "Starting apt-mirror sync..."
+    log "Starting apt-mirror2 sync..."
     
     if [ ! -f "$MIRROR_CONFIG" ]; then
         log "ERROR: Mirror configuration not found at $MIRROR_CONFIG"
@@ -52,7 +52,7 @@ do_sync() {
     # Create lock file
     create_lock
     
-    # Run apt-mirror
+    # Run apt-mirror2 using Python version
     if apt-mirror "$MIRROR_CONFIG" 2>&1 | tee -a "$MIRROR_LOG"; then
         log "Sync completed successfully"
         

+ 4 - 4
setup.sh

@@ -206,14 +206,14 @@ create_data_dirs() {
     print_success "Data directories created."
 }
 
-# Function to generate apt-mirror configuration
+# Function to generate apt-mirror2 configuration
 generate_mirror_config() {
     local domain=$1
     
-    print_status "Generating apt-mirror configuration..."
+    print_status "Generating apt-mirror2 configuration..."
     
     cat > data/conf/apt-mirror/mirror.list << EOF
-# apt-mirror configuration for $domain
+# apt-mirror2 configuration for $domain
 # Generated on $(date)
 
 # Set base_path to the directory where you want to store the mirror
@@ -264,7 +264,7 @@ clean http://deb.debian.org/debian
 clean http://security.debian.org/debian-security
 EOF
     
-    print_success "apt-mirror configuration generated."
+    print_success "apt-mirror2 configuration generated."
 }
 
 # Function to show status