X-Original-To: alpine-devel@mail.alpinelinux.org Delivered-To: alpine-devel@mail.alpinelinux.org Received: from mail.alpinelinux.org (dallas-a1.alpinelinux.org [127.0.0.1]) by mail.alpinelinux.org (Postfix) with ESMTP id 64339DC029C for ; Sat, 6 Feb 2016 12:01:46 +0000 (UTC) Received: from relay1.infogroup.kiev.ua (tera.infogroup.kiev.ua [195.144.25.26]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.alpinelinux.org (Postfix) with ESMTPS id D2D76DC0287 for ; Sat, 6 Feb 2016 12:01:45 +0000 (UTC) Received: from aveo.com.ua ([195.144.25.27] helo=alpine) by relay1.infogroup.kiev.ua with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.80.1) (envelope-from ) id 1aS1Yd-0007tw-8w; Sat, 06 Feb 2016 14:01:43 +0200 From: Valery Kartel To: alpine-devel@lists.alpinelinux.org Cc: Valery Kartel Subject: [alpine-devel] [PATCH] setup-disk.in: cleanups Date: Sat, 6 Feb 2016 14:05:54 +0200 Message-Id: <1454760354-7797-1-git-send-email-valery.kartel@gmail.com> X-Mailer: git-send-email 2.7.0 X-Virus-Scanned: ClamAV using ClamSMTP X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: - 'mkfs_args' function added. It prints mkfs. 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). PS: don't know why additional package 'acct' hardcoded to dest-system install list. Does it really needs? --- setup-disk.in | 56 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/setup-disk.in b/setup-disk.in index ea3c590..30a3e09 100644 --- a/setup-disk.in +++ b/setup-disk.in @@ -32,6 +32,18 @@ all_in_list() { return 0 } +# prints mkfs.* specific command-line arguments +mkfs_args() { + local args= + case "$1" in + xfs) args="-f";; + ext*) args="-F";; + btrfs) args="-f";; + esac + [ -n "$VERBOSE" ] || args="$args -q" + echo $args +} + # wrapper to only show given device _blkid() { blkid | grep "^$1:" @@ -442,21 +454,20 @@ stop_all_raid() { # 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 - # we need load btrfs module early to avoid the error message: - # 'failed to open /dev/btrfs-control' + 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 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() { @@ -533,11 +544,11 @@ find_lvm_partition() { # set up optional raid and create filesystem on boot device. setup_boot_dev() { - local disk= bootdev= mkfs_args="-q" + local disk= boot_dev= local part=$(for disk in $@; do find_boot_partition $disk; done) set -- $part - bootdev=$1 - [ -z "$bootdev" ] && return 1 + boot_dev=$1 + [ -z "$boot_dev" ] && return 1 echo "Creating file systems..." if [ -n "$USE_RAID" ]; then local missing= @@ -549,11 +560,10 @@ setup_boot_dev() { # we only use raid level 1 for boot devices mdadm --create /dev/md0 --level=1 --raid-devices=$num \ --metadata=0.90 --quiet --run $@ $missing || return 1 - bootdev=/dev/md0 + boot_dev=/dev/md0 fi - [ "$BOOTFS" = "btrfs" ] && mkfs_args="" - mkfs.$BOOTFS $mkfs_args $bootdev - BOOT_DEV="$bootdev" + mkfs.$BOOTFS $(mkfs_args $BOOTFS) $boot_dev + BOOT_DEV="$boot_dev" } # $1 = index @@ -645,11 +655,10 @@ reset_var() { # 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 || 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 @@ -742,9 +751,8 @@ data_only_disk_install() { # 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.7.0 --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---