public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/binhost:master commit in: builders/milou/gnome-23/portage/variants/lucky/, ...
@ 2024-09-11  0:32 Eli Schwartz
  0 siblings, 0 replies; only message in thread
From: Eli Schwartz @ 2024-09-11  0:32 UTC (permalink / raw
  To: gentoo-commits

commit:     d06884c8ce125cf6ee217afbb38cdb5b3fe1d101
Author:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 10 19:17:53 2024 +0000
Commit:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
CommitDate: Wed Sep 11 00:31:02 2024 +0000
URL:        https://gitweb.gentoo.org/proj/binhost.git/commit/?id=d06884c8

Add variant mechanism to build temporary packages.

Build some variants for gnome, to demonstrate how:
- nopulse
- an "I'm feeling lucky" mode that randomly attempts to build one of the
  ten thousand packages with stable keywords that isn't yet installed
  via autounmask
- compile some unstable compilers via --buildpkgonly. Nothing is ever
  installed or can mix with the system, so it cannot ever have an effect
  on other binhost packages. But users can install upcoming compilers
  for testing.

Variant builds are built in an ephemeral nspawn container based on the
original one. The primary build has to succeed in order to build a
variant, otherwise we assume resolution fails anyway. The ephemeral
container means we can freely modify the portage config, even in totally
broken ways, and our changes get automatically wiped after exiting. The
only persistent data is the binpkgs cache, which is mounted from the
real location.

Signed-off-by: Eli Schwartz <eschwartz <AT> gentoo.org>

 builders/milou/binhost-update                      | 17 ++++++++--
 .../gnome-23/portage/variants/lucky/.run_marker    |  1 +
 .../portage/variants/nopulse/package.use/nopulse   |  1 +
 .../portage/variants/unstable/buildpkgonly         |  9 +++++
 .../variants/unstable/package.accept_keywords/gcc  |  2 ++
 builders/milou/gnome-23/run-update                 | 38 ++++++++++++++++++++--
 .../gnome-v3-23/portage/variants/lucky/.run_marker |  1 +
 .../portage/variants/nopulse/package.use/nopulse   |  1 +
 .../portage/variants/unstable/buildpkgonly         |  9 +++++
 .../variants/unstable/package.accept_keywords/gcc  |  2 ++
 builders/milou/gnome-v3-23/run-update              | 38 ++++++++++++++++++++--
 11 files changed, 112 insertions(+), 7 deletions(-)

diff --git a/builders/milou/binhost-update b/builders/milou/binhost-update
index 8a304dd..d48e15e 100755
--- a/builders/milou/binhost-update
+++ b/builders/milou/binhost-update
@@ -113,15 +113,26 @@ emerge --sync -q &>> ${TMPFILE}
 
 anyfail=0
 
+nspawn_command=(systemd-nspawn --bind /var/cache/distfiles --bind-ro /var/db/repos/gentoo --tmpfs=/var/tmp:mode=1777,size=${TMPFS_SIZE}g)
 for n in ${NSPAWN_NAMES} ; do
+	machinedir=/var/lib/machines/${n}
 	echo Machine ${n} &>> ${TMPFILE}
 	echo &>> ${TMPFILE}
-	cd /var/lib/machines/${n}/etc/binhost &>> ${TMPFILE}
+	cd ${machinedir}/etc/binhost &>> ${TMPFILE}
 	git reset --hard &>> ${TMPFILE}
 	git pull &>> ${TMPFILE}
 	cd /root &>> ${TMPFILE}
-	systemd-nspawn --bind /var/cache/distfiles --bind-ro /var/db/repos/gentoo --tmpfs=/var/tmp:mode=1777,size=${TMPFS_SIZE}g -M ${n} /root/bin/run-update &>> ${TMPFILE}
-	let "anyfail+=$?"
+	"${nspawn_command[@]}" -M ${n} /root/bin/run-update &>> ${TMPFILE}
+	ret=$?
+	let "anyfail+=${ret}"
+	if [[ ${ret} = 0 ]]; then
+		builder=$(readlink ${machinedir}/etc/portage)
+		for variant in ${machinedir}/${builder}/variants/*; do
+			[[ -d ${variant} ]] || break
+			"${nspawn_command[@]}" --ephemeral --bind ${machinedir}/var/cache/binpkgs -M ${n} /root/bin/run-update ${variant##*/} &>> ${TMPFILE}
+			let "anyfail+=$?"
+		done
+	fi
 done
 
 

diff --git a/builders/milou/gnome-23/portage/variants/lucky/.run_marker b/builders/milou/gnome-23/portage/variants/lucky/.run_marker
new file mode 100644
index 0000000..722c3eb
--- /dev/null
+++ b/builders/milou/gnome-23/portage/variants/lucky/.run_marker
@@ -0,0 +1 @@
+I'm feeling lucky!

diff --git a/builders/milou/gnome-23/portage/variants/nopulse/package.use/nopulse b/builders/milou/gnome-23/portage/variants/nopulse/package.use/nopulse
new file mode 100644
index 0000000..3f33baa
--- /dev/null
+++ b/builders/milou/gnome-23/portage/variants/nopulse/package.use/nopulse
@@ -0,0 +1 @@
+*/* -pulseaudio -screencast

diff --git a/builders/milou/gnome-23/portage/variants/unstable/buildpkgonly b/builders/milou/gnome-23/portage/variants/unstable/buildpkgonly
new file mode 100755
index 0000000..e344f3c
--- /dev/null
+++ b/builders/milou/gnome-23/portage/variants/unstable/buildpkgonly
@@ -0,0 +1,9 @@
+#!/bin/bash
+set -e
+
+# We must use buildpkgonly here since we do not want to actually install
+# unstable packages. buildpkgonly will fatally error if any dependencies aren't
+# installed.
+emerge --buildpkgonly sys-devel/gcc:15 sys-devel/gcc:14 sys-devel/gcc:12
+# ... and clean it up
+rm /etc/portage/package.accept_keywords/gcc

diff --git a/builders/milou/gnome-23/portage/variants/unstable/package.accept_keywords/gcc b/builders/milou/gnome-23/portage/variants/unstable/package.accept_keywords/gcc
new file mode 100644
index 0000000..8b9d7eb
--- /dev/null
+++ b/builders/milou/gnome-23/portage/variants/unstable/package.accept_keywords/gcc
@@ -0,0 +1,2 @@
+sys-devel/gcc ~amd64
+<sys-devel/gcc-15.0.9999:15 **

diff --git a/builders/milou/gnome-23/run-update b/builders/milou/gnome-23/run-update
index 02cdf8a..84bf589 100755
--- a/builders/milou/gnome-23/run-update
+++ b/builders/milou/gnome-23/run-update
@@ -3,6 +3,40 @@
 # if one thing fails, abort entirely
 set -e
 
-emerge -uDNkq --changed-deps --backtrack=100 --keep-going world
+to_install=(world)
 
-emerge --depclean --quiet-unmerge-warn
+if [[ $1 = lucky ]]; then
+	eix-update
+	eix --stable --only-names | grep -E -v '^(acct|virtual|sec)-' | sort -u > /tmp/stable
+	eix --installed --only-names | sort -u > /tmp/installed
+	comm -23 /tmp/stable /tmp/installed > /tmp/uninstalled-stable
+	sed -i 's/--binpkg-respect-use//' /etc/portage/make.conf
+
+	to_install=(--autounmask --autounmask-keep-keywords --autounmask-write --autounmask-continue $(shuf -n1 /tmp/uninstalled-stable))
+elif [[ $1 ]]; then
+	pushd /etc/portage/variants/$1
+	while read -r -d '' line; do
+		dest=../../${line%.footer}
+		if [[ ${line} = world* ]]; then
+			dest=/var/lib/portage/world
+		fi
+
+		if [[ ${line} = world.remove ]]; then
+			emerge -C $(<"${line}")
+		elif [[ ${line} = *.footer ]]; then
+			cat "${line}" >> "${dest}"
+		else
+			cp "${line}" "${dest}"
+		fi
+	done < <(find . -type f -printf '%P\0')
+	if [[ -f buildpkgonly ]]; then
+		./buildpkgonly
+	fi
+	popd
+fi
+
+emerge -uDNkq --changed-deps --backtrack=100 --keep-going "${to_install[@]}"
+
+if [[ ! $1 ]]; then
+	emerge --depclean --quiet-unmerge-warn
+fi

diff --git a/builders/milou/gnome-v3-23/portage/variants/lucky/.run_marker b/builders/milou/gnome-v3-23/portage/variants/lucky/.run_marker
new file mode 100644
index 0000000..722c3eb
--- /dev/null
+++ b/builders/milou/gnome-v3-23/portage/variants/lucky/.run_marker
@@ -0,0 +1 @@
+I'm feeling lucky!

diff --git a/builders/milou/gnome-v3-23/portage/variants/nopulse/package.use/nopulse b/builders/milou/gnome-v3-23/portage/variants/nopulse/package.use/nopulse
new file mode 100644
index 0000000..3f33baa
--- /dev/null
+++ b/builders/milou/gnome-v3-23/portage/variants/nopulse/package.use/nopulse
@@ -0,0 +1 @@
+*/* -pulseaudio -screencast

diff --git a/builders/milou/gnome-v3-23/portage/variants/unstable/buildpkgonly b/builders/milou/gnome-v3-23/portage/variants/unstable/buildpkgonly
new file mode 100755
index 0000000..e344f3c
--- /dev/null
+++ b/builders/milou/gnome-v3-23/portage/variants/unstable/buildpkgonly
@@ -0,0 +1,9 @@
+#!/bin/bash
+set -e
+
+# We must use buildpkgonly here since we do not want to actually install
+# unstable packages. buildpkgonly will fatally error if any dependencies aren't
+# installed.
+emerge --buildpkgonly sys-devel/gcc:15 sys-devel/gcc:14 sys-devel/gcc:12
+# ... and clean it up
+rm /etc/portage/package.accept_keywords/gcc

diff --git a/builders/milou/gnome-v3-23/portage/variants/unstable/package.accept_keywords/gcc b/builders/milou/gnome-v3-23/portage/variants/unstable/package.accept_keywords/gcc
new file mode 100644
index 0000000..8b9d7eb
--- /dev/null
+++ b/builders/milou/gnome-v3-23/portage/variants/unstable/package.accept_keywords/gcc
@@ -0,0 +1,2 @@
+sys-devel/gcc ~amd64
+<sys-devel/gcc-15.0.9999:15 **

diff --git a/builders/milou/gnome-v3-23/run-update b/builders/milou/gnome-v3-23/run-update
index 02cdf8a..84bf589 100755
--- a/builders/milou/gnome-v3-23/run-update
+++ b/builders/milou/gnome-v3-23/run-update
@@ -3,6 +3,40 @@
 # if one thing fails, abort entirely
 set -e
 
-emerge -uDNkq --changed-deps --backtrack=100 --keep-going world
+to_install=(world)
 
-emerge --depclean --quiet-unmerge-warn
+if [[ $1 = lucky ]]; then
+	eix-update
+	eix --stable --only-names | grep -E -v '^(acct|virtual|sec)-' | sort -u > /tmp/stable
+	eix --installed --only-names | sort -u > /tmp/installed
+	comm -23 /tmp/stable /tmp/installed > /tmp/uninstalled-stable
+	sed -i 's/--binpkg-respect-use//' /etc/portage/make.conf
+
+	to_install=(--autounmask --autounmask-keep-keywords --autounmask-write --autounmask-continue $(shuf -n1 /tmp/uninstalled-stable))
+elif [[ $1 ]]; then
+	pushd /etc/portage/variants/$1
+	while read -r -d '' line; do
+		dest=../../${line%.footer}
+		if [[ ${line} = world* ]]; then
+			dest=/var/lib/portage/world
+		fi
+
+		if [[ ${line} = world.remove ]]; then
+			emerge -C $(<"${line}")
+		elif [[ ${line} = *.footer ]]; then
+			cat "${line}" >> "${dest}"
+		else
+			cp "${line}" "${dest}"
+		fi
+	done < <(find . -type f -printf '%P\0')
+	if [[ -f buildpkgonly ]]; then
+		./buildpkgonly
+	fi
+	popd
+fi
+
+emerge -uDNkq --changed-deps --backtrack=100 --keep-going "${to_install[@]}"
+
+if [[ ! $1 ]]; then
+	emerge --depclean --quiet-unmerge-warn
+fi


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-09-11  0:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-11  0:32 [gentoo-commits] proj/binhost:master commit in: builders/milou/gnome-23/portage/variants/lucky/, Eli Schwartz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox