Subject: [alpine-devel] [PATCH] Add btrfs-progs to init_progs(). Use "-q" only when the tool supports this switch.

From: Juan Francisco Cantero Hurtado <[email-masked]>
Date: Fri, 1 Aug 2014 02:39:35 +0200

---
 setup-disk.in | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/setup-disk.in b/setup-disk.in
index c20c619..f41a464 100644
--- a/setup-disk.in
+++ b/setup-disk.in
@@ -424,7 +424,7 @@ stop_all_raid() {
 init_progs() {
 	local raidpkg=
 	[ -n "$USE_RAID" ] && raidpkg="mdadm"
-	apk add --quiet sfdisk e2fsprogs lvm2 $raidpkg syslinux $@
+	apk add --quiet sfdisk e2fsprogs lvm2 $raidpkg syslinux btrfs-progs $@
 }
 
 show_disk_info() {
@@ -519,7 +519,11 @@ setup_boot_dev() {
 			--metadata=0.90 --quiet --run $@ $missing || return 1
 		bootdev=/dev/md0
 	fi
-	mkfs.$BOOTFS -q $bootdev
+	local mkfs_args=
+	if [ "$BOOTFS" != "btrfs" ]; then
+		mkfs_args="-q"
+	fi
+	mkfs.$BOOTFS $mkfs_args $bootdev
 	BOOT_DEV="$bootdev"
 }
 
@@ -614,7 +618,7 @@ setup_var() {
 	local var_dev="$1"
 	local varfs=${VARFS}
 	echo "Creating file systems..."
-	mkfs.$varfs -q $var_dev >/dev/null || return 1
+	mkfs.$varfs $var_dev >/dev/null || return 1
 	sed -i -e '/[[:space:]]\/var[[:space:]]/d' /etc/fstab
 	echo -e "${var_dev}\t/var\t\t${varfs}\tdefaults 1 2" >> /etc/fstab
 
@@ -710,7 +714,11 @@ data_only_disk_install() {
 # setup
 setup_root() {
 	local root_dev="$1" boot_dev="$2"
-	mkfs.$ROOTFS -q "$root_dev"
+	local mkfs_args=
+	if [ "$ROOTFS" != "btrfs" ]; then
+		mkfs_args="-q"
+	fi
+	mkfs.$ROOTFS $mkfs_args "$root_dev"
 	mkdir -p "$SYSROOT"
 	mount -t $ROOTFS $root_dev "$SYSROOT" || return 1
 	if [ -n "$boot_dev" ]; then
-- 
1.9.3

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

---

From: Natanael Copa <[email-masked]>
Date: Fri, 1 Aug 2014 11:25:01 +0200

On Fri,  1 Aug 2014 02:39:35 +0200
Juan Francisco Cantero Hurtado <[email-masked]> wrote:

So as i understand this adds support for btrfs to setup-disk?

> +	apk add --quiet sfdisk e2fsprogs lvm2 $raidpkg syslinux btrfs-progs $@

If we are going to do this, how about soemthing like:

	case $ROOTFS in
	ext*) fstools=e2fsprogs; mkfs_args="-q";;
	xfs) fstools=xfsprogs; mkfs_args="-q";;
	btrfs) fstools=btrs-progs; mkfs_args="";;
	esac
	apk add --quiet $fstools ....

That way we dont install btrfs-tools unless actually needed and we
avoid specialhandling for future filesystems.

> +	mkfs.$BOOTFS $mkfs_args $bootdev

btw.. does exlinux support booting from btrfs?

>  	if [ -n "$boot_dev" ]; then

-nc

---

---

From: Juan Francisco Cantero Hurtado <[email-masked]>
Date: Sat, 02 Aug 2014 00:17:31 +0200

> So as i understand this adds support for btrfs to setup-disk?

Yes. I tried to use ROOTFS=btrfs but failed because btrfs-progs
was not installed and the tools doesn't support "-q".

> > +	apk add --quiet sfdisk e2fsprogs lvm2 $raidpkg syslinux
> > btrfs-progs $@> 
> >  }
> 

I didn't test with BOOTFS. I only added that part because the wiki
says that BOOTFS supports also btrfs
http://wiki.alpinelinux.org/wiki/Alpine_setup_scripts#setup-disk .

>From 87a2a3ca2f365df3c60d933b71d70333287e090f Mon Sep 17 00:00:00 2001
From: Juan Francisco Cantero Hurtado <[email-masked]>
Date: Fri, 1 Aug 2014 23:47:50 +0200
Subject: [PATCH] Add support for btrfs to setup-disk.

---
 setup-disk.in | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/setup-disk.in b/setup-disk.in
index c20c619..bae373a 100644
--- a/setup-disk.in
+++ b/setup-disk.in
@@ -424,7 +424,12 @@ stop_all_raid() {
 init_progs() {
 	local raidpkg=
 	[ -n "$USE_RAID" ] && raidpkg="mdadm"
-	apk add --quiet sfdisk e2fsprogs lvm2 $raidpkg syslinux $@
+	case $ROOTFS in
+	ext*) fstools=e2fsprogs; mkfs_args="-q";;
+	xfs) fstools=xfsprogs; mkfs_args="-q";;
+	btrfs) fstools=btrs-progs; mkfs_args="";;
+	esac
+	apk add --quiet sfdisk e2fsprogs lvm2 $raidpkg syslinux $fstools $@
 }
 
 show_disk_info() {
@@ -614,7 +619,7 @@ setup_var() {
 	local var_dev="$1"
 	local varfs=${VARFS}
 
@@ -710,7 +715,7 @@ data_only_disk_install() {
 # setup
 setup_root() {

---

---

From: Natanael Copa <[email-masked]>
Date: Tue, 4 Nov 2014 11:33:22 +0100

This was finally applied.

Sorry for the delay.

Thanks!

-nc

On Sat, 02 Aug 2014 00:17:31 +0200

---