void-packages/srcpkgs/lvm2/patches/0001-lvresize-use-POSIX-she...

126 lines
3.9 KiB
Diff

From 50fe324ff953eedd210054ffc21715d22134b3c1 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 16 Nov 2022 11:55:34 +0100
Subject: [PATCH] lvresize: use POSIX shell
---
scripts/lvresize_fs_helper.sh | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/scripts/lvresize_fs_helper.sh b/scripts/lvresize_fs_helper.sh
index 90b1a97..1c48a71 100755
--- a/scripts/lvresize_fs_helper.sh
+++ b/scripts/lvresize_fs_helper.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Copyright (C) 2022 Red Hat, Inc. All rights reserved.
#
@@ -69,7 +69,7 @@ fsextend() {
fi
fi
- if [[ "$FSTYPE" == "ext"* ]]; then
+ if [ "${FSTYPE#ext}" != "$FSTYPE" ]; then
logmsg "resize2fs ${DEVPATH}"
if resize2fs "$DEVPATH"; then
logmsg "resize2fs done"
@@ -77,7 +77,7 @@ fsextend() {
logmsg "resize2fs failed"
RESIZEFS_FAILED=1
fi
- elif [[ "$FSTYPE" == "xfs" ]]; then
+ elif [ "$FSTYPE" = "xfs" ]; then
logmsg "xfs_growfs ${DEVPATH}"
if xfs_growfs "$DEVPATH"; then
logmsg "xfs_growfs done"
@@ -102,7 +102,7 @@ fsextend() {
# If the fs was temporarily unmounted, now remount it.
# Not considered a command failure if this fails.
- if [[ $DO_UNMOUNT -eq 1 && $REMOUNT -eq 1 ]]; then
+ if [ "$DO_UNMOUNT" -eq 1 ] && [ "$REMOUNT" -eq 1 ]; then
logmsg "remount ${DEVPATH} ${MOUNTDIR}"
if mount -t "$FSTYPE" "$DEVPATH" "$MOUNTDIR"; then
logmsg "remount done"
@@ -151,7 +151,7 @@ fsreduce() {
fi
fi
- if [[ "$FSTYPE" == "ext"* ]]; then
+ if [ "${FSTYPE#ext}" != "$FSTYPE" ]; then
NEWSIZEKB=$(( NEWSIZEBYTES / 1024 ))
logmsg "resize2fs ${DEVPATH} ${NEWSIZEKB}k"
if resize2fs "$DEVPATH" "$NEWSIZEKB"k; then
@@ -194,7 +194,7 @@ fsreduce() {
# If the fs was temporarily unmounted, now remount it.
# Not considered a command failure if this fails.
- if [[ $DO_UNMOUNT -eq 1 && $REMOUNT -eq 1 ]]; then
+ if [ "$DO_UNMOUNT" -eq 1 ] && [ "$REMOUNT" -eq 1 ]; then
logmsg "remount ${DEVPATH} ${MOUNTDIR}"
if mount -t "$FSTYPE" "$DEVPATH" "$MOUNTDIR"; then
logmsg "remount done"
@@ -291,7 +291,7 @@ DO_FSCK=0
# mounted and the script unmounted it.
REMOUNT=0
-if [ "$UID" != 0 ] && [ "$EUID" != 0 ]; then
+if [ "$(id -u)" != 0 ]; then
errorexit "${SCRIPTNAME} must be run as root."
fi
@@ -372,11 +372,11 @@ done
#
# There are three top level commands: --fsextend, --fsreduce, --cryptresize.
-if [[ "$DO_FSEXTEND" -eq 0 && "$DO_FSREDUCE" -eq 0 && "$DO_CRYPTRESIZE" -eq 0 ]]; then
+if [ "$DO_FSEXTEND" -eq 0 ] && [ "$DO_FSREDUCE" -eq 0 ] && [ "$DO_CRYPTRESIZE" -eq 0 ]; then
errorexit "Missing --fsextend|--fsreduce|--cryptresize."
fi
-if [[ "$DO_FSEXTEND" -eq 1 || "$DO_FSREDUCE" -eq 1 ]]; then
+if [ "$DO_FSEXTEND" -eq 1 ] || [ "$DO_FSREDUCE" -eq 1 ]; then
case "$FSTYPE" in
ext[234]) ;;
"xfs") ;;
@@ -388,7 +388,7 @@ if [[ "$DO_FSEXTEND" -eq 1 || "$DO_FSREDUCE" -eq 1 ]]; then
fi
fi
-if [[ "$DO_CRYPTRESIZE" -eq 1 && -z "$CRYPTPATH" ]]; then
+if [ "$DO_CRYPTRESIZE" -eq 1 ] && [ -z "$CRYPTPATH" ]; then
errorexit "Missing required --cryptpath for --cryptresize."
fi
@@ -406,15 +406,15 @@ if [ ! -e "$DEVPATH" ]; then
errorexit "Device does not exist \"$DEVPATH\"."
fi
-if [[ "$DO_UNMOUNT" -eq 1 && -z "$MOUNTDIR" ]]; then
+if [ "$DO_UNMOUNT" -eq 1 ] && [ -z "$MOUNTDIR" ]; then
errorexit "Missing required --mountdir for --unmount."
fi
-if [[ "$DO_FSREDUCE" -eq 1 && "$FSTYPE" == "xfs" ]]; then
+if [ "$DO_FSREDUCE" -eq 1 ] && [ "$FSTYPE" = "xfs" ]; then
errorexit "Cannot reduce xfs."
fi
-if [[ "$DO_FSCK" -eq 1 && "$FSTYPE" == "xfs" ]]; then
+if [ "$DO_FSCK" -eq 1 ] && [ "$FSTYPE" = "xfs" ]; then
errorexit "Cannot use --fsck with xfs."
fi
@@ -424,7 +424,7 @@ if [ "$DO_MOUNT" -eq 1 ]; then
errorexit "Failed to create temp dir."
fi
# In case the script terminates without doing cleanup
- function finish {
+ finish() {
if [ "$TMP_MOUNT_DONE" -eq 1 ]; then
logmsg "exit unmount ${TMPDIR}"
umount "$TMPDIR"