Skip to content

Conversation

@elibosley
Copy link
Member

@elibosley elibosley commented Jan 23, 2026

Update build workflow to include additional directories and streamline tarball creation.

Summary by CodeRabbit

  • New Features

    • Pre-install conflict detection that blocks installation when other plugins manage the same files.
    • Non-destructive restoration during removal (originals copied back), with clearer warnings when backups are missing.
  • Bug Fixes

    • Broadened file-existence checks and more consistent handling of new vs. backed-up files.
    • Added user-facing warnings and clearer install/remove messages.
  • Chores

    • Build workflow now generates and packages a dynamic file list for packaging.

✏️ Tip: You can customize this high-level summary in your review settings.

…ckup restoration. Update build workflow to include additional directories and streamline tarball creation.
@elibosley elibosley requested a review from SimonFair January 23, 2026 16:33
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

Updates add pre-install conflict detection across webgui-pr-* plugins, broadened workflow packaging to include etc/sbin/share, and change plugin removal/restoration to non-destructive copy operations with missing-backup warnings and wider file-existence checks. (50 words)

Changes

Cohort / File(s) Summary
PR plugin installation logic
.github/scripts/generate-pr-plugin.sh
Adds pre-install scan of other webgui-pr-* plugins' installed_files.txt to detect file overlaps and abort on conflicts; switches restoration from mv to cp -fp; broadens existence checks (-e
PR plugin build workflow
.github/workflows/pr-plugin-build.yml
Extends workflow triggers to include etc/**, sbin/**, and share/**; generates dynamic file_list.txt of build/ contents and uses that list for tar creation; logs file list and retains tar verification.
Init script formatting
etc/rc.d/rc.udev
Adds a blank line after the PATH assignment (formatting-only change).

Sequence Diagram(s)

sequenceDiagram
    participant Installer as PR Plugin Installer
    participant Scanner as Manifest Scanner
    participant OtherPlugins as Installed Plugins Manifests
    participant Filesystem as System Files / Backups

    Installer->>Scanner: Read new plugin file list
    Installer->>OtherPlugins: Read each webgui-pr-*/installed_files.txt
    Scanner-->>Installer: Build file→plugin mapping
    Installer->>Scanner: Compare new files to mapping

    alt Conflicts found
        Scanner-->>Installer: Return conflict entries
        Installer->>Filesystem: Print failure banner & guidance
        Installer->>Installer: Clean temp files and exit (error)
    else No conflicts
        Installer->>Filesystem: Copy backups (cp -fp) / create NEW backups
        Installer->>Filesystem: Install plugin files
        Installer->>Scanner: Write installed_files.txt manifest
        Installer-->>Installer: Complete
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I sniffed through manifests, one by one,
Found tangled files before they’d begun,
I copied backups—no loss in the night,
Warned of what’s missing and set things right,
A cautious hop, and the plugin's done. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title emphasizes conflict handling, but the PR primarily updates the build workflow to include additional directories and streamline tarball creation, with file conflict detection being only one aspect among broader changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Jan 23, 2026

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2026.01.23.1830
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2533/webgui-pr-2533.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates

📝 Modified Files:

Click to expand file list
etc/rc.d/rc.udev

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2533, or run:

plugin remove webgui-pr-2533

🤖 This comment is automatically generated and will be updated with each new push to this PR.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/scripts/generate-pr-plugin.sh (1)

263-273: Inconsistent symlink handling in backup creation.

Lines 89 and 402 use -e "$system_file" || -L "$system_file" to handle symlinks, but line 266 uses only -f "$SYSTEM_FILE". If the system file is a symlink, it won't be backed up and will be marked as NEW, causing it to be deleted on removal rather than restored.

Proposed fix
     if [ -f "$BACKUP_FILE" ]; then
         echo "  → Using existing backup: $BACKUP_FILE"
         echo "$SYSTEM_FILE|$BACKUP_FILE" >> "$MANIFEST"
-    elif [ -f "$SYSTEM_FILE" ]; then
+    elif [ -e "$SYSTEM_FILE" ] || [ -L "$SYSTEM_FILE" ]; then
         echo "  → Creating backup of original: $SYSTEM_FILE"
-        cp -p "$SYSTEM_FILE" "$BACKUP_FILE"
+        cp -pP "$SYSTEM_FILE" "$BACKUP_FILE"
         echo "$SYSTEM_FILE|$BACKUP_FILE" >> "$MANIFEST"
     else

Note: -pP preserves symlinks as symlinks rather than following them.

🤖 Fix all issues with AI agents
In @.github/workflows/pr-plugin-build.yml:
- Around line 127-134: The tar step can fail if TAR_SOURCES is empty; update the
logic around the TAR_SOURCES array and the tar invocation (the TAR_SOURCES
variable and the tar -czf ../${{ steps.version.outputs.local_txz }}
"${TAR_SOURCES[@]}" line) to guard against an empty array: check the length of
TAR_SOURCES (e.g., ${`#TAR_SOURCES`[@]}) before calling tar and either create a
harmless placeholder (temporary empty directory/file) or skip/mark artifact
creation when no sources exist so tar is never invoked with an empty list.

Comment on lines 127 to 134
TAR_SOURCES=()
if [ -d etc ]; then
TAR_SOURCES+=("etc")
fi
if [ -d usr ]; then
TAR_SOURCES+=("usr")
fi
tar -czf ../${{ steps.version.outputs.local_txz }} "${TAR_SOURCES[@]}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Handle empty TAR_SOURCES to prevent tarball creation failure.

If neither etc nor usr directories exist in the build folder (edge case), tar will fail with "Cowardly refusing to create an empty archive." While the current file mapping logic should always create usr for valid changes, consider adding a guard.

Proposed fix
  TAR_SOURCES=()
  if [ -d etc ]; then
    TAR_SOURCES+=("etc")
  fi
  if [ -d usr ]; then
    TAR_SOURCES+=("usr")
  fi
+ if [ ${`#TAR_SOURCES`[@]} -eq 0 ]; then
+   echo "Error: No files to package"
+   exit 1
+ fi
  tar -czf ../${{ steps.version.outputs.local_txz }} "${TAR_SOURCES[@]}"
🤖 Prompt for AI Agents
In @.github/workflows/pr-plugin-build.yml around lines 127 - 134, The tar step
can fail if TAR_SOURCES is empty; update the logic around the TAR_SOURCES array
and the tar invocation (the TAR_SOURCES variable and the tar -czf ../${{
steps.version.outputs.local_txz }} "${TAR_SOURCES[@]}" line) to guard against an
empty array: check the length of TAR_SOURCES (e.g., ${`#TAR_SOURCES`[@]}) before
calling tar and either create a harmless placeholder (temporary empty
directory/file) or skip/mark artifact creation when no sources exist so tar is
never invoked with an empty list.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/pr-plugin-build.yml:
- Around line 121-130: The script can produce an empty file_list.txt which would
make tar create an unintended empty archive; before running the tar command (the
lines that cd build and call tar -czf ../${{ steps.version.outputs.local_txz }}
-T ../file_list.txt) add a guard that checks file_list.txt is non-empty (e.g.
test -s ../file_list.txt) and if it's empty print a clear message and exit with
non-zero status (or skip artifact creation) so the pipeline fails loudly instead
of producing an empty tar; update the surrounding echo/logging to reflect the
decision.
🧹 Nitpick comments (1)
.github/workflows/pr-plugin-build.yml (1)

41-43: Update log message to reflect all monitored directories.

The message "No emhttp files changed" is misleading since the workflow now monitors emhttp, etc, sbin, and share directories (line 34).

Proposed fix
  if [ ! -s "changed_files.txt" ]; then
-   echo "No emhttp files changed"
+   echo "No relevant files changed in emhttp/etc/sbin/share"
    echo "has_changes=false" >> "$GITHUB_OUTPUT"

Comment on lines +121 to +130
# Generate file list for plugin/tar (relative paths)
find build -type f | sed 's|^build/||' > file_list.txt
echo "File list for plugin:"
cat file_list.txt
# Create tarball - consistent filename for updates
cd build
echo "Creating tarball with contents:"
find usr/ -type f
tar -czf ../${{ steps.version.outputs.local_txz }} usr/
cat ../file_list.txt
tar -czf ../${{ steps.version.outputs.local_txz }} -T ../file_list.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Guard against empty file list before tar creation.

If all changed files fall into the "Skipping unsupported path" case (line 111-112), file_list.txt will be empty. While tar -T with an empty file may create an empty archive rather than failing, this likely isn't the desired behavior.

Proposed fix
  # Generate file list for plugin/tar (relative paths)
  find build -type f | sed 's|^build/||' > file_list.txt
+ if [ ! -s file_list.txt ]; then
+   echo "Error: No files to package"
+   exit 1
+ fi
  echo "File list for plugin:"
  cat file_list.txt
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Generate file list for plugin/tar (relative paths)
find build -type f | sed 's|^build/||' > file_list.txt
echo "File list for plugin:"
cat file_list.txt
# Create tarball - consistent filename for updates
cd build
echo "Creating tarball with contents:"
find usr/ -type f
tar -czf ../${{ steps.version.outputs.local_txz }} usr/
cat ../file_list.txt
tar -czf ../${{ steps.version.outputs.local_txz }} -T ../file_list.txt
# Generate file list for plugin/tar (relative paths)
find build -type f | sed 's|^build/||' > file_list.txt
if [ ! -s file_list.txt ]; then
echo "Error: No files to package"
exit 1
fi
echo "File list for plugin:"
cat file_list.txt
# Create tarball - consistent filename for updates
cd build
echo "Creating tarball with contents:"
cat ../file_list.txt
tar -czf ../${{ steps.version.outputs.local_txz }} -T ../file_list.txt
🤖 Prompt for AI Agents
In @.github/workflows/pr-plugin-build.yml around lines 121 - 130, The script can
produce an empty file_list.txt which would make tar create an unintended empty
archive; before running the tar command (the lines that cd build and call tar
-czf ../${{ steps.version.outputs.local_txz }} -T ../file_list.txt) add a guard
that checks file_list.txt is non-empty (e.g. test -s ../file_list.txt) and if
it's empty print a clear message and exit with non-zero status (or skip artifact
creation) so the pipeline fails loudly instead of producing an empty tar; update
the surrounding echo/logging to reflect the decision.

Copy link
Contributor

@SimonFair SimonFair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LTGM, have install and removed a few times working as expected.

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.

3 participants