Refactor work

This commit is contained in:
Ryan Hughes committed 2025-11-16 19:31:01 -05:00
1 parent 4ded01b207
commit 76699b4de0
9 files changed
+730 -142

No files matched your search

+143
View File
@@ -0,0 +1,143 @@
# Omarchy ISO Builder
## Overview
The ISO build system now integrates local package building for development workflows.
## Build Scripts
### build-iso.sh
Main ISO build script that:
1. Sets up Arch Linux build environment
2. Builds omarchy-settings package locally (if omarchy-pkgs mounted)
3. Installs omarchy-settings in the ISO
4. Downloads remaining packages to offline mirror
5. Assembles the final ISO image
### build-omarchy-packages.sh
Builds omarchy-settings package locally from source:
- Runs inside Docker container
- Builds as `nobody` user (makepkg requirement)
- Outputs package to `/tmp/omarchy-pkg-build/`
- Exports `OMARCHY_SETTINGS_PKG` variable for build-iso.sh
## Package Integration
### omarchy-settings
**Installed in ISO** - Provides EVERYTHING needed:
- User skeleton files (`/etc/skel/`)
- System configurations (`/etc/`)
- Plymouth boot theme
- Essential binaries (`omarchy-debug`, `omarchy-upload-log`)
- Install scripts (`/usr/share/omarchy/install/`)
- Default configs and migrations
**Size**: ~5-10MB
**Purpose**: Complete self-contained package for ISO - no git clone needed!
### omarchy (future)
**In offline mirror** - Full desktop environment:
- All omarchy-* binaries
- Install scripts and migrations
- Themes and assets
- Heavy dependencies (Hyprland, Waybar, etc.)
**Installed during**: Post-install phase in chroot
## Development Workflow
### Quick Build
```bash
# From omarchy-iso directory (uses default paths)
omarchy-iso-make-dev
# Or with custom paths
export OMARCHY_PKGS_PATH=/path/to/pkgs
export OMARCHY_INSTALLER_PATH=/path/to/installer
omarchy-iso-make-dev
```
This will:
1. Mount omarchy-pkgs into Docker container
2. Mount omarchy-installer (if OMARCHY_INSTALLER_PATH set)
3. Build omarchy-settings from local source
4. Install it in the ISO
5. Create bootable ISO with latest changes
See [ENV_VARS.md](../ENV_VARS.md) for all configuration options.
### Without Package Build
If `omarchy-pkgs` directory is not mounted:
- **Build will fail** with helpful error message
- The ISO build now requires omarchy-settings package
- No fallback to git clone (removed for simplicity)
- Set `OMARCHY_PKGS_PATH` to enable builds
## Directory Structure
```
omarchy-iso/
├── bin/
│ └── omarchy-iso-make # Main entry point (updated to mount omarchy-pkgs)
├── builder/
│ ├── build-iso.sh # Main ISO build (updated for package integration)
│ ├── build-omarchy-packages.sh # New: Local package builder
│ └── README.md # This file
├── configs/
│ ├── profiledef.sh # ISO profile (updated to remove manual file perms)
│ └── ...
└── release/
└── omarchy-*.iso # Built ISOs
```
## How It Works
1. **omarchy-iso-make** detects `../omarchy-pkgs` directory
2. Mounts it read-only into Docker container at `/omarchy-pkgs`
3. **build-iso.sh** checks for `/omarchy-pkgs` mount (REQUIRED!)
4. Sources **build-omarchy-packages.sh** to build package
5. Package is built with makepkg as `nobody` user
6. Built package added to `packages.x86_64` list
7. Copied to offline mirror
8. mkarchiso installs it during ISO assembly
9. ISO boots with omarchy-settings pre-installed
10. **Everything works from package** - no git clone, no manual copying!
## Benefits
### For Development
- ✅ No need to publish packages for testing
- ✅ Instant iteration on configs and binaries
- ✅ Test package integration in real ISO environment
- ✅ Single command builds everything
### For Production
- ✅ Same workflow works with published packages
- ✅ Fallback to manual copying if needed
- ✅ Reproducible builds
- ✅ Version-locked packages
## Troubleshooting
### Package build fails
```bash
# Check that omarchy-pkgs is mounted
docker run --rm -v "$PWD/../omarchy-pkgs:/omarchy-pkgs:ro" archlinux ls -la /omarchy-pkgs
```
### Manual file copying used instead of package
- Ensure omarchy-pkgs directory exists at `../omarchy-pkgs`
- Check Docker mount in omarchy-iso-make
- Look for "Mounting omarchy-pkgs" message during build
### Permission errors
- build-omarchy-packages.sh runs makepkg as `nobody` user
- Temporary sudo access granted for pacman operations
- Cleaned up after build
## Future Enhancements
1. Build full `omarchy` package locally
2. Remove git clone of omarchy-installer entirely
3. Use only packages for all file installation
4. Support building other omarchy-* packages
+66 -19
View File
@@ -30,21 +30,41 @@ rm -rf "$build_cache_dir/airootfs/etc/xdg/reflector"
# Bring in our configs
cp -r /configs/* $build_cache_dir/
# Setup Omarchy itself
if [[ -d /omarchy ]]; then
cp -rp /omarchy "$build_cache_dir/airootfs/root/omarchy"
# Build omarchy-settings package locally
# This package provides EVERYTHING needed for the ISO:
# - User configs (/etc/skel/)
# - System configs (/etc/)
# - Plymouth theme
# - Essential binaries (debug, upload-log)
# - Install scripts (/usr/share/omarchy/install/)
if [ -d "/omarchy-pkgs" ]; then
echo "========================================="
echo "Building omarchy-settings package locally"
echo "========================================="
source /builder/build-omarchy-packages.sh
# Add omarchy packages to ISO
# omarchy-settings provides configs and will be installed in ISO
# omarchy-installer provides install scripts and will be installed in ISO
echo "omarchy-settings" >> "$build_cache_dir/packages.x86_64"
echo "omarchy-installer" >> "$build_cache_dir/packages.x86_64"
# Copy built packages to offline mirror (for installation on target system)
cp "$OMARCHY_SETTINGS_PKG" "$offline_mirror_dir/"
cp "$OMARCHY_INSTALLER_PKG" "$offline_mirror_dir/"
cp "$OMARCHY_PKG" "$offline_mirror_dir/"
echo "✓ omarchy-settings will be installed in ISO (configs, binaries)"
echo "✓ omarchy-installer will be installed in ISO (install scripts, helpers)"
echo "✓ All omarchy packages available in offline mirror for installation"
echo "✓ No git clone needed - everything comes from packages!"
else
git clone -b $OMARCHY_INSTALLER_REF https://github.com/$OMARCHY_INSTALLER_REPO.git "$build_cache_dir/airootfs/root/omarchy"
echo "ERROR: /omarchy-pkgs not mounted!"
echo "The ISO build now requires omarchy-settings package."
echo "Please set OMARCHY_PKGS_PATH or ensure ../omarchy-pkgs exists."
exit 1
fi
# Make log uploader available in the ISO too
mkdir -p "$build_cache_dir/airootfs/usr/local/bin/"
cp "$build_cache_dir/airootfs/root/omarchy/bin/omarchy-upload-log" "$build_cache_dir/airootfs/usr/local/bin/omarchy-upload-log"
# Copy the Omarchy Plymouth theme to the ISO
mkdir -p "$build_cache_dir/airootfs/usr/share/plymouth/themes/omarchy"
cp -r "$build_cache_dir/airootfs/root/omarchy/default/plymouth/"* "$build_cache_dir/airootfs/usr/share/plymouth/themes/omarchy/"
# Download and verify Node.js binary for offline installation
NODE_DIST_URL="https://nodejs.org/dist/latest"
@@ -67,19 +87,41 @@ mkdir -p "$build_cache_dir/airootfs/opt/packages/"
cp "/tmp/$NODE_FILENAME" "$build_cache_dir/airootfs/opt/packages/"
# Add our additional packages to packages.x86_64
arch_packages=(linux-t2 git gum jq openssl plymouth tzupdate omarchy-keyring)
arch_packages=(linux-t2 git gum jq openssl plymouth tzupdate omarchy-keyring python-terminaltexteffects)
printf '%s\n' "${arch_packages[@]}" >>"$build_cache_dir/packages.x86_64"
# Build list of all the packages needed for the offline mirror
all_packages=($(cat "$build_cache_dir/packages.x86_64"))
all_packages+=($(grep -v '^#' "$build_cache_dir/airootfs/root/omarchy/install/omarchy-base.packages" | grep -v '^$'))
all_packages+=($(grep -v '^#' "$build_cache_dir/airootfs/root/omarchy/install/omarchy-other.packages" | grep -v '^$'))
all_packages+=($(grep -v '^#' /builder/archinstall.packages | grep -v '^$'))
# Start with packages.x86_64 but exclude locally-built packages
all_packages=($(cat "$build_cache_dir/packages.x86_64" | grep -vE '^(omarchy|omarchy-settings|omarchy-installer)$'))
# Add omarchy package lists from source, excluding locally-built packages
if [ -n "$OMARCHY_INSTALLER_SRC" ] && [ -d "$OMARCHY_INSTALLER_SRC" ]; then
# Filter out locally-built packages and known problematic packages
all_packages+=($(grep -v '^#' "$OMARCHY_INSTALLER_SRC/install/omarchy-base.packages" | grep -v '^$' | grep -vE '^(omarchy|omarchy-settings|omarchy-installer)$'))
all_packages+=($(grep -v '^#' "$OMARCHY_INSTALLER_SRC/install/omarchy-other.packages" | grep -v '^$' | grep -vE '^qt5-remoteobjects$'))
else
echo "WARNING: Could not find omarchy package lists, offline mirror may be incomplete"
fi
all_packages+=($(grep -v '^#' /builder/archinstall.packages | grep -v '^$' | grep -vE '^(omarchy|omarchy-settings|omarchy-installer)$'))
# Remove duplicates
all_packages=($(printf '%s\n' "${all_packages[@]}" | sort -u))
# Download all the packages to the offline mirror inside the ISO
# Use --needed to skip packages that are already in cache
# Use --noconfirm to avoid interactive prompts
mkdir -p /tmp/offlinedb
pacman --config /configs/pacman-online.conf --noconfirm -Syw "${all_packages[@]}" --cachedir $offline_mirror_dir/ --dbpath /tmp/offlinedb
repo-add --new "$offline_mirror_dir/offline.db.tar.gz" "$offline_mirror_dir/"*.pkg.tar.zst
echo "Downloading ${#all_packages[@]} packages to offline mirror..."
pacman --config /configs/pacman-online.conf --noconfirm -Syw "${all_packages[@]}" --cachedir $offline_mirror_dir/ --dbpath /tmp/offlinedb --needed
# Build repository database for the offline mirror
# First, create the database from all downloaded packages
echo "Building offline repository database..."
repo-add "$offline_mirror_dir/offline.db.tar.gz" "$offline_mirror_dir/"*.pkg.tar.zst
# Note: Our locally built packages (omarchy, omarchy-settings) were copied earlier
# and are now included in the repository database
# Create a symlink to the offline mirror instead of duplicating it.
# mkarchiso needs packages at /var/cache/omarchy/mirror/offline in the container,
@@ -91,6 +133,11 @@ ln -s "$offline_mirror_dir" "/var/cache/omarchy/mirror/offline"
# same config when booted
cp $build_cache_dir/pacman.conf "$build_cache_dir/airootfs/etc/pacman.conf"
# Create missing device-mapper udev rules file to silence mkinitcpio warning
# This file was removed in recent device-mapper versions but mkinitcpio still references it
mkdir -p /usr/lib/initcpio/udev
touch /usr/lib/initcpio/udev/11-dm-initramfs.rules
# Finally, we assemble the entire ISO
mkarchiso -v -w "$build_cache_dir/work/" -o "/out/" "$build_cache_dir/"
+203
View File
@@ -0,0 +1,203 @@
#!/bin/bash
# Build omarchy packages locally for ISO integration
# This runs inside the Docker container during ISO build
set -e
echo "========================================="
echo "Building omarchy-settings package locally"
echo "========================================="
# Packages will be built in /tmp/omarchy-pkg-build
BUILD_DIR="/tmp/omarchy-pkg-build"
# Clean old builds to avoid checksum issues
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
# Create a writable build directory
WORK_DIR="/tmp/omarchy-pkg-work"
# Clean old work directory
rm -rf "$WORK_DIR"
mkdir -p "$WORK_DIR"
# Copy package files to writable location
echo "Setting up build directory..."
cp -r /omarchy-pkgs/pkgbuilds/omarchy-settings "$WORK_DIR/"
cd "$WORK_DIR/omarchy-settings"
# Set PKGDEST to control where built packages go
export PKGDEST="$BUILD_DIR"
# Check if we should use dev build (local source)
if [ -n "$OMARCHY_DEV_BUILD" ] && [ -d "/omarchy-installer" ]; then
echo "========================================="
echo "DEV MODE: Using locally mounted source"
echo "========================================="
# Source the dev PKGBUILD patch
source /builder/templates/dev-pkgbuild-patch.sh
convert_to_dev_pkgbuild "PKGBUILD"
# Ensure local source is accessible
mkdir -p src
ln -sf /omarchy-installer src/omarchy-installer
BUILD_FILE="PKGBUILD.dev"
BUILD_FLAGS="--noconfirm --skippgpcheck --skipchecksums --noextract"
echo "✓ Will build from local source (no git clone)"
else
echo "========================================="
echo "PRODUCTION MODE: Using git source"
echo "========================================="
BUILD_FILE="PKGBUILD"
BUILD_FLAGS="--noconfirm --skippgpcheck"
echo "✓ Will git clone from repository"
fi
# Sync package databases (needed for dependency resolution)
echo "Syncing package databases..."
pacman -Sy --noconfirm
# Build the package
# Note: The container runs as root, but makepkg refuses to run as root
# Create a fresh build user (nobody account is expired in base image)
if ! id builder &>/dev/null; then
useradd -m -s /bin/bash builder
fi
# Give builder ownership
chown -R builder:builder "$WORK_DIR/omarchy-settings"
chown -R builder:builder "$BUILD_DIR"
# Allow builder to run pacman without password (needed for dependency installation)
echo "builder ALL=(ALL) NOPASSWD: /usr/bin/pacman" > /etc/sudoers.d/99-builder-pacman
chmod 440 /etc/sudoers.d/99-builder-pacman
# Build the package as builder user (makepkg will install dependencies via sudo)
su builder -c "cd $WORK_DIR/omarchy-settings && makepkg -p $BUILD_FILE $BUILD_FLAGS -s"
# Find the built package
BUILT_PACKAGE=$(ls -t "$BUILD_DIR"/omarchy-settings-*.pkg.tar.zst 2>/dev/null | head -n1)
if [ -z "$BUILT_PACKAGE" ]; then
echo "ERROR: Failed to build omarchy-settings package"
exit 1
fi
echo "✓ Successfully built: $(basename $BUILT_PACKAGE)"
echo "Package location: $BUILT_PACKAGE"
# Export the path for use by build-iso.sh
export OMARCHY_SETTINGS_PKG="$BUILT_PACKAGE"
# Export the source directory for accessing package lists before package is installed
# Check both possible locations (dev mode uses /omarchy-installer, prod uses src/)
if [ -d "/omarchy-installer" ]; then
export OMARCHY_INSTALLER_SRC="/omarchy-installer"
echo "✓ Package source available at: $OMARCHY_INSTALLER_SRC (mounted)"
elif [ -d "$WORK_DIR/omarchy-settings/src/omarchy-installer" ]; then
export OMARCHY_INSTALLER_SRC="$WORK_DIR/omarchy-settings/src/omarchy-installer"
echo "✓ Package source available at: $OMARCHY_INSTALLER_SRC (from build)"
fi
echo "✓ Package contains everything needed for ISO (configs, package lists, binaries, theme)"
# Now build the omarchy-installer package
echo ""
echo "========================================="
echo "Building omarchy-installer package"
echo "========================================="
# Copy omarchy-installer package files to writable location
cp -r /omarchy-pkgs/pkgbuilds/omarchy-installer "$WORK_DIR/"
cd "$WORK_DIR/omarchy-installer"
# Check if we should use dev build
if [ -n "$OMARCHY_DEV_BUILD" ] && [ -d "/omarchy-installer" ]; then
echo "DEV MODE: Using locally mounted source"
# Generate dev PKGBUILD
source /builder/templates/dev-pkgbuild-patch.sh
convert_to_dev_pkgbuild "PKGBUILD"
# Symlink local source
mkdir -p src
ln -sf /omarchy-installer src/omarchy-installer
INSTALLER_BUILD_FILE="PKGBUILD.dev"
INSTALLER_BUILD_FLAGS="--noconfirm --skippgpcheck --skipchecksums --noextract"
else
echo "PRODUCTION MODE: Using git source"
INSTALLER_BUILD_FILE="PKGBUILD"
INSTALLER_BUILD_FLAGS="--noconfirm --skippgpcheck"
fi
# Give builder ownership
chown -R builder:builder "$WORK_DIR/omarchy-installer"
# Build the omarchy-installer package
su builder -c "cd $WORK_DIR/omarchy-installer && makepkg -p $INSTALLER_BUILD_FILE $INSTALLER_BUILD_FLAGS -d"
# Find the built package
OMARCHY_INSTALLER_PKG=$(ls -t "$BUILD_DIR"/omarchy-installer-*.pkg.tar.zst 2>/dev/null | head -n1)
if [ -z "$OMARCHY_INSTALLER_PKG" ]; then
echo "ERROR: Failed to build omarchy-installer package"
exit 1
fi
echo "✓ Successfully built: $(basename $OMARCHY_INSTALLER_PKG)"
echo "Package location: $OMARCHY_INSTALLER_PKG"
# Now build the full omarchy package for offline mirror
echo ""
echo "========================================="
echo "Building omarchy meta-package"
echo "========================================="
# Copy omarchy package files to writable location
cp -r /omarchy-pkgs/pkgbuilds/omarchy "$WORK_DIR/"
cd "$WORK_DIR/omarchy"
# Check if we should use dev build
if [ -n "$OMARCHY_DEV_BUILD" ] && [ -d "/omarchy-installer" ]; then
echo "DEV MODE: Using locally mounted source"
# Generate dev PKGBUILD
source /builder/templates/dev-pkgbuild-patch.sh
convert_to_dev_pkgbuild "PKGBUILD"
# Symlink local source
mkdir -p src
ln -sf /omarchy-installer src/omarchy-installer
OMARCHY_BUILD_FILE="PKGBUILD.dev"
OMARCHY_BUILD_FLAGS="--noconfirm --skippgpcheck --skipchecksums --noextract"
else
echo "PRODUCTION MODE: Using git source"
OMARCHY_BUILD_FILE="PKGBUILD"
OMARCHY_BUILD_FLAGS="--noconfirm --skippgpcheck"
fi
# Give builder ownership
chown -R builder:builder "$WORK_DIR/omarchy"
# Build the omarchy package
# Note: Skip dependency checks (-d) since we're just packaging files, not running them
# The dependencies will be resolved when the package is installed in the actual system
su builder -c "cd $WORK_DIR/omarchy && makepkg -p $OMARCHY_BUILD_FILE $OMARCHY_BUILD_FLAGS -d"
# Find the built package
OMARCHY_PKG=$(ls -t "$BUILD_DIR"/omarchy-*.pkg.tar.zst 2>/dev/null | head -n1)
if [ -z "$OMARCHY_PKG" ]; then
echo "ERROR: Failed to build omarchy package"
exit 1
fi
echo "✓ Successfully built: $(basename $OMARCHY_PKG)"
echo "Package location: $OMARCHY_PKG"
# Export for use by build-iso.sh
export OMARCHY_PKG="$OMARCHY_PKG"
export OMARCHY_INSTALLER_PKG="$OMARCHY_INSTALLER_PKG"
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
# Patch to convert production PKGBUILD to dev PKGBUILD
# This script modifies PKGBUILD to use local source instead of git clone
convert_to_dev_pkgbuild() {
local pkgbuild_path="$1"
local dev_pkgbuild_path="${pkgbuild_path}.dev"
echo "Creating dev PKGBUILD from production version..."
# Copy production PKGBUILD
cp "$pkgbuild_path" "$dev_pkgbuild_path"
# Remove git source (replace with empty source array)
sed -i '/^source=/c\source=()' "$dev_pkgbuild_path"
sed -i '/^sha256sums=/c\sha256sums=()' "$dev_pkgbuild_path"
# Add prepare() function to symlink local source
# Insert after the source line
cat >> "$dev_pkgbuild_path" << 'EOF'
# Dev build: use locally mounted source
prepare() {
# Symlink local omarchy-installer source
if [ -d "/omarchy-installer" ]; then
ln -sf /omarchy-installer "$srcdir/omarchy-installer"
echo "Using locally mounted omarchy-installer from /omarchy-installer"
elif [ -f "/omarchy-pkgs/pkgbuilds/omarchy-settings/src/omarchy-installer" ]; then
# Fallback: use source from previous build
echo "Using omarchy-installer from previous package build"
else
error "No local omarchy-installer source found!"
return 1
fi
}
EOF
echo "✓ Dev PKGBUILD created: $dev_pkgbuild_path"
}