replace grep and sed with rg and sd

This commit is contained in:
Tobias Powalowski 2024-06-26 12:00:47 +02:00
parent cb685921df
commit a41219f4b7
5 changed files with 17 additions and 22 deletions

View file

@ -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

View file

@ -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

View file

@ -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."

View file

@ -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

View file

@ -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: