DEV Community

Query Filter
Query Filter

Posted on

docker-197

import os
import zipfile

# Define the presentation text structures for all 9 slides
SLIDES_DATA = [
    {
        "type": "title",
        "title": "Automated Legacy Java Library\nDecompilation Pipeline",
        "subtitle": "Modernizing Source Artifacts for Java 21+ Environments",
        "footer": "Presenter: Systems Architecture Team  |  Platform: Git Bash / MSYS2 on Windows"
    },
    {
        "type": "bullets",
        "title": "The Challenge of Legacy Black Boxes",
        "bullets": [
            "<b>System Dependencies:</b> Upgrading core infrastructure (like the COMET and CPLS systems) requires modernizing outdated libraries (such as the Java 6 ETSF library).",
            "<b>Lost Context:</b> Source repositories for older .jar files are often missing, corrupt, or unmaintained across historical project structures.",
            "<b>The Objective:</b> Safely disassemble binary .jar artifacts back into clean, high-concurrency-ready Java 21+ source code structures without introducing structural regression."
        ]
    },
    {
        "type": "bullets",
        "title": "Pipeline Architecture Blueprint",
        "bullets": [
            "<b>1. Version Control Audit:</b> Peeks inside bytecode headers to identify compliance states before processing.",
            "<b>2. Auto-Discovery Engine:</b> Dynamically maps the local filesystem to locate the IDE decompiler runtime.",
            "<b>3. Fernflower Decompilation:</b> Disassembles compiled binary classes into highly structured source code.",
            "<b>4. Extraction & Housekeeping:</b> Unpacks the generated archives and automatically drops intermediate artifacts."
        ]
    },
    {
        "type": "bullets",
        "title": "Phase 1: Version Control Audit",
        "bullets": [
            "<b>Source Inspection via 'javap':</b> The script targets the first .class file inside the archive and extracts the binary major version header directly from the bytecode.",
            "<b>Dynamic Matrix Mapping:</b> Maps internal bytecode numbers to human-readable names (e.g., major version 50 -> Java 6; 65 -> Java 21).",
            "<b>Target Runtime Verification:</b> Queries the discovered IntelliJ Java binary via 'java -version' to ensure destination alignment.",
            "<b>Deterministic Logging:</b> Outputs a dedicated [VERSION CONTROL] console block detailing the exact transition path before processing."
        ]
    },
    {
        "type": "bullets",
        "title": "Phase 2: Dynamic Environment Discovery",
        "bullets": [
            "<b>The Fragility Problem:</b> Hardcoding specific IDE versions (e.g., 'IntelliJ IDEA 2024.3.3') breaks when software updates patch or push paths forward.",
            "<b>The Automated Discovery Solution:</b> The script dynamically scans standard corporate installation spaces (C:/Program Files/JetBrains and local AppData).",
            "<b>Smart Selection Matrix:</b> Employs an alphanumeric reverse sort ('sort -r') to guarantee that the newest available IDE version and runtime engine are utilized automatically.",
            "<b>Fail-Safe Containment:</b> Gracefully interrupts execution with a unique exit code if critical binaries (java.exe or java-decompiler.jar) cannot be resolved."
        ]
    },
    {
        "type": "bullets",
        "title": "Phase 3: Decompilation Execution",
        "bullets": [
            "<b>Target Directory Enforcement:</b> Checks for the presence of the output folder, instantly spinning up the destination directories via 'mkdir -p' if they do not exist.",
            "<b>Absolute Path Mapping ('realpath'):</b> Upgrades input strings to fully qualified filesystem paths to prevent context loss during terminal directory switching.",
            "<b>Preserving Type Signatures:</b> Applies the critical generic signature flag (-dgs=true) to preserve advanced structural syntax patterns during decompilation."
        ]
    },
    {
        "type": "bullets",
        "title": "Phase 4: Extraction & Validation",
        "bullets": [
            "<b>Unpacking the Payload:</b> The Fernflower engine packages its results as a nested .jar file inside your destination folder.",
            "<b>Native Unpacking:</b> Uses the JDK utility ('jar -xvf') to extract the structural directories cleanly into the local folder context.",
            "<b>Automated Housekeeping:</b> Automatically removes the duplicate intermediate archive file to prevent build-path conflicts or git history clutter.",
            "<b>Deterministic Inventory Report:</b> Runs a localized filesystem discovery ('find . -type f') to output a scannable inventory summary of all reconstructed files."
        ]
    },
    {
        "type": "bullets",
        "title": "Built-In Resiliency Matrix",
        "bullets": [
            "<b>Strict Error Containment ('set -eo pipefail'):</b> Ensures that if any individual command or sub-pipe breaks, execution halts instantly instead of continuing blindly down the line.",
            "<b>Context Traps ('trap cleanup_on_err EXIT'):</b> Captures the exact line number and failing command, outputting a highly readable troubleshooting message upon an unexpected crash.",
            "<b>Idempotent Behavior:</b> Overwrites older directory traces cleanly on retry without interactive human prompts, making the script fully compatible with automated CI/CD integration pipelines."
        ]
    },
    {
        "type": "terminal",
        "title": "Execution Walkthrough & Console Output",
        "console": (
            "$ ./decompile_lib.sh ../etsf-1.0_A20.jar lib\n"
            "[INFO] Locating IntelliJ installation environment...\n"
            "[INFO] Found Runtime: /c/Program Files/JetBrains/IntelliJ IDEA 2026.1/jbr/bin/java.exe\n"
            "------------------------------------------------------------\n"
            "[VERSION CONTROL] Pipeline Architecture Mapping:\n"
            "[VERSION CONTROL]    >> SOURCE bytecode format:   Java 6\n"
            "[VERSION CONTROL]    >> TARGET decompiler runtime: Java 21.0.2\n"
            "------------------------------------------------------------\n"
            "[INFO] Destination folder 'lib' does not exist. Creating it now...\n"
            "[INFO] Executing ConsoleDecompiler against etsf-1.0_A20.jar...\n"
            "[INFO] Extracting generated source archive inside target folder...\n"
            " extracted: com/etsf/core/Parser.java\n"
            " extracted: com/etsf/core/Validator.java\n"
            "[INFO] --- Disassembled File Inventory Summary ---\n"
            "./com/etsf/core/Parser.java\n"
            "./com/etsf/core/Validator.java\n"
            "[INFO] Decompilation pipeline successfully completed."
        ]
    }
]

def build_slide_xml(slide_idx, data):
    """Generates the open XML schema layout text string for a slide based on its type."""
    xml = (
        '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'
        '<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" '
        'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" '
        'xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">\n'
        '<p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>'
        '<p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>'
    )

    if data["type"] == "title":
        # Layout for Title Slide
        xml += (
            f'<p:sp><p:nvSpPr><p:cNvPr id="{slide_idx}1" name="Title"/><p:cNvSpPr><p:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr/></p:nvSpPr>'
            '<p:spPr><a:xfrm><a:off x="914400" y="2000000"/><a:ext cx="10363200" cy="2500000"/></a:xfrm></p:spPr>'
            '<p:txBody><a:bodyPr/><a:lstStyle/><a:p>'
            f'<a:r><a:rPr sz="4000" b="1"><a:solidFill><a:srgbClr val="0C2340"/></a:solidFill></a:rPr><a:t>{data["title"]}</a:t></a:r>'
            '</a:p><a:p><a:pPr><a:lnSpc><a:spcPct val="150000"/></a:lnSpc></a:pPr></a:p>'
            '<a:p>'
            f'<a:r><a:rPr sz="2000"><a:solidFill><a:srgbClr val="009698"/></a:solidFill></a:rPr><a:t>{data["subtitle"]}</a:t></a:r>'
            '</a:p></p:txBody></p:sp>'
            f'<p:sp><p:nvSpPr><p:cNvPr id="{slide_idx}2" name="Footer"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>'
            '<p:spPr><a:xfrm><a:off x="914400" y="6200000"/><a:ext cx="10363200" cy="500000"/></a:xfrm></p:spPr>'
            '<p:txBody><a:bodyPr/><a:lstStyle/><a:p>'
            f'<a:r><a:rPr sz="1200"><a:solidFill><a:srgbClr val="555555"/></a:solidFill></a:rPr><a:t>{data["footer"]}</a:t></a:r>'
            '</a:p></p:txBody></p:sp>'
        )
    elif data["type"] == "terminal":
        # Layout for Slide 9 (Terminal background panel)
        xml += (
            f'<p:sp><p:nvSpPr><p:cNvPr id="{slide_idx}1" name="Title"/><p:cNvSpPr><p:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr/></p:nvSpPr>'
            '<p:spPr><a:xfrm><a:off x="711200" y="400000"/><a:ext cx="10668000" cy="800000"/></a:xfrm></p:spPr>'
            '<p:txBody><a:bodyPr/><a:lstStyle/><a:p>'
            f'<a:r><a:rPr sz="3200" b="1"><a:solidFill><a:srgbClr val="0C2340"/></a:srgbClr></a:solidFill></a:rPr><a:t>{data["title"]}</a:t></a:r>'
            '</a:p></p:txBody></p:sp>'
            f'<p:sp><p:nvSpPr><p:cNvPr id="{slide_idx}2" name="TerminalBG"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>'
            '<p:spPr><a:xfrm><a:off x="711200" y="1500000"/><a:ext cx="10668000" cy="5200000"/></a:xfrm></p:spPr>'
            '<p:txBody><a:bodyPr><a:solidFill><a:srgbClr val="1E1E1E"/></a:solidFill></a:bodyPr><a:lstStyle/>'
        )
        for line in data["console"].split("\n"):
Enter fullscreen mode Exit fullscreen mode

Top comments (0)