|
| 1 | +# Maintaining GhostBSD Ports from FreeBSD Ports |
| 2 | + |
| 3 | +## Purpose |
| 4 | +This guide explains how to keep the GhostBSD ports tree (https://github.com/ghostbsd/ghostbsd-ports) current with the upstream FreeBSD ports tree (https://github.com/freebsd/freebsd-ports), resolve merge conflicts, and test changes before submission. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | +- Git installed and configured with access to GitHub. |
| 8 | +- Basic understanding of Git commands and FreeBSD ports structure. |
| 9 | +- `poudriere` installed for testing (optional but recommended). |
| 10 | +- A local working directory (e.g., `~/ghostbsd-ports`). |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Step-by-Step Instructions |
| 15 | + |
| 16 | +### 1. Clone the Repository and Configure Remotes |
| 17 | +Clone the GhostBSD ports repository if you don’t already have it: |
| 18 | +```shell |
| 19 | +git clone https://github.com/ghostbsd/ghostbsd-ports.git |
| 20 | +cd ghostbsd-ports |
| 21 | +``` |
| 22 | +Add the FreeBSD ports repository as a remote: |
| 23 | +```shell |
| 24 | +git remote add freebsd https://github.com/freebsd/freebsd-ports.git |
| 25 | +``` |
| 26 | +Verify the remotes: |
| 27 | +```shell |
| 28 | +git remote -v |
| 29 | +``` |
| 30 | +Expected output: |
| 31 | +``` |
| 32 | +freebsd https://github.com/freebsd/freebsd-ports.git (fetch) |
| 33 | +freebsd https://github.com/freebsd/freebsd-ports.git (push) |
| 34 | +origin https://github.com/ghostbsd/ghostbsd-ports.git (fetch) |
| 35 | +origin https://github.com/ghostbsd/ghostbsd-ports.git (push) |
| 36 | +``` |
| 37 | + |
| 38 | +**Note**: If the `freebsd` remote is already set, skip the `git remote add` step. |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +### 2. Create a New Working Branch |
| 43 | +Always work in a feature branch to keep `master` clean: |
| 44 | +```shell |
| 45 | +git checkout master |
| 46 | +git pull origin master # Ensure your local master is up-to-date |
| 47 | +git checkout -b my-branch-name |
| 48 | +``` |
| 49 | +- Replace `my-branch-name` with a descriptive name (e.g., `sync-freebsd-20250403`). |
| 50 | +- This isolates your changes and simplifies pull requests. |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +### 3. Fetch and Merge FreeBSD Ports |
| 55 | +Fetch the latest changes from FreeBSD: |
| 56 | +```shell |
| 57 | +git fetch freebsd |
| 58 | +``` |
| 59 | +Merge FreeBSD’s `master` branch into your branch: |
| 60 | +```shell |
| 61 | +git merge freebsd/master |
| 62 | +``` |
| 63 | + |
| 64 | +- **If no conflicts occur**: Proceed to Step 5 (Testing). |
| 65 | +- **If conflicts occur**: Continue to Step 4 (Resolving Conflicts). |
| 66 | + |
| 67 | +You’re right—my wording for directory conflicts suggests restoring GhostBSD’s version when FreeBSD renames or removes a directory, but you want the resolver to ensure files are moved and the old directory is removed, aligning with FreeBSD’s change. Here’s the corrected section: |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +### 4. Resolve Merge Conflicts |
| 72 | +Conflicts typically come from GhostBSD-specific changes (e.g., `Mk` files, `Makefiles`). FreeBSD updates, like renamed or removed directories, can also affect merges. Check https://github.com/freebsd/freebsd-ports for upstream changes. To find code conflicts: |
| 73 | +```bash |
| 74 | +grep -R '<<<<<<< HEAD' . |
| 75 | +``` |
| 76 | +This lists files with conflicts, marked like: |
| 77 | +``` |
| 78 | +<<<<<<< HEAD |
| 79 | +# GhostBSD-specific changes (your code) |
| 80 | +======= |
| 81 | +# FreeBSD changes (upstream code) |
| 82 | +>>>>>>> freebsd/master |
| 83 | +``` |
| 84 | + |
| 85 | +**Resolution Tips**: |
| 86 | +- Code conflicts require ports maintenance knowledge but are usually easy—often just changes Git can’t auto-merge. |
| 87 | +- **Keep GhostBSD changes**: Always preserve our customizations (e.g., in `Mk` files or `Makefiles`, the most common conflict sources), especially fixes made before FreeBSD or changes to default options. |
| 88 | +- **Resolve `PORTVERSION` conflicts**: For `Makefile` `PORTVERSION`, use FreeBSD’s version (e.g., `1.2.4`) unless a comment above ours (e.g., `# Keep 1.2.3 for GhostBSD fix`) says to keep it. |
| 89 | +- **Handle directory conflicts**: If FreeBSD renamed or removed a directory, ensure all files are moved to the new location and remove the old directory (use `git status` to spot added/removed files). |
| 90 | + |
| 91 | +### 5. Test the Ports Tree (Dry Run) |
| 92 | +Before committing, test the updated ports tree with `poudriere`: |
| 93 | +```shell |
| 94 | +sudo poudriere bulk -j ghostbsd-amd64 -p ghostbsd-ports -an |
| 95 | +``` |
| 96 | +- `-j ghostbsd-amd64`: Specifies the jail (adjust if different). |
| 97 | +- `-p ghostbsd-ports`: Uses your local ports tree. |
| 98 | +- `-an`: Dry run (analyzes without building). |
| 99 | + |
| 100 | +Check the output for errors. If issues arise, fix the affected ports and repeat. |
| 101 | + |
| 102 | +### 6. Commit and Push Changes |
| 103 | +Stage all changes: |
| 104 | +```shell |
| 105 | +git add -A |
| 106 | +``` |
| 107 | +Commit changes: |
| 108 | +```shell |
| 109 | +git commit |
| 110 | +``` |
| 111 | +Push to your branch: |
| 112 | +```shell |
| 113 | +git push origin my-branch-name |
| 114 | +``` |
| 115 | + |
| 116 | +### 7. Submit Changes |
| 117 | +- Create a pull request (PR) on GitHub from `my-branch-name` to `ghostbsd-ports/master`. |
| 118 | +- Describe the changes and any resolved conflicts in the PR. |
| 119 | +- Await review and approval from maintainers. |
| 120 | + |
| 121 | +:::{note} |
| 122 | +Do not push directly to `master` unless you’re a maintainer with explicit permission. |
| 123 | +::: |
| 124 | + |
| 125 | +## Common Issues and Solutions |
| 126 | +- **Conflict in `Mk` Files**: FreeBSD may update build infrastructure. Retain GhostBSD-specific tweaks (e.g., custom `USES` flags). |
| 127 | +- **Renamed/Removed Directories**: If FreeBSD renamed or removed a directory, ensure all files are moved to the new location and delete the old directory during conflict resolution. |
| 128 | +- **Testing Fails**: Check `poudriere` logs (e.g., `/usr/local/poudriere/data/logs/bulk`) for clues. |
0 commit comments