Skip to content

Commit 4a2be9c

Browse files
committed
feat: Support non-Ublue images
1 parent 9cdb48d commit 4a2be9c

7 files changed

Lines changed: 122 additions & 7 deletions

File tree

modules/justfiles/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# `justfiles`
22

3-
:::note
4-
The module is only compatible with Universal Blue images.
5-
:::
6-
7-
The `justfiles` module makes it easy to include [just](https://just.systems/) recipes from multiple files in Universal Blue -based images. It can be useful for example when utilizing DE-specific justfiles when building multiple images. On the other hand, you likely wont need the module if you're building just one image or need just one justfile for all your images.
3+
The `justfiles` module makes it easy to include [just](https://just.systems/) recipes from multiple files. It can be useful for example when utilizing DE-specific justfiles when building multiple images. On the other hand, you likely wont need the module if you're building just one image or need just one justfile for all your images.
84

95
## What is just ?
106

11-
Just is a command runner (kind of like make) that can be used to supply arbitrary scripts under a single shell command. Images based on Universal Blue bundle a set of these scripts, called recipes, which can be accessed with the `ujust` command.
7+
Just is a command runner (kind of like make) that can be used to supply arbitrary scripts under a single shell command.
8+
9+
### `blujust`
10+
11+
The `blujust` command will be installed if `ujust` is not detected. This will allow base image maintainers to take advantage of the pattern popularized by Ublue without having to directly depend on their images.
12+
13+
### `ujust`
14+
15+
Images based on Universal Blue bundle a set of these scripts, called recipes, which can be accessed with the `ujust` command.
1216

1317
For more information, refer to these links:
1418

modules/justfiles/blujust

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/bash
2+
3+
/usr/bin/just --justfile /usr/share/bluebuild/justfile "${@}"
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
uid := `id -u`
2+
shell := `grep :$(id -u): /etc/passwd | cut -d: -f7`
3+
4+
# Boot into this device's BIOS/UEFI screen
5+
bios:
6+
#!/usr/bin/bash
7+
if [ -d /sys/firmware/efi ]; then
8+
systemctl reboot --firmware-setup
9+
else
10+
echo "Rebooting to legacy BIOS from OS is not supported."
11+
fi
12+
13+
# Show BIOS info
14+
bios-info:
15+
#!/usr/bin/bash
16+
echo "Manufacturer: $(sudo dmidecode -s baseboard-manufacturer)"
17+
echo "Product Name: $(sudo dmidecode -s baseboard-product-name)"
18+
echo "Version: $(sudo dmidecode -s bios-version)"
19+
echo "Release Date: $(sudo dmidecode -s bios-release-date)"
20+
21+
# Show all messages from this boot
22+
logs-this-boot:
23+
sudo journalctl --no-hostname -b 0
24+
25+
# Show all messages from last boot
26+
logs-last-boot:
27+
sudo journalctl --no-hostname -b -1
28+
29+
# Check for local overrides
30+
check-local-overrides:
31+
#!/usr/bin/bash
32+
diff -r \
33+
--suppress-common-lines \
34+
--color="always" \
35+
--exclude "passwd*" \
36+
--exclude "group*" \
37+
--exclude="subgid*" \
38+
--exclude="subuid*" \
39+
--exclude="machine-id" \
40+
--exclude="adjtime" \
41+
--exclude="fstab" \
42+
--exclude="system-connections" \
43+
--exclude="shadow*" \
44+
--exclude="gshadow*" \
45+
--exclude="ssh_host*" \
46+
--exclude="cmdline" \
47+
--exclude="crypttab" \
48+
--exclude="hostname" \
49+
--exclude="localtime" \
50+
--exclude="locale*" \
51+
--exclude="*lock" \
52+
--exclude=".updated" \
53+
--exclude="*LOCK" \
54+
--exclude="vconsole*" \
55+
--exclude="00-keyboard.conf" \
56+
--exclude="grub" \
57+
--exclude="system.control*" \
58+
--exclude="cdi" \
59+
--exclude="default.target" \
60+
/usr/etc /etc 2>/dev/null | sed '/Binary\ files\ /d'
61+
62+
# Gather device info to a pastebin
63+
device-info:
64+
#!/usr/bin/bash
65+
fpaste <(rpm-ostree status) <(fpaste --sysinfo --printonly) <(flatpak list --columns=application,version,options)
66+
67+
# Measure Idle Power Draw
68+
check-idle-power-draw:
69+
#!/usr/bin/bash
70+
sudo powerstat -a -r
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set allow-duplicate-recipes := true
2+
set ignore-comments := true
3+
4+
_default:
5+
#!/usr/bin/bash
6+
/usr/bin/blujust --list --list-heading $'Available commands:\n' --list-prefix $' - '
7+
8+
# Imports
9+
import "/usr/share/ublue-os/just/00-default.just"
10+
import? "/usr/share/ublue-os/just/60-custom.just"

modules/justfiles/justfiles.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,32 @@ set -euo pipefail
44

55
get_json_array CONFIG_SELECTION 'try .["include"][]' "$1"
66
VALIDATE="$(echo "$1" | jq -r 'try .["validate"]')"
7+
INSTALL="$(echo "$1" | jq -r 'try .["install"]')"
8+
9+
if [ "${INSTALL}" = "true" ] && ! rpm -q just > /dev/null; then
10+
if command -v dnf5 > /dev/null; then
11+
dnf5 -y install just
12+
elif command -v dnf4 > /dev/null; then
13+
dnf4 -y install just
14+
else
15+
echo "No recognizable package manager! Expected dnf4 or dnf5."
16+
exit 1
17+
fi
18+
fi
719

8-
IMPORT_FILE="/usr/share/ublue-os/just/60-custom.just"
20+
if [ -x /usr/bin/ujust ]; then
21+
IMPORT_FILE="/usr/share/ublue-os/just/60-custom.just"
22+
else
23+
# Install blujust files
24+
if ! [ -f /usr/bin/blujust ]; then
25+
cp -f "${MODULE_DIRECTORY}/justfiles/blujust" /usr/bin/blujust
26+
chmod +x /usr/bin/blujust
27+
28+
mkdir -p /usr/share/bluebuild/
29+
cp -fr "${MODULE_DIRECTORY}/justfiles/blujust_files/*" /usr/share/bluebuild/
30+
fi
31+
IMPORT_FILE="/usr/share/bluebuild/just/60-custom.just"
32+
fi
933
CONFIG_FOLDER="${CONFIG_DIRECTORY}/justfiles"
1034
DEST_FOLDER="/usr/share/bluebuild/justfiles"
1135

modules/justfiles/justfiles.tsp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ model JustfilesModuleV1 {
1818

1919
/** List of files or subfolders to include into this image. If omitted, all justfiles will be included. */
2020
include?: Array<string>;
21+
22+
/** Install `just` via the package manager. * */
23+
install?: boolean = false;
2124
}

modules/justfiles/module.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ shortdesc: The justfiles module makes it easy to include just recipes from multi
33
example: |
44
type: justfiles
55
validate: true
6+
install: true
67
include:
78
- common
89
- gnome/monitors.just

0 commit comments

Comments
 (0)