Subject: [alpine-aports] [PATCH] main/alpine-conf: corrections in 'setup-disk' script

From: Valery Kartel <[email-masked]>
Date: Thu, 17 Dec 2015 15:15:18 +0200

- 'mkfs_args' function added. It prints mkfs.<filesystem> specific arguments.

- in 'setup_boot_dev', 'setup_var' & 'setup_root' mkfs_args variable changed to mkfs_args(fs) function call.

- in 'init_progs' I replace all pkg-specific variables with a single $pkgs variable and made modules and fs-tools loading depends on install type (sys or data).

- in 'install_mounted_root' I added a removing sfdisk from dest-system install list.

PS: don't know why additional package 'acct' hardcoded to dest-system install list. Does it really needs?
---
 main/alpine-conf/APKBUILD                          |  12 ++-
 .../setup-disk_mkfsargs_cfdisk_setupfs.patch       | 103 +++++++++++++++++++++
 2 files changed, 111 insertions(+), 4 deletions(-)
 create mode 100644 main/alpine-conf/setup-disk_mkfsargs_cfdisk_setupfs.patch

diff --git a/main/alpine-conf/APKBUILD b/main/alpine-conf/APKBUILD
index e42c3f5..0dd93b6 100644
--- a/main/alpine-conf/APKBUILD
+++ b/main/alpine-conf/APKBUILD
@@ -1,13 +1,14 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=alpine-conf
 pkgver=3.3.0_rc1
-pkgrel=0
+pkgrel=1
 pkgdesc="Alpine configuration management scripts"
 url=http://git.alpinelinux.org/cgit/$pkgname
 arch="all"
 license="MIT"
 depends="openrc>0.13"
 source="http://dev.alpinelinux.org/archive/alpine-conf/alpine-conf-$pkgver.tar.xz
+	setup-disk_mkfsargs_cfdisk_setupfs.patch
 	"
 
 _builddir="$srcdir"/$pkgname-$pkgver
@@ -34,6 +35,9 @@ package() {
 	done
 }
 
-md5sums="dc90de8e1c0971c125fe45f072d243e6  alpine-conf-3.3.0_rc1.tar.xz"
-sha256sums="ddfa912d089bf9ee39b9a35a723dc84ed758eb57edd5b5bc19cd5b4cf00a4635  alpine-conf-3.3.0_rc1.tar.xz"
-sha512sums="0a410f951b58af91d734aa2b56460565fad3c430c0602bea70aa722b0c6b9a2dc88f46cc526216891bc9f70f54acc22e9be0519fa6bebd8dc460f71829c513e4  alpine-conf-3.3.0_rc1.tar.xz"
+md5sums="dc90de8e1c0971c125fe45f072d243e6  alpine-conf-3.3.0_rc1.tar.xz
+4b286b311a326998271d1fe567edb181  setup-disk_mkfsargs_cfdisk_setupfs.patch"
+sha256sums="ddfa912d089bf9ee39b9a35a723dc84ed758eb57edd5b5bc19cd5b4cf00a4635  alpine-conf-3.3.0_rc1.tar.xz
+2f49393a51ab68ff43ee66bf6e7d2d87af89bea78ab762f69033e4dd2e3470e5  setup-disk_mkfsargs_cfdisk_setupfs.patch"
+sha512sums="0a410f951b58af91d734aa2b56460565fad3c430c0602bea70aa722b0c6b9a2dc88f46cc526216891bc9f70f54acc22e9be0519fa6bebd8dc460f71829c513e4  alpine-conf-3.3.0_rc1.tar.xz
+ce75c59b06ef59657fcfa05123832d6f6b15b4df404ee82506314b5520801d8e55daa9dfe887a8773b2fa86271cc5f4b84a4d401ee60beeaa12efa0aee6b8949  setup-disk_mkfsargs_cfdisk_setupfs.patch"
diff --git a/main/alpine-conf/setup-disk_mkfsargs_cfdisk_setupfs.patch b/main/alpine-conf/setup-disk_mkfsargs_cfdisk_setupfs.patch
new file mode 100644
index 0000000..9d4e1c3
--- /dev/null
+++ b/main/alpine-conf/setup-disk_mkfsargs_cfdisk_setupfs.patch
@@ -0,0 +1,103 @@
+--- old/setup-disk.in
++++ new/setup-disk.in
+@@ -32,6 +32,15 @@
+ 	return 0
+ }
+ 
++# prints mkfs.* specific command-line arguments
++mkfs_args() {
++	case "$1" in
++		xfs) echo "-q -f";;
++		ext*) echo "-q -F";;
++		btrfs) echo "-q -f";;
++	esac
++}
++
+ # wrapper to only show given device
+ _blkid() {
+ 	blkid | grep "^$1:"
+@@ -327,6 +336,7 @@
+ 
+ 	local apkflags="--initdb --quiet --progress --update-cache --clean-protected"
+ 	local pkgs=$(cat "$mnt"/etc/apk/world "$mnt"/var/lib/apk/world 2>/dev/null)
++	pkgs=$(echo $pkgs | sed s,sfdisk,,)
+ 	pkgs="$pkgs acct linux-$KERNEL_FLAVOR alpine-base"
+ 	if [ "$(rc --sys)" = "XEN0" ]; then
+ 		pkgs="$pkgs xen-hypervisor"
+@@ -440,21 +450,23 @@
+ 
+ # install needed programs
+ init_progs() {
+-	local raidpkg= lvmpkg= fs= fstools=
+-	[ -n "$USE_RAID" ] && raidpkg="mdadm"
+-	[ -n "$USE_LVM" ] && lvmpkg="lvm2"
+-	for fs in $BOOTFS $ROOTFS $VARFS; do
++	local fs= fslist= pkgs="sfdisk syslinux"
++	[ -n "$USE_RAID" ] && pkgs="$pkgs mdadm"
++	[ -n "$USE_LVM" ] && pkgs="$pkgs lvm2"
++	[ "$answer" = "sys" ] && fslist="$BOOTFS $ROOTFS"
++	[ "$answer" = "data" ] && fslist="$VARFS"
++	for fs in $fslist; do
+ 		# we need load btrfs module early to avoid the error message:
+ 		# 'failed to open /dev/btrfs-control'
+ 		modprobe $fs
+ 
+ 		case $fs in
+-		xfs) fstools="$fstools xfsprogs";;
+-		ext*) fstools="$fstools e2fsprogs";;
+-		btrfs) fstools="$fstools btrfs-progs";;
++		xfs) pkgs="$pkgs xfsprogs";;
++		ext*) pkgs="$pkgs e2fsprogs";;
++		btrfs) pkgs="$pkgs btrfs-progs";;
+ 		esac
+ 	done
+-	apk add --quiet sfdisk $lvmpkg $raidpkg syslinux $fstools $@
++	apk add --quiet $pkgs $@
+ }
+ 
+ show_disk_info() {
+@@ -531,7 +543,7 @@
+ 
+ # set up optional raid and create filesystem on boot device.
+ setup_boot_dev() {
+-	local disk= bootdev= mkfs_args="-q"
++	local disk= bootdev=
+ 	local part=$(for disk in $@; do find_boot_partition $disk; done)
+ 	set -- $part
+ 	bootdev=$1
+@@ -549,8 +561,7 @@
+ 			--metadata=0.90 --quiet --run $@ $missing || return 1
+ 		bootdev=/dev/md0
+ 	fi
+-	[ "$BOOTFS" = "btrfs" ] && mkfs_args=""
+-	mkfs.$BOOTFS $mkfs_args $bootdev
++	mkfs.$BOOTFS $(mkfs_args $BOOTFS) $bootdev
+ 	BOOT_DEV="$bootdev"
+ }
+ 
+@@ -643,11 +654,10 @@
+ # set up /var on given device
+ setup_var() {
+ 	local var_dev="$1"
+-	local varfs=${VARFS}
+ 	echo "Creating file systems..."
+-	mkfs.$varfs $var_dev >/dev/null || return 1
++	mkfs.$VARFS $(mkfs_args $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
++	echo -e "${var_dev}\t/var\t\t${VARFS}\tdefaults 1 2" >> /etc/fstab
+ 
+ 	mv /var /.var
+ 	mkdir /var
+@@ -740,9 +750,8 @@
+ 
+ # setup
+ setup_root() {
+-	local root_dev="$1" boot_dev="$2" mkfs_args="-q"
+-	[ "$ROOTFS" = "btrfs" ] && mkfs_args=""
+-	mkfs.$ROOTFS $mkfs_args "$root_dev"
++	local root_dev="$1" boot_dev="$2"
++	mkfs.$ROOTFS $(mkfs_args $ROOTFS) "$root_dev"
+ 	mkdir -p "$SYSROOT"
+ 	mount -t $ROOTFS $root_dev "$SYSROOT" || return 1
+ 	if [ -n "$boot_dev" ]; then
-- 
2.6.4

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