Subject: [alpine-devel] [PATCH abuild] buildlab fixes

From: Eivind Uggedal <[email-masked]>
Date: Mon, 6 May 2019 21:47:43 +0000

Last time I worked on Alpine (4 years ago) I used LXC for building/testing
against given release versions or edge. Seems LXC has deprecated all
the things that made it great, so I came over the buildlab script
in the abuild repo and thought it would be a simple solution for my
needs.

A few minutes later I had a non-working empty chroot directory without a
rootfs due to missing signing keys. To my amasement all
my important virtual filesystems on the host had been umounted as
well...

This series of patches makes buildlab (barely) work for building packages
against edge from a 3.9 host without hosing your system.

Maybe the script should be dropped altogether if noone has used it. If
not, I might send future patches to improve the workflow somewhat
and fix the non-working cache copying/setup.

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Eivind Uggedal <[email-masked]>
Date: Mon, 6 May 2019 21:47:46 +0000

Let's party with buildlab like its 2015.
---
 buildlab.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/buildlab.in b/buildlab.in
index 073400851749..f06a68266a48 100644
--- a/buildlab.in
+++ b/buildlab.in
@@ -123,6 +123,7 @@ prepare_chroot() {
 	cp /etc/apk/keys/[email-masked]*.pub \
 		"$path"/etc/apk/keys/
 	echo "http://$mirror/alpine/$version/main" >> "$path"/etc/apk/repositories
+	echo "http://$mirror/alpine/$version/community" >> "$path"/etc/apk/repositories
 	echo "http://$mirror/alpine/$version/testing" >> "$path"/etc/apk/repositories
 
 	if [ ! -z "$enablecache" ]; then
-- 
2.20.1

---

---

From: Eivind Uggedal <[email-masked]>
Date: Mon, 6 May 2019 21:47:45 +0000

This change makes buildlab actually able to
install packages when a chroot is created.
---
 buildlab.in | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/buildlab.in b/buildlab.in
index e0d64d665380..073400851749 100644
--- a/buildlab.in
+++ b/buildlab.in
@@ -119,7 +119,9 @@ prepare_chroot() {
 
 	msg "Setting up repositories for mirror $mirror with version $version at $path..."
 
-	mkdir -p "$path"/etc/apk
+	mkdir -p "$path"/etc/apk/keys
+	cp /etc/apk/keys/[email-masked]*.pub \
+		"$path"/etc/apk/keys/
 	echo "http://$mirror/alpine/$version/main" >> "$path"/etc/apk/repositories
 	echo "http://$mirror/alpine/$version/testing" >> "$path"/etc/apk/repositories
 
-- 
2.20.1

---

---

From: Eivind Uggedal <[email-masked]>
Date: Mon, 6 May 2019 21:47:44 +0000

Before this change running buildlab would
umount your system's proper non bind mounted
/dev, /proc, and /sys!
---
 buildlab.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/buildlab.in b/buildlab.in
index b5129ff17270..e0d64d665380 100644
--- a/buildlab.in
+++ b/buildlab.in
@@ -100,7 +100,7 @@ do_chroot_action() {
 	chroot "$path" /bin/sh /.chroot-action.sh
 	rm "$path"/.chroot-action.sh
 
-	do_chroot_close
+	do_chroot_close "$path"
 }
 
 update_chroot() {
-- 
2.20.1

---

---

From: Eivind Uggedal <[email-masked]>
Date: Mon, 6 May 2019 21:47:47 +0000

Without this the abuild user won't be able
to create tmp files (and not build anything).
---
 buildlab.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/buildlab.in b/buildlab.in
index f06a68266a48..b77d1becc5d7 100644
--- a/buildlab.in
+++ b/buildlab.in
@@ -136,6 +136,7 @@ prepare_chroot() {
 	mkdir -p "$path"/var/lock
 	mkdir -p "$path"/var/cache/apk
 	mkdir -p "$path"/tmp
+	chmod 1777 "$path"/tmp
 
 	mkdir -p "$path"/etc
 	cp /etc/resolv.conf "$path"/etc/resolv.conf
-- 
2.20.1

---

---

From: Chloe Kudryavtsev <[email-masked]>
Date: Mon, 6 May 2019 18:26:13 -0400

> and fix the non-working cache copying/setup.

Looks good to me on first glance.
I'll try and take some time to test if it works on my edge-based builder 
sometime this week.
You might need to wait some time for adoption, since 3.10 is coming up 
and everyone is busy with that.

That said, it would be very nice if you got chroot-based builds working 
well :)

---

---

From: Natanael Copa <[email-masked]>
Date: Wed, 5 Jun 2019 22:00:25 +0200

On Mon,  6 May 2019 21:47:43 +0000

> in the abuild repo and thought it would be a simple solution for my

Have you seen abuild-rootbld?

It will set up a lightweight container using bubblewrap and do the
build in there.

  apk add abuild-rootbld
  abuild rootbld

It will also work if you check out 3.*-stable.

-nc

---