init
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
ctx/
|
||||
repo/
|
||||
*.key
|
||||
*.pub
|
||||
.DS_Store
|
||||
102
binhost.sh
Normal file
102
binhost.sh
Normal file
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_URL="git@git.ayau.me:mira/gentoo-pill.git"
|
||||
WORK_DIR="$(pwd)"
|
||||
REPO="${WORK_DIR}/repo"
|
||||
CTX="${WORK_DIR}/ctx"
|
||||
|
||||
IMAGE="gentoo/stage3:amd64-desktop-openrc"
|
||||
PROFILE="default/linux/amd64/23.0/desktop"
|
||||
CFLAGS="-O2 -pipe -march=x86-64-v3"
|
||||
|
||||
if [[ ! -d "$REPO/.git" ]]; then
|
||||
git clone "$REPO_URL" "$REPO"
|
||||
else
|
||||
git -C "$REPO" pull --rebase
|
||||
fi
|
||||
|
||||
echo "Aggregating configuration..."
|
||||
rm -rf "$CTX" && mkdir -p "$CTX"/var/lib/portage
|
||||
|
||||
# config types to merge
|
||||
CONFIGS=(package.use package.accept_keywords package.license package.mask package.unmask package.env)
|
||||
|
||||
for type in "${CONFIGS[@]}"; do
|
||||
dest="$CTX/etc/portage/$type"
|
||||
mkdir -p "$dest"
|
||||
|
||||
inject() {
|
||||
local src=$1 prefix=$2
|
||||
[[ ! -e "$src" ]] && return
|
||||
|
||||
if [[ -d "$src" ]]; then
|
||||
for f in "$src"/*; do
|
||||
[[ -f "$f" ]] && cp "$f" "$dest/${prefix}-$(basename "$f")"
|
||||
done
|
||||
else
|
||||
cp "$src" "$dest/${prefix}-$(basename "$src")"
|
||||
fi
|
||||
}
|
||||
|
||||
inject "$REPO/common/$type" "00-common"
|
||||
|
||||
for host_dir in "$REPO/hosts"/*; do
|
||||
[[ -d "$host_dir" ]] || continue
|
||||
hostname=$(basename "$host_dir")
|
||||
inject "$host_dir/$type" "50-${hostname}"
|
||||
done
|
||||
done
|
||||
|
||||
# generate world union
|
||||
cat "$REPO"/hosts/*/world 2>/dev/null | sort -u | sed '/^#/d;/^$/d' > "$CTX/var/lib/portage/world"
|
||||
echo "Packages to build: $(wc -l < "$CTX/var/lib/portage/world")"
|
||||
|
||||
# make.conf
|
||||
mkdir -p "$CTX/etc/portage"
|
||||
cp "$REPO/binhost/make.conf" "$CTX/etc/portage/make.conf"
|
||||
{
|
||||
# we don't want build to fail bcs of EULA check..
|
||||
echo 'ACCEPT_LICENSE="*"'
|
||||
echo "CFLAGS=\"$CFLAGS\""
|
||||
echo "CXXFLAGS=\"$CFLAGS\""
|
||||
} >> "$CTX/etc/portage/make.conf"
|
||||
|
||||
echo "Starting Builder..."
|
||||
|
||||
VOLUMES=(
|
||||
-v portage_db:/var/db/repos/gentoo
|
||||
-v distfiles:/var/cache/distfiles
|
||||
-v binpkgs:/var/cache/binpkgs
|
||||
-v "$CTX/etc/portage/make.conf:/etc/portage/make.conf"
|
||||
-v "$CTX/var/lib/portage/world:/var/lib/portage/world"
|
||||
)
|
||||
|
||||
# add config dirs to volumes
|
||||
for type in "${CONFIGS[@]}"; do
|
||||
VOLUMES+=(-v "$CTX/etc/portage/$type:/etc/portage/$type")
|
||||
done
|
||||
|
||||
# start cooking
|
||||
podman run --rm -i \
|
||||
--name "gentoo_builder" \
|
||||
--cap-add=SYS_PTRACE \
|
||||
"${VOLUMES[@]}" \
|
||||
"$IMAGE" /bin/bash <<EOF
|
||||
set -e
|
||||
source /etc/profile
|
||||
|
||||
echo "> Syncing tree..."
|
||||
emerge-webrsync -q
|
||||
|
||||
echo "> Setting Profile..."
|
||||
eselect profile set "$PROFILE"
|
||||
|
||||
echo "> Building World..."
|
||||
emerge --verbose --buildpkg --update --deep --newuse --changed-use --with-bdeps=y --keep-going @world
|
||||
|
||||
echo "> Cleaning up..."
|
||||
emerge --depclean
|
||||
emaint binhost --fix
|
||||
EOF
|
||||
|
||||
25
binhost/make.conf
Normal file
25
binhost/make.conf
Normal file
@@ -0,0 +1,25 @@
|
||||
# These settings were set by the catalyst build script that automatically
|
||||
# built this stage.
|
||||
# Please consult /usr/share/portage/config/make.conf.example for a more
|
||||
# detailed example.
|
||||
COMMON_FLAGS="-O2 -pipe -march=x86-64-v3"
|
||||
CFLAGS="${COMMON_FLAGS}"
|
||||
CXXFLAGS="${COMMON_FLAGS}"
|
||||
FCFLAGS="${COMMON_FLAGS}"
|
||||
FFLAGS="${COMMON_FLAGS}"
|
||||
# RUSTFLAGS="${RUSTFLAGS} -C target-cpu=native"
|
||||
|
||||
# NOTE: This stage was built with the bindist USE flag enabled
|
||||
|
||||
# This sets the language of build output to English.
|
||||
# Please keep this setting intact when reporting bugs.
|
||||
LC_MESSAGES=C.UTF-8
|
||||
|
||||
USE="dist-kernel pulseaudio pipewire screencast -wayland"
|
||||
VIDEO_CARDS="intel nouveau"
|
||||
|
||||
# "buildpkg" = generate binary packages upon install
|
||||
# "binpkg-multi-instance" = keep only latest version, but support slotting
|
||||
FEATURES="${FEATURES} -getbinpkg buildpkg binpkg-multi-instance"
|
||||
|
||||
BINPKG_FORMAT="gpkg"
|
||||
3
common/package.license
Normal file
3
common/package.license
Normal file
@@ -0,0 +1,3 @@
|
||||
sys-kernel/linux-firmware @BINARY-REDISTRIBUTABLE
|
||||
sys-firmware/intel-microcode intel-ucode
|
||||
|
||||
7
common/package.use
Normal file
7
common/package.use
Normal file
@@ -0,0 +1,7 @@
|
||||
sys-apps/fwupd gnutls uefi
|
||||
sys-kernel/installkernel grub dracut
|
||||
media-video/pipewire sound-server pipewire-alsa extra bluetooth v4l ffmpeg
|
||||
media-video/wireplumber elogind
|
||||
media-libs/libsdl2 -pipewire
|
||||
app-admin/sudo offensive
|
||||
|
||||
60
gentoo-sync.sh
Executable file
60
gentoo-sync.sh
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
PILL_REPO="$HOME/gentoo-pill"
|
||||
HOSTNAME_TAG="${HOSTNAME:-$(hostname)}"
|
||||
|
||||
# remote trigger
|
||||
SERVER_USER="mira"
|
||||
SERVER_IP="192.168.102.148"
|
||||
SERVER_BINHOST_DIR="~/gentoo-pill"
|
||||
|
||||
HOST_DIR="$PILL_REPO/hosts/$HOSTNAME_TAG"
|
||||
echo "> Syncing configuration for: $HOSTNAME_TAG"
|
||||
|
||||
if [[ -d "$PILL_REPO/.git" ]]; then
|
||||
git -C "$PILL_REPO" pull --rebase --autostash
|
||||
else
|
||||
echo "Error: repo not found at $PILL_REPO"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$HOST_DIR"
|
||||
|
||||
echo "> Syncing World file component..."
|
||||
cp /var/lib/portage/world "$HOST_DIR/world"
|
||||
|
||||
CONFIGS=(package.use package.accept_keywords package.license package.mask package.unmask package.env)
|
||||
|
||||
echo "> Syncing Portage components..."
|
||||
for type in "${CONFIGS[@]}"; do
|
||||
local_src="/etc/portage/$type"
|
||||
repo_dest="$HOST_DIR/$type"
|
||||
|
||||
# rm -rf "$repo_dest"
|
||||
|
||||
if [[ -e "$local_src" ]]; then
|
||||
rsync -a --delete --copy-links "$local_src" "$HOST_DIR/"
|
||||
else
|
||||
rm -rf "$repo_dest"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "> Pushing..."
|
||||
cd "$PILL_REPO"
|
||||
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
git add .
|
||||
git commit -m "sync: $HOSTNAME_TAG $(date +'%Y-%m-%d %H:%M')"
|
||||
git push
|
||||
echo "> Changes pushed successfully."
|
||||
|
||||
# trigger the remote
|
||||
if [[ -n "$SERVER_IP" ]]; then
|
||||
echo "> Triggering binhost build @ [$SERVER_IP]..."
|
||||
ssh "${SERVER_USER}@${SERVER_IP}" \
|
||||
"cd ${SERVER_BINHOST_DIR} && ./binhost.sh"
|
||||
fi
|
||||
else
|
||||
echo "> No changes, binhost trig skipped"
|
||||
fi
|
||||
0
hosts/.keep
Normal file
0
hosts/.keep
Normal file
Reference in New Issue
Block a user