scripts: Introduce organized directory structure with conventions #12936

Merged
jnsamyak merged 1 commit from releng_improv_pt2 into main 2025-09-16 04:02:17 +00:00
37 changed files with 363 additions and 91 deletions

View file

@ -1,43 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: GPL-2.0
# Author: Mohan Boddu <mboddu@bhujji.com>
#
# Private compose from a tag using odcs
#
"""
Usage: python odcs-private-compose.py <token> <koji_tag> <sigkey>
This is used to generate private composes using ODCS.
This script is specifically used to generate openh264 repos.
The compsoe is stored in /srv/odcs/private/ dir on
odcs-backend-releng01.iad2.fedoraproject.org
"""
import argparse
from odcs.client.odcs import ODCS, AuthMech, ComposeSourceTag
# We need oidc token to authenticate to odcs and a koji tag to compose from
parser = argparse.ArgumentParser()
parser.add_argument("token", help="OIDC token for authenticating to ODCS")
parser.add_argument("tag", help="koji tag to compose")
parser.add_argument("sigkey", help="sigkey that was used to signed the builds in the tag")
args = parser.parse_args()
token = args.token
tag = args.tag
sigkey = args.sigkey
odcs = ODCS("https://odcs.fedoraproject.org",
auth_mech=AuthMech.OpenIDC,
openidc_token=token)
source = ComposeSourceTag(tag, sigkeys=[sigkey])
# Making a private compose with no inheritance
arches = ["armhfp", "i386", "x86_64", "aarch64", "ppc64le", "s390x"]
compose = odcs.request_compose(source, target_dir="private", arches = arches, flags=["no_inheritance"])
print(compose)

View file

@ -1,48 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: GPL-2.0
# Author: Mohan Boddu <mboddu@bhujji.com>
#
# Private compose from a tag using odcs
#
"""
Usage: python odcs-token.py
This is used to generate a token needed to run odcs composes
"""
import openidc_client
staging = False
if staging:
id_provider = 'https://id.stg.fedoraproject.org/openidc/'
else:
id_provider = 'https://id.fedoraproject.org/openidc/'
# Get the auth token using the OpenID client.
oidc = openidc_client.OpenIDCClient(
'odcs',
id_provider,
{'Token': 'Token', 'Authorization': 'Authorization'},
'odcs-authorizer',
'notsecret',
)
scopes = [
'openid',
'https://id.fedoraproject.org/scope/groups',
'https://pagure.io/odcs/new-compose',
'https://pagure.io/odcs/renew-compose',
'https://pagure.io/odcs/delete-compose',
]
try:
token = oidc.get_token(scopes, new_token=True)
token = oidc.report_token_issue()
print(token)
except requests.exceptions.HTTPError as e:
print(e.response.text)
raise

129
scripts_new/CONVENTIONS.md Normal file
View file

@ -0,0 +1,129 @@
# Fedora Release Engineering Scripts - Naming Conventions
This document establishes standardized naming conventions for all scripts in the reorganized `scripts/` directory structure. These conventions improve consistency, readability, and maintainability.
## 🎯 Core Principles
1. **Consistency**: All scripts follow the same naming patterns
2. **Clarity**: Names clearly indicate script purpose and type
3. **Maintainability**: Predictable naming makes navigation easier
4. **Future-proof**: Standards that scale as the repository grows
## 📝 Naming Rules
### File Names
#### ✅ Use snake_case (underscores) for all script names
- **Correct**: `mass_rebuild.py`, `find_failures.py`, `stage_release.sh`
- **Incorrect**: `mass-rebuild.py`, `find-failures.py`, `stage-release.sh`
**Rationale**: Snake_case is more consistent with Python conventions and easier to work with programmatically.
#### ✅ Always include appropriate file extensions
- **Python scripts**: `.py`
- **Shell scripts**: `.sh`
- **Configuration files**: `.conf`, `.ini`, `.yaml`, etc.
- **Templates**: `.j2` (Jinja2), `.tmpl`, etc.
- **Executables**: No extension only if truly meant to be CLI tools
**Examples**:
- `mass_rebuild.py` (Python script)
- `create_repos.sh` (Shell script)
- `compose_config.conf` (Configuration)
- `email_template.j2` (Jinja2 template)
#### ✅ Use lowercase for all file and directory names
- **Correct**: `mass_rebuilds/`, `koji_import.py`
- **Incorrect**: `Mass_Rebuilds/`, `Koji_Import.py`
#### ✅ Use descriptive, action-oriented names
- **Good**: `find_failed_builds.py`, `retire_orphaned_packages.py`
- **Poor**: `script.py`, `util.py`, `helper.sh`
### Directory Names
#### ✅ Use lowercase with hyphens for multi-word directory names
- **Correct**: `mass-rebuilds/`, `quality-assurance/`, `release-process/`
- **Incorrect**: `mass_rebuilds/`, `qualityAssurance/`, `release_process/`
**Rationale**: Hyphens in directory names are more readable in URLs and file paths, while underscores in filenames work better with import statements and variable names.
## 📋 Specific Patterns
### Script Categories
#### Build & Compose Scripts
```
build_current.py # Build current compose
build_previous.py # Build previous release
koji_import.py # Import builds to Koji
koji_compare.py # Compare Koji builds
compose_info_builder.py # Build compose metadata
```
#### Package Management Scripts
```
find_failures.py # Find failed builds
block_retired.py # Block retired packages
retire_packages.py # Retire package list
orphan_packages.py # Orphan package list
```
#### Release Process Scripts
```
mass_rebuild.py # Mass rebuild orchestration
stage_release.sh # Stage release for publication
sign_packages.py # Sign package batches
create_torrents.py # Generate release torrents
```
#### Quality Assurance Scripts
```
check_builds.py # Check build health
test_compose.py # Test compose quality
validate_paths.py # Validate upgrade paths
```
## 🔄 Migration Guidelines
### Renaming Existing Scripts
When migrating scripts to the new structure, rename according to these patterns:
#### Before → After
```bash
# Hyphens to underscores
mass-rebuild.py → mass_rebuild.py
check-latest-build.py → check_latest_build.py
find-bad-builds.py → find_bad_builds.py
# Add missing extensions
mashcompose → mash_compose.py
buildepelbeta → build_epel_beta.sh
torrent-generator → generate_torrents.py
# Improve clarity
build-current.py → build_current_compose.py
clean-amis.py → clean_ami_images.py
get_retired_packages.sh → find_retired_packages.sh
```
## ❓ FAQ
**Q: Should configuration files follow the same naming?**
A: Yes, but use appropriate extensions (.conf, .yaml, .ini) instead of .py/.sh.
**Q: How do we handle template files?**
A: Use clear extensions like `.j2` for Jinja2, `.tmpl` for generic templates.
**Q: Do you have any helper where we can check about renaming?**
A: Yes, please consider looking into rename_script_helper, and validate_conventions scripts from the misc directory.
## 📚 References
- [Fedora Packaging Guidelines](https://docs.fedoraproject.org/en-US/packaging-guidelines/)
---
**Maintainer**: Fedora Release Engineering Team
**Questions**: File issues in [fedora-releng repository](https://pagure.io/releng)

32
scripts_new/README.md Normal file
View file

@ -0,0 +1,32 @@
# Fedora Release Engineering Scripts (New Structure)
This directory contains the reorganized structure for Fedora Release Engineering scripts, designed for better maintainability and clarity.
## 📁 Directory Structure
- **[builds/](builds/)** - Build system tools and compose generation
- **[release_process/](release_process/)** - Release workflow orchestration and management
- **[packages/](packages/)** - Package lifecycle and maintenance tools
- **[quality-assurance/](quality-assurance/)** - Testing, validation, and quality tools
- **[sync/](sync/)** - Repository synchronization utilities
- **[infrastructure/](infrastructure/)** - Infrastructure management and governance
- **[utilities/](utilities/)** - General-purpose helper scripts
- **[misc/](misc/)** - Uncategorized or legacy scripts
## 🔧 Migration Status
**⚠️ This is the new directory structure under development.**
Scripts are being migrated from the flat `scripts/` directory to this organized structure. See [CONVENTIONS.md](CONVENTIONS.md) for naming standards and migration guidelines.
## 📖 Getting Started
1. Review [CONVENTIONS.md](CONVENTIONS.md) for naming and organization standards
2. Check individual directory READMEs for specific tool documentation
3. Use the directory structure to quickly locate relevant scripts
## 🔗 Related
- Original scripts: `../scripts/` (legacy structure)
- Conventions: [CONVENTIONS.md](CONVENTIONS.md)
- Issues: [fedora-releng repository](https://pagure.io/releng)

View file

@ -0,0 +1,14 @@
# Build System Tools
Scripts for managing Fedora builds, composes, and Koji operations.
## Subdirectories
- **[compose/](compose/)** - Compose generation and validation tools
- **[koji/](koji/)** - Koji build system utilities and maintenance
## Purpose
This directory contains tools that directly interact with the build infrastructure to create, manage, and validate Fedora package builds and composes.
**Status**: 🚧 Migration in progress

View file

@ -0,0 +1,14 @@
# Compose Tools
Scripts for generating, validating, and managing Fedora composes.
## Purpose
Tools that handle the creation and validation of Fedora release composes, including metadata generation and quality checks.
**Examples of scripts that will be migrated here:**
- Compose building and validation
- Metadata generation
- Compose health checking
**Status**: 🚧 Awaiting migration

View file

@ -0,0 +1,14 @@
# Koji Utilities
Scripts for interacting with and managing the Koji build system.
## Purpose
Tools for Koji build operations, import/export, monitoring, and maintenance tasks.
**Examples of scripts that will be migrated here:**
- Koji build import/export
- Build monitoring and reporting
- Koji maintenance and cleanup
**Status**: 🚧 Awaiting migration

View file

@ -0,0 +1,14 @@
# Infrastructure Management
Scripts for managing Fedora infrastructure and governance processes.
## Subdirectories
- **[messaging/](messaging/)** - Fedora messaging and notification systems
- **[fesco/](fesco/)** - FESCo governance and policy tools
## Purpose
Tools that support Fedora infrastructure operations and governance processes.
**Status**: 🚧 Migration in progress

View file

View file

@ -0,0 +1 @@
release_process/bug-filing/

View file

@ -0,0 +1 @@
packages/orphaned

View file

@ -0,0 +1,9 @@
# Miscellaneous Scripts
Uncategorized scripts and legacy tools that don't fit into other categories.
## Purpose
Temporary location for scripts that need further analysis for proper categorization, or legacy scripts with unclear current status.
**Status**: 🚧 Triage in progress

View file

@ -0,0 +1,13 @@
#!/bin/bash
# rename_script.sh - Helper for batch renaming during migration
# Convert hyphens to underscores in filename
rename_file() {
local old_name="$1"
local new_name=$(echo "$old_name" | sed 's/-/_/g')
if [[ "$old_name" != "$new_name" ]]; then
echo "Renaming: $old_name$new_name"
git mv "$old_name" "$new_name"
fi
}

View file

@ -0,0 +1,22 @@
#!/usr/bin/env python3
"""validate_conventions.py - Check adherence to naming conventions"""
import os
import re
from pathlib import Path
def validate_filename(filepath):
"""Validate a single file against conventions"""
name = filepath.name
# Check for hyphens in filenames (should use underscores)
if '-' in name and not filepath.is_dir():
return f"{filepath}: Use underscores not hyphens in filenames"
# Check for missing extensions on scripts
if filepath.suffix == '' and not filepath.is_dir():
first_line = filepath.read_text(errors='ignore').split('\n')[0]
if first_line.startswith('#!'):
return f"⚠️ {filepath}: Script missing file extension"
return None

View file

@ -0,0 +1,16 @@
# Package Management Tools
Scripts for managing package lifecycles and dist-git operations.
## Subdirectories
- **[lifecycle/](lifecycle/)** - Package retirement, blocking, and lifecycle management
- **[maintenance/](maintenance/)** - Package health monitoring and failure detection
- **[orphaned/](orphaned/)** - Orphaned package processing and retirement
- **[distgit/](distgit/)** - Dist-git repository operations
## Purpose
Tools that manage packages throughout their lifecycle in Fedora, from creation through retirement.
**Status**: 🚧 Migration in progress

View file

View file

View file

View file

View file

@ -0,0 +1,15 @@
# Quality Assurance Tools
Scripts for testing, validation, and quality control in Fedora releases.
## Subdirectories
- **[testing/](testing/)** - Build and release testing tools
- **[critpath/](critpath/)** - Critical path package management
- **[ftbfs/](ftbfs/)** - Failure to Build From Source (FTBFS) handling
## Purpose
Ensures quality and reliability of Fedora releases through automated testing and validation.
**Status**: 🚧 Migration in progress

View file

View file

View file

@ -0,0 +1,18 @@
# Release Process Management
Scripts that orchestrate and manage Fedora release workflows.
## Subdirectories
- **[mass-rebuilds/](mass-rebuilds/)** - Mass rebuild orchestration and coordination
- **[staging/](staging/)** - Release staging and preparation tools
- **[atomic/](atomic/)** - Atomic/OSTree release management
- **[mass-branching/](mass-branching/)** - Branch creation for new releases
- **[signing/](signing/)** - Package and release signing tools
- **[torrents/](torrents/)** - Release torrent generation
## Purpose
Contains scripts that manage the end-to-end release process, from mass rebuilds through final release publication.
**Status**: 🚧 Migration in progress

View file

View file

@ -0,0 +1,14 @@
# Branch Creation Tools
Scripts for creating new release branches in Fedora and EPEL.
## Subdirectories
- **[fedora/](fedora/)** - Fedora release branching tools
- **[epel/](epel/)** - EPEL release branching tools
## Purpose
Manages the creation of new branches when starting development for new Fedora releases or EPEL versions.
**Status**: 🚧 Awaiting migration

View file

@ -0,0 +1,14 @@
# Mass Rebuild Tools
Scripts for orchestrating mass rebuilds during Fedora release cycles.
## Purpose
Tools that coordinate large-scale package rebuilds, typically performed twice per release cycle for toolchain updates.
**Examples of scripts that will be migrated here:**
- Mass rebuild orchestration
- Rebuild status tracking
- Bug filing for failed rebuilds
**Status**: 🚧 Awaiting migration

View file

View file

View file

View file

@ -0,0 +1,14 @@
# Repository Synchronization
Scripts for syncing repositories between primary and secondary architectures.
## Subdirectories
- **[primary/](primary/)** - Primary architecture synchronization
- **[secondary/](secondary/)** - Secondary architecture synchronization
## Purpose
Manages the synchronization of packages and repositories across different architecture buildroots.
**Status**: 🚧 Awaiting migration

0
scripts_new/sync/primary/.gitignore vendored Normal file
View file

0
scripts_new/sync/secondary/.gitignore vendored Normal file
View file

View file

@ -0,0 +1,9 @@
# General Utilities
General-purpose helper scripts and utilities used across multiple workflows.
## Purpose
Standalone tools that provide utility functions for various release engineering tasks but don't fit into specific workflow categories.
**Status**: 🚧 Awaiting migration