Skip to content

Commit

Permalink
add rhino-hotfix devdocs (#4)
Browse files Browse the repository at this point in the history
* add rhino-hotfix devdocs

* User hotfix documentation

* fixup

---------

Co-authored-by: ook37 <[email protected]>
Co-authored-by: ajstrongdev <[email protected]>
  • Loading branch information
3 people authored Jan 26, 2025
1 parent 25b769d commit b1690b4
Show file tree
Hide file tree
Showing 5 changed files with 2,527 additions and 1,886 deletions.
1 change: 1 addition & 0 deletions pages/dev/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"brand": "Brand Guidelines",
"docker": "Docker Images",
"pacstall-101": "Pacscript 101",
"hotfix-101": "Creating Hotfixes",
"ubxi": "UBXI",
"wiki": "Wiki Page Tips"
}
113 changes: 113 additions & 0 deletions pages/dev/hotfix-101.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: Creating Hotfixes
description: A guide on the creation of hotfixes for the Rhino Hotfix utility.
---

import { Callout } from 'nextra/components'

# Creating Hotfixes

This page is a guide overviewing how to create and push hotfixes for the [Rhino Hotfix](https://github.com/rhino-linux/hotfix) utility.

## Built-in Variables

| Variable Name | Purpose | Value | Notes |
|---------------|---------|-------|-------|
| `SRCDIR` | Staging area for hotfixes | `/tmp/rhino-hotfix/${hotfix}-${published}` | Useful if scripts need to `cd` to locations and return back later |
| `CARCH` | Current architecture running | `$(dpkg --print-architecture)` | Useful if scripts require downloads or perform actions based on architecture |

## Standards

Hotfix scripts should conform to the following standards:

### Bash Shebang
The top of the script should always start with an `env bash` shebang:
```bash
#!/usr/bin/env bash
```

### Hotfix Function
All script actions should be contained within functions, with the main function always called `hotfix`:
```bash
hotfix() {
echo "This is a hotfix."
}
```

### Localize Everything
All variables should be localized within the functions:
```bash
hotfix() {
local names=("test1" "test2")

for i in "${names[@]}"; do
echo "${i}"
done
}
```
<Callout type="warning" emoji="">
**Warning:** Do not localize `SRCDIR` or `CARCH`, or they will be made inaccessible to the script.
</Callout>
<Callout type="error" emoji="">
**Danger:** Do not `export` any variables.
</Callout>

### Cleanup Extra Functions
If using extra functions, be sure to clean them up with `unset -f` at the end of the `hotfix` function:
```bash
hotfix() {
local names=("test1" "test2")

for i in "${names[@]}"; do
subprocess "${i}"
done
unset -f subprocess
}

subprocess() {
echo "${1}"
}
```
<Callout type="warning" emoji="">
**Warning:** This is crucial, as if these are not unset, they could bleed over into other scripts.
</Callout>

### Example Script
Putting it all together, here is what a hotfix script might look like:
```bash
#!/usr/bin/env bash

hotfix() {
local names messages
names=("test1" "test2")
messages=("This is the first message" "This is the second")

for i in "${!names[@]}"; do
subprocess "${names[i]}" "${messages[i]}"
done
unset -f subprocess
}

subprocess() {
local name="${1}" message="${2}"
echo "${name}: ${message}"
}
```

## Adding and Publishing
Once written, the hotfix script must follow these guidelines:
1. It must be placed in the `scripts/` directory of the [Rhino Hotfix](https://github.com/rhino-linux/hotfix) repository.
2. While the name of the script can be flexible, it must be relevant to the thing it is fixing.
3. The name of the script must end with the suffix `.sh`.

Then, from the head of the repository, run:
```bash
go run manager.go add -t HOTFIXNAME -d "Some description" -s scripts/SCRIPTNAME.sh
git add hotfixes.json scripts/SCRIPTNAME.sh
```
<Callout emoji="">
**Important:** `HOTFIXNAME` can only use the following characters: `[A-z]`, `[0-9]`, `[-~._+()]`
</Callout>
<Callout type="info" emoji="">
**Note:** `HOTFIXNAME` and `SCRIPTNAME` do not necessarily need to match. `HOTFIXNAME` will be what is called to run the hotfix (`rhino-hotfix HOTFIXNAME`).
</Callout>
1 change: 1 addition & 0 deletions pages/user/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rpk": "Rhino PKG",
"pacstall": "Pacstall",
"unicorn": "Unicorn Desktop",
"hotfix": "Rhino Hotfix",
"switch": "Switch to UBXI",
"nvidia": "Nvidia Drivers",
"ub2r": "Convert to Rhino"
Expand Down
32 changes: 32 additions & 0 deletions pages/user/hotfix.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Rhino Hotfix
description: A utility to apply hotfixes and patches to Rhino Linux.
---

# Rhino Hotfix

Rhino Hotfix is a utility designed to distribute and apply hotfixes and patches to existing installations of Rhino Linux.

```bash
Usage: rhino-hotfix <input> [-h]

Input format:
<hotfix>[@<metalink>]

<hotfix> (optional):
`hotfix`: Fetch a specific hotfix.
`hotfix@<metalink>`: Fetch from a specific repo, branch, or PR.

<metalink> (optional):
`[user/repo]`: Use a specific repo.
`[user/repo:branch]` or `[:branch]`: Use a specific branch.
`[user/repo#PR]` or `[#PR]`: Use a specific PR.
NOTE: only branch or PR can be used, not both.
Examples:
rhino-hotfix # List hotfixes from rhino-linux/hotfix.
rhino-hotfix :branch # List hotfixes from an upstream branch.
rhino-hotfix hotfix # Fetch a hotfix from rhino-linux/hotfix.
rhino-hotfix hotfix@#42 # Fetch a hotfix from PR #42 upstream.
rhino-hotfix @user/repo#99 # List hotfixes from PR #99 downstream.
```
Loading

0 comments on commit b1690b4

Please sign in to comment.