Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chroot: add support for XDG_CONFIG_HOME/pacman/makepkg.conf #1289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

romanstingler
Copy link

Allow users to override makepkg.conf settings by placing a config file in $XDG_CONFIG_HOME/pacman/makepkg.conf. When present, this config will be mounted read-only in the chroot at /etc/makepkg.conf.d/xdg.conf, allowing its settings to take precedence over the base config.

Closes #1283

Allow users to override makepkg.conf settings by placing a config file
in $XDG_CONFIG_HOME/pacman/makepkg.conf. When present, this config
will be mounted read-only in the chroot at /etc/makepkg.conf.d/xdg.conf,
allowing its settings to take precedence over the base config.

Closes Morganamilo#1283
@romanstingler
Copy link
Author

I tried with this quick and dirty script

#!/bin/sh
set -e

# Test directory setup
TEST_ROOT="/tmp/paru_test"
CHROOT_DIR="$TEST_ROOT/chroot"
XDG_CONFIG_HOME="$TEST_ROOT/config"
export XDG_CONFIG_HOME

# Clean up previous test if exists
rm -rf "$TEST_ROOT"

# Create test directories and configs
mkdir -p "$CHROOT_DIR"
mkdir -p "$XDG_CONFIG_HOME/pacman"

# Create test makepkg.conf with distinctive settings
cat > "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<EOF
PKGEXT='.pkg.tar'
BUILDDIR=/tmp/custom_build
PACKAGER="Test User <[email protected]>"
EOF

# Initialize the chroot with basic packages
echo "Creating chroot environment..."
sudo pacstrap -c "$CHROOT_DIR" base

# Create a basic system makepkg.conf
sudo tee "$CHROOT_DIR/etc/makepkg.conf" > /dev/null <<EOF
PKGEXT='.pkg.tar.zst'
BUILDDIR=/tmp/makepkg
PACKAGER="System <[email protected]>"
EOF

# Copy XDG config to chroot
sudo mkdir -p "$CHROOT_DIR/etc/makepkg.conf.d"
sudo cp "$XDG_CONFIG_HOME/pacman/makepkg.conf" "$CHROOT_DIR/etc/makepkg.conf.d/xdg.conf"

# Test config precedence
echo "=== Testing makepkg.conf settings ==="
sudo chroot "$CHROOT_DIR" /bin/bash <<'CHROOT_SCRIPT'
echo "Base makepkg.conf:"
cat /etc/makepkg.conf
echo -e "\nXDG config makepkg.conf:"
cat /etc/makepkg.conf.d/xdg.conf
echo -e "\nTesting variable precedence:"
. /etc/makepkg.conf
if [ -d /etc/makepkg.conf.d ]; then
    for conf in /etc/makepkg.conf.d/*.conf; do
        if [ -f "$conf" ]; then
            echo "Sourcing $conf"
            . "$conf"
        fi
    done
fi
echo -e "\nFinal values:"
echo "PKGEXT=$PKGEXT"
echo "BUILDDIR=$BUILDDIR"
echo "PACKAGER=$PACKAGER"
CHROOT_SCRIPT

@cwrau
Copy link

cwrau commented Dec 16, 2024

This fails for me with Failed to create mount point /var/lib/aurbuild/x86_64/root/etc/makepkg.conf.d/xdg.conf: Read-only file system

I assume because it also read-only mounts --bind-ro /etc/makepkg.conf.d:/etc/makepkg.conf.d?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

paru not using $XDG_CONFIG_HOME/pacman/makepkg.conf inside CHROOT
2 participants