Skip to content

Conversation

@skorotkiewicz
Copy link

@skorotkiewicz skorotkiewicz commented Sep 27, 2025

Summary

This PR implements comprehensive support for custom PKGBUILD repositories in yay, allowing users to configure and manage private, organization-specific, or local package collections that integrate seamlessly with yay's existing search and installation workflows.

Features Added

🏗️ Core Infrastructure

  • Repository Types: Support for local filesystem, Git, and HTTP-based PKGBUILD repositories
  • Configuration Management: Extended ~/.config/yay/config.json with customRepos array
  • Repository Manager: Centralized management system with search, update, and package retrieval capabilities
  • PKGBUILD Parser: Robust parsing of PKGBUILD files with dependency extraction and validation

🔍 Search Integration

  • Unified Search: Custom repositories appear alongside AUR and official repositories in search results
  • Repository-Specific Search: New repo/package syntax (e.g., yay -Ss aur/mama, yay -Ss core/linux)
  • Priority System: Configurable search priority for custom repositories
  • Source Indication: Clear labeling of package sources in search results

📦 Installation Workflow

  • Dependency Resolution: Custom repository packages integrated into yay's dependency graph
  • Build Process: Seamless building and installation of custom repository packages
  • Read-Only Support: Automatic copying of PKGBUILDs from read-only repositories to build directory
  • Git Integration: Proper Git repository initialization for custom packages

⚙️ CLI Management

  • Repository Commands:
    • --repo-add=name,type,url/path - Add custom repository
    • --repo-remove=name - Remove custom repository
    • --repo-list - List all configured repositories
    • --repo-update - Update all custom repositories
  • Early Command Handling: Repository management commands work without requiring sudo

🔧 Configuration & Migration

  • Backward Compatibility: Automatic migration of existing configurations
  • Authentication Support: SSH keys, tokens, and basic auth for private repositories
  • Validation: Comprehensive configuration validation and error handling

Repository Types Supported

📁 Local Repositories

{
  "name": "local-packages",
  "type": "local", 
  "path": "/path/to/pkgbuilds",
  "searchable": true,
  "priority": 1
}

🌐 Git Repositories

{
  "name": "github-test",
  "type": "git",
  "url": "https://github.com/skorotkiewicz/test-repo",
  "branch": "main",
  "searchable": true,
  "priority": 2,
  "auth": {
    "type": "token",
    "token": "ghp_..."
  }
}

🌍 HTTP Repositories

{
  "name": "http-repo",
  "type": "http", 
  "url": "https://example.com/pkgs/",
  "searchable": true,
  "priority": 3
}

Usage Examples

Search Commands

# Search all repositories
yay -Ss firefox

# Search specific repository
yay -Ss core/linux
yay -Ss aur/yay
yay -Ss github-test/mama

# List custom repositories
yay --repo-list

Repository Management

# Add repositories
yay --repo-add=local-packages,local,/home/user/pkgs
yay --repo-add=github-test,git,https://github.com/skorotkiewicz/test-repo

# Update repositories
yay --repo-update

# Remove repository
yay --repo-remove=github-test

Installation

# Install from custom repository
yay -S github-test/mama

# Install with dependency resolution
yay -S local-packages/myapp

Technical Implementation

Key Files Added/Modified

  • pkg/customrepo/ - Complete custom repository package
  • pkg/settings/config.go - Extended configuration structure
  • pkg/query/query_builder.go - Search integration
  • pkg/dep/dep_graph.go - Dependency resolution
  • pkg/sync/workdir/preparer.go - Build process integration
  • main.go - CLI command handling

Architecture Highlights

  • Interface-Based Design: Clean separation between repository types
  • Context-Aware Operations: Proper cancellation and timeout handling
  • Error Resilience: Graceful handling of repository failures
  • Performance Optimized: Efficient caching and update mechanisms

Testing

  • ✅ Unit tests for repository management
  • ✅ Integration tests for search functionality
  • ✅ Build process validation
  • ✅ Configuration migration testing
  • ✅ CLI command verification

Backward Compatibility

  • ✅ Existing configurations automatically migrated
  • ✅ No breaking changes to existing functionality
  • ✅ All existing commands continue to work unchanged

Security Considerations

  • 🔐 Secure credential storage in configuration
  • 🔐 Support for SSH key authentication
  • 🔐 Token-based authentication for private repositories
  • 🔐 Validation of repository URLs and paths

Documentation

  • 📚 Comprehensive README with usage examples
  • 📚 Configuration reference documentation
  • 📚 Migration guide for existing users

Future Enhancements

  • 🔮 Support for additional repository types (FTP, S3, etc.)
  • 🔮 Repository signing and verification
  • 🔮 Advanced caching strategies
  • 🔮 Repository health monitoring

…ting, and updating repositories

- Introduced new command-line options for managing custom repositories: `--repo-add`, `--repo-remove`, `--repo-list`, and `--repo-update`.
- Implemented functions to handle these commands, including validation and configuration saving.
- Updated dependency graph handling to incorporate packages from custom repositories.
- Enhanced search functionality to include results from custom repositories.
- Updated configuration structure to support custom repository settings.
…BUILD support

- Updated command-line options for managing custom repositories, including `--repo-add`, `--repo-remove`, `--repo-list`, and `--repo-update`.
- Implemented early command handling for custom repository operations before runtime initialization.
- Added functionality to download and manage `.SRCINFO` files alongside `PKGBUILD`.
- Enhanced package search and installation processes to support custom repositories.
- Improved error handling and logging for repository operations.
- Added functionality to update custom repositories before refreshing pacman databases.
- Integrated error handling for cache directory retrieval and repository updates.
- Enhanced logging to inform users of the update status of custom repositories.
…ogger parameter

- Updated test cases in cmd_test.go and query_test.go to pass `nil` for the logger parameter in the QueryBuilder initialization.
- This change simplifies the test setup and aligns with the updated QueryBuilder constructor signature.
… logger parameter in the SourceQueryBuilder initialization, aligning with recent changes in the constructor signature.
- Added parsing for repository-specific search targets, including AUR and custom repositories.
- Implemented logic to categorize targets into AUR, known repositories, and general targets.
- Updated search logic to handle package names correctly when querying repositories.
- Improved logging for better traceability during target processing.
@fsmv
Copy link

fsmv commented Oct 5, 2025

Hi does this work with https://github.com/archlinux/aur.git like this post describes? https://archlinux.org/news/recent-services-outages/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants