Skip to content

Commit 105173f

Browse files
author
MochiOS Team
committed
Initial mochios repo: full source tree, pkgbuilds, archiso profile, and CI workflow
0 parents  commit 105173f

85 files changed

Lines changed: 3664 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build.yml‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build MochiOS ISO
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
container:
14+
image: archlinux:latest
15+
options: --privileged
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Arch Linux
22+
run: |
23+
pacman-key --init
24+
pacman-key --populate archlinux
25+
echo "Server = https://mirror.rackspace.com/archlinux/\$repo/os/\$arch" > /etc/pacman.d/mirrorlist
26+
pacman -Sy --noconfirm
27+
28+
- name: Install build dependencies
29+
run: |
30+
pacman -S --needed --noconfirm \
31+
archiso \
32+
base-devel \
33+
sudo \
34+
go \
35+
python \
36+
python-urwid \
37+
squashfs-tools \
38+
dosfstools \
39+
mtools \
40+
openssl \
41+
zstd \
42+
fakeroot \
43+
debugedit
44+
45+
- name: Create mochi user with passwordless sudo
46+
run: |
47+
useradd -m mochi
48+
echo "mochi ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
49+
chown -R mochi:mochi /home/mochi
50+
51+
- name: Create GPG signing key
52+
run: |
53+
mkdir -p /home/mochi/.mochios-gnupg
54+
chmod 700 /home/mochi/.mochios-gnupg
55+
printf 'Key-Type: RSA\nKey-Length: 4096\nSubkey-Type: RSA\nSubkey-Length: 4096\nName-Real: MochiOS CI Signing Key\nName-Email: ci@mochios.dev\nExpire-Date: 0\n%%no-protection\n%%commit\n' | gpg --homedir /home/mochi/.mochios-gnupg --batch --gen-key
56+
mkdir -p repo/pubkey
57+
gpg --homedir /home/mochi/.mochios-gnupg --export --armor ci@mochios.dev > repo/pubkey/mochios-key.pub
58+
59+
- name: Build packages
60+
run: |
61+
chmod +x build.sh
62+
# Override paths for CI (we're at /__w/mochios/mochios or similar)
63+
export MOCHIOS_DIR="$PWD"
64+
export REPO_DIR="$PWD/repo"
65+
export OUT_DIR="$PWD/out"
66+
export ISO_DIR="$PWD/archiso-mochios"
67+
export WORK_DIR="/tmp/mochios-work"
68+
export GNUPGHOME="/home/mochi/.mochios-gnupg"
69+
export SIGN_KEY="ci@mochios.dev"
70+
bash build.sh 2>&1
71+
72+
- name: List ISO output
73+
run: |
74+
ls -lh out/*.iso 2>/dev/null || echo "No ISO found"
75+
ls -lh repo/os/x86_64/ 2>/dev/null || echo "No packages found"
76+
77+
- name: Upload ISO artifact
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: mochios-iso
81+
path: out/*.iso
82+
retention-days: 30
83+
84+
- name: Upload packages artifact
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: mochios-packages
88+
path: repo/os/x86_64/*.pkg.tar.zst
89+
retention-days: 30

‎.gitignore‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Build outputs
2+
out/
3+
*.iso
4+
*.pkg.tar.zst
5+
*.sig
6+
pkg/
7+
src/
8+
9+
# OS junk
10+
Thumbs.db
11+
.DS_Store
12+
13+
# IDE
14+
.vscode/
15+
.idea/
16+
*.swp
17+
*.swo
18+
19+
# Secrets
20+
privkey.pem
21+
**/privkey.pem
22+
*.key
23+
**/*.key
24+
25+
# GPG
26+
.mochios-gnupg/
27+
28+
# Temp
29+
/tmp/
30+
*.tmp
31+
32+
# Generated tarballs (CI regenerates)
33+
pkgbuilds/mochi/*.tar.gz
34+
pkgbuilds/mochiinstall/*.tar.gz
35+
pkgbuilds/mochi-abroot/*.tar.gz
36+
pkgbuilds/mochios-defaults/*.tar.gz
37+
pkgbuilds/mochios-branding/*.tar.gz

‎abroot.sh‎

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/bin/bash
2+
# abroot - A/B root atomic update manager for mochios
3+
# manages two root subvolumes (root_a, root_b) on btrfs
4+
5+
set -euo pipefail
6+
7+
CONF="${CONF:-/etc/abroot.conf}"
8+
9+
if [ -f "$CONF" ]; then
10+
source "$CONF"
11+
fi
12+
13+
ROOT_PART="${ROOT_PART:-/dev/mapper/mochios-root}"
14+
BTRFS_MOUNT="${BTRFS_MOUNT:-/mnt/btrfs}"
15+
ACTIVE_ROOT="${ACTIVE_ROOT:-root_a}"
16+
NEXT_ROOT="${NEXT_ROOT:-root_b}"
17+
18+
mount_btrfs() {
19+
if ! mountpoint -q "$BTRFS_MOUNT"; then
20+
mkdir -p "$BTRFS_MOUNT"
21+
mount "$ROOT_PART" "$BTRFS_MOUNT"
22+
fi
23+
}
24+
25+
mount_chroot() {
26+
local target="$1"
27+
mkdir -p "$target"
28+
mount --bind "$BTRFS_MOUNT/$NEXT_ROOT" "$target"
29+
mount --bind /dev "$target/dev"
30+
mount --bind /proc "$target/proc"
31+
mount --bind /sys "$target/sys"
32+
if mountpoint -q /boot 2>/dev/null; then
33+
mkdir -p "$target/boot"
34+
mount --bind /boot "$target/boot"
35+
fi
36+
}
37+
38+
umount_chroot() {
39+
local target="$1"
40+
umount "$target/dev" 2>/dev/null || true
41+
umount "$target/proc" 2>/dev/null || true
42+
umount "$target/sys" 2>/dev/null || true
43+
umount "$target/boot" 2>/dev/null || true
44+
umount "$target" 2>/dev/null || true
45+
}
46+
47+
status() {
48+
mount_btrfs
49+
echo "active: $ACTIVE_ROOT"
50+
echo "next: $NEXT_ROOT"
51+
echo "---"
52+
btrfs subvolume list "$BTRFS_MOUNT" 2>/dev/null || true
53+
echo "---"
54+
ls "$BTRFS_MOUNT/snapshots/" 2>/dev/null || echo "no snapshots"
55+
}
56+
57+
deploy() {
58+
mount_btrfs
59+
60+
local snapshot="$BTRFS_MOUNT/snapshots/$(date +%Y%m%d_%H%M%S)_$ACTIVE_ROOT"
61+
mkdir -p "$BTRFS_MOUNT/snapshots"
62+
echo "creating snapshot: $(basename "$snapshot")"
63+
btrfs subvolume snapshot -r "$BTRFS_MOUNT/$ACTIVE_ROOT" "$snapshot"
64+
65+
echo "updating $NEXT_ROOT..."
66+
btrfs subvolume delete "$BTRFS_MOUNT/$NEXT_ROOT" 2>/dev/null || true
67+
btrfs subvolume snapshot "$BTRFS_MOUNT/$ACTIVE_ROOT" "$BTRFS_MOUNT/$NEXT_ROOT"
68+
69+
local target="/mnt/next"
70+
mount_chroot "$target"
71+
72+
echo "running pacman in $NEXT_ROOT..."
73+
if [ $# -eq 0 ]; then
74+
arch-chroot "$target" pacman --noconfirm -Syu
75+
else
76+
arch-chroot "$target" pacman --noconfirm -S "$@"
77+
fi
78+
79+
umount_chroot "$target"
80+
echo "update deployed to $NEXT_ROOT"
81+
echo "reboot and select $NEXT_ROOT to apply"
82+
}
83+
84+
rollback() {
85+
mount_btrfs
86+
local latest
87+
latest=$(ls -t "$BTRFS_MOUNT/snapshots/" 2>/dev/null | head -1)
88+
if [ -z "$latest" ]; then
89+
echo "no snapshots found"
90+
exit 1
91+
fi
92+
echo "rolling back to: $latest"
93+
echo "WARNING: this will DELETE the current $ACTIVE_ROOT subvolume"
94+
if [ "${1:--}" != "-f" ] && [ "${1:--}" != "--force" ]; then
95+
read -rp "are you sure? [y/N] " confirm
96+
case "$confirm" in
97+
[yY]*) ;;
98+
*) echo "rollback cancelled"; exit 1 ;;
99+
esac
100+
fi
101+
btrfs subvolume delete "$BTRFS_MOUNT/$ACTIVE_ROOT"
102+
btrfs subvolume snapshot "$BTRFS_MOUNT/snapshots/$latest" "$BTRFS_MOUNT/$ACTIVE_ROOT"
103+
echo "rolled back to $latest"
104+
}
105+
106+
case "${1:-status}" in
107+
status)
108+
status
109+
;;
110+
deploy)
111+
shift
112+
deploy "$@"
113+
;;
114+
rollback)
115+
shift
116+
rollback "$@"
117+
;;
118+
list-snapshots|snapshot)
119+
mount_btrfs
120+
echo "snapshots:"
121+
ls -lt "$BTRFS_MOUNT/snapshots/" 2>/dev/null || echo "no snapshots"
122+
;;
123+
*)
124+
echo "usage: abroot {status|deploy|rollback|snapshot}"
125+
exit 1
126+
;;
127+
esac
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# mochios mkinitcpio preset
2+
MODULES=(ata_piix ahci nvme)
3+
HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block encrypt filesystems fsck)

‎airootfs/etc/mochios-release‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MOCHIOS_BUILD_ID="rolling"
2+
MOCHIOS_BUILD_DATE="$(date +%Y-%m-%d)"
3+
MOCHIOS_VERSION="0.1.0"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Autologin]
2+
User=mochi
3+
Session=plasma.desktop
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Theme]
2+
Current=mochios
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# mochi user passwordless sudo for live environment
2+
mochi ALL=(ALL:ALL) NOPASSWD: ALL
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Desktop Entry]
2+
Type=Application
3+
Name=MochiOS Wallpaper
4+
Comment=Set MochiOS wallpaper
5+
Exec=mochi-wallpaper light
6+
Terminal=false
7+
X-KDE-autostart-phase=2
8+
NoDisplay=true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Desktop Entry]
2+
Type=Application
3+
Name=MochiOS Installer
4+
Comment=Install MochiOS to your system
5+
Exec=konsole -e mochiinstall
6+
Terminal=false
7+
Categories=System;
8+
X-KDE-autostart-phase=2
9+
X-KDE-autostart-after=panel
10+

0 commit comments

Comments
 (0)