From a41219f4b7aad1f3c0c5dd7365cb310b2f0a10a9 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Wed, 26 Jun 2024 12:00:47 +0200 Subject: [PATCH] replace grep and sed with rg and sd --- usr/lib/archboot/run/chroot-tarball.sh | 6 ++---- usr/lib/archboot/run/container.sh | 13 +++++-------- usr/lib/archboot/run/iso.sh | 8 ++++---- usr/lib/archboot/run/repository.sh | 6 +++--- usr/lib/archboot/run/server-release.sh | 6 +++--- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/usr/lib/archboot/run/chroot-tarball.sh b/usr/lib/archboot/run/chroot-tarball.sh index eeba6ff33..21ff5612c 100755 --- a/usr/lib/archboot/run/chroot-tarball.sh +++ b/usr/lib/archboot/run/chroot-tarball.sh @@ -4,7 +4,7 @@ . /etc/archboot/defaults . /usr/lib/archboot/common.sh . /usr/lib/archboot/container.sh -if echo "${_BASENAME}" | grep -qw aarch64; then +if echo "${_BASENAME}" | rg -qw 'aarch64'; then _PACMAN_ARCH_CHROOT="${_PACMAN_AARCH64_CHROOT}" _PACMAN_ARCH="${_PACMAN_AARCH64}" _ARCH_VERSION="ArchLinuxARM-aarch64-latest.tar.gz" @@ -12,7 +12,7 @@ if echo "${_BASENAME}" | grep -qw aarch64; then _LATEST_ARCH="http://os.archlinuxarm.org/os/${_ARCH_VERSION}" _CAP_ARCH="AARCH64" _ARCH="aarch64" -elif echo "${_BASENAME}" | grep -qw riscv64; then +elif echo "${_BASENAME}" | rg -qw 'riscv64'; then _PACMAN_ARCH_CHROOT="${_PACMAN_RISCV64_CHROOT}" _PACMAN_ARCH="${_PACMAN_RISCV64}" _ARCH_VERSION="archriscv-20220727.tar.zst" @@ -44,8 +44,6 @@ echo "Downloading archlinux ${_ARCH}..." bsdtar -xf "${_ARCH_VERSION}" -C "${1}" echo "Removing installation tarball..." rm "${_ARCH_VERSION}" -sed -i -e '/^\[community\]/ { n ; s/^/#/ }' "${1}"/etc/pacman.conf -sed -i -e 's:^\[community\]:#\[community\]:g' "${1}"/etc/pacman.conf _generate_keyring "${1}" || exit 1 _fix_network "${1}" # update container to latest packages diff --git a/usr/lib/archboot/run/container.sh b/usr/lib/archboot/run/container.sh index 6a4ed1a4b..81a2c8045 100755 --- a/usr/lib/archboot/run/container.sh +++ b/usr/lib/archboot/run/container.sh @@ -8,7 +8,7 @@ _parameters "$@" _root_check echo "Starting container creation..." [[ -d "${1}" ]] || (echo "Creating directory ${1}..."; mkdir "${1}") -if echo "${_BASENAME}" | grep -qw "${_RUNNING_ARCH}"; then +if echo "${_BASENAME}" | rg -qw "${_RUNNING_ARCH}"; then # running system = creating system _cachedir_check _create_pacman_conf "${1}" @@ -25,22 +25,19 @@ if echo "${_BASENAME}" | grep -qw "${_RUNNING_ARCH}"; then if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then _copy_archboot_defaults "${1}" # enable [*-testing] if enabled in host - if grep -q "^\[core-testing" /etc/pacman.conf; then + if rg -q "^\[core-testing" /etc/pacman.conf; then echo "Enable [core-testing] and [extra-testing] repository in container..." - sed -i -e '/^#\[core-testing\]/ { n ; s/^#// }' "${1}/etc/pacman.conf" - sed -i -e '/^#\[extra-testing\]/ { n ; s/^#// }' "${1}/etc/pacman.conf" - sed -i -e 's:^#\[core-testing\]:\[core-testing\]:g' \ - -e 's:^#\[extra-testing\]:\[extra-testing\]:g' "${1}/etc/pacman.conf" + sd '^#(\[[c,e].*-testing\]\n)#' '$1' "${1}/etc/pacman.conf" fi fi else # running system != creating system if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then - if echo "${_BASENAME}" | grep -qw aarch64; then + if echo "${_BASENAME}" | rg -qw 'aarch64'; then _pacman_chroot "${1}" "${_ARCHBOOT_AARCH64_CHROOT_PUBLIC}" \ "${_PACMAN_AARCH64_CHROOT}" || exit 1 fi - if echo "${_BASENAME}" | grep -qw riscv64; then + if echo "${_BASENAME}" | rg -qw 'riscv64'; then _pacman_chroot "${1}" "${_ARCHBOOT_RISCV64_CHROOT_PUBLIC}" \ "${_PACMAN_RISCV64_CHROOT}" || exit 1 fi diff --git a/usr/lib/archboot/run/iso.sh b/usr/lib/archboot/run/iso.sh index e768eee7e..3942e3558 100755 --- a/usr/lib/archboot/run/iso.sh +++ b/usr/lib/archboot/run/iso.sh @@ -9,16 +9,16 @@ _parameters "$@" _root_check _architecture_check _config -if echo "${_BASENAME}" | grep -qw aarch64 || echo "${_BASENAME}" | grep -qw x86_64; then +if echo "${_BASENAME}" | rg -qw 'aarch64' || echo "${_BASENAME}" | rg -qw 'x86_64'; then # running system = aarch64 or x86_64 echo "Starting ISO creation..." _prepare_kernel_initrd_files || exit 1 _prepare_ucode || exit 1 - if echo "${_BASENAME}" | grep -qw aarch64; then + if echo "${_BASENAME}" | rg -qw 'aarch64'; then _prepare_fedora_shim_bootloaders_aarch64 || exit 1 _prepare_uefi_AA64 || exit 1 fi - if echo "${_BASENAME}" | grep -qw x86_64; then + if echo "${_BASENAME}" | rg -qw 'x86_64'; then _prepare_fedora_shim_bootloaders_x86_64 || exit 1 _prepare_uefi_shell_tianocore || exit 1 _prepare_uefi_X64 || exit 1 @@ -41,7 +41,7 @@ else fi _create_cksum || exit 1 _cleanup_iso || exit 1 -if echo "${_BASENAME}" | grep -qw aarch64 || echo "${_BASENAME}" | grep -qw x86_64; then +if echo "${_BASENAME}" | rg -qw 'aarch64' || echo "${_BASENAME}" | rg -qw 'x86_64'; then echo "Finished ISO creation." else echo "Finished Image creation." diff --git a/usr/lib/archboot/run/repository.sh b/usr/lib/archboot/run/repository.sh index 470d8cdec..40001b529 100755 --- a/usr/lib/archboot/run/repository.sh +++ b/usr/lib/archboot/run/repository.sh @@ -10,7 +10,7 @@ _root_check [[ -d "${1}" ]] || (echo "Creating directory ${1}..."; mkdir "${1}") _REPODIR="$(mktemp -d "${1}"/repository.XXX)" echo "Starting repository creation..." -if echo "${_BASENAME}" | grep -qw "${_RUNNING_ARCH}"; then +if echo "${_BASENAME}" | rg -qw "${_RUNNING_ARCH}"; then # running system = creating system [[ "${_RUNNING_ARCH}" == "x86_64" ]] && (_x86_64_pacman_use_default || exit 1) _cachedir_check @@ -23,11 +23,11 @@ if echo "${_BASENAME}" | grep -qw "${_RUNNING_ARCH}"; then else # running system != creating system if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then - if echo "${_BASENAME}" | grep -qw aarch64; then + if echo "${_BASENAME}" | rg -qw 'aarch64'; then _pacman_chroot "${_REPODIR}" "${_ARCHBOOT_AARCH64_CHROOT_PUBLIC}" \ "${_PACMAN_AARCH64_CHROOT}" || exit 1 fi - if echo "${_BASENAME}" | grep -qw riscv64; then + if echo "${_BASENAME}" | rg -qw 'riscv64'; then _pacman_chroot "${_REPODIR}" "${_ARCHBOOT_RISCV64_CHROOT_PUBLIC}" \ "${_PACMAN_RISCV64_CHROOT}" || exit 1 fi diff --git a/usr/lib/archboot/run/server-release.sh b/usr/lib/archboot/run/server-release.sh index 242616a98..85a7fd266 100755 --- a/usr/lib/archboot/run/server-release.sh +++ b/usr/lib/archboot/run/server-release.sh @@ -4,15 +4,15 @@ . /usr/lib/archboot/server.sh _root_check _container_check -if echo "${_BASENAME}" | grep -qw riscv64 || echo "${_BASENAME}" | grep -qw aarch64; then +if echo "${_BASENAME}" | rg -qw 'riscv64' || echo "${_BASENAME}" | rg -qw 'aarch64'; then _update_pacman_chroot || exit 1 fi _update_source -if echo "${_BASENAME}" | grep -qw x86_64; then +if echo "${_BASENAME}" | rg -qw 'x86_64'; then _x86_64_pacman_use_default || exit 1 fi _server_release || exit 1 -if echo "${_BASENAME}" | grep -qw x86_64; then +if echo "${_BASENAME}" | rg -qw 'x86_64'; then _x86_64_pacman_restore || exit 1 fi # vim: set ft=sh ts=4 sw=4 et: