refind: eliminate ed dependency

post-install now depends on
- coreutils (df, mkdir, mktemp, mv, touch)
- awk

post-remove depends on:
- sed
This commit is contained in:
Doan Tran Cong Danh 2019-11-17 21:10:05 +07:00 committed by Juan RP
parent ef4f38d9b6
commit 7b1cb97f79
3 changed files with 38 additions and 23 deletions

View file

@ -19,21 +19,31 @@ zrefind_dir="${REFIND_CONF%/*}"
mkdir -p "$zrefind_dir" mkdir -p "$zrefind_dir"
touch "$REFIND_CONF" touch "$REFIND_CONF"
tmpfile=$(mktemp /tmp/refind.XXXXXXX)
zefi_mountpoint=$(df -P "$REFIND_CONF" | awk 'NR==2{print $6}') zefi_mountpoint=$(df -P "$REFIND_CONF" | awk 'NR==2{print $6}')
zicon="${zrefind_dir#$zefi_mountpoint}/icons/os_void.png" zicon="${zrefind_dir#$zefi_mountpoint}/icons/os_void.png"
mkedscript() { zprocess() {
zversion=$(echo $VERSION | sed 's/[.]/[.]/g') has_timeout=no
zexpr='^menuentry "Void Linux '"$zversion"'" {$' inserted=no
if grep -q "$zexpr" "$REFIND_CONF"; then skipping=no
# Do not merge into /expr/,/}/d, it doesn't work while IFS= read -r line; do
printf '%s\n' "/$zexpr/" '.,/}/d' if [ $skipping = yes ]
fi then
if [ "x$line" = "x}" ]
cat <<EOF then
1 skipping=no
/^menuentry / fi
i continue
elif [ "x${line#timeout[[:space:]]}" != "x${line}" ]
then
has_timeout=yes
elif [ "$inserted" = no ] &&
[ "x${line#menuentry }" != "x$line" ]
then
inserted=yes
cat <<EOF
menuentry "Void Linux $VERSION" { menuentry "Void Linux $VERSION" {
icon $zicon icon $zicon
volume "Void Linux" volume "Void Linux"
@ -41,14 +51,23 @@ menuentry "Void Linux $VERSION" {
initrd /initramfs-$VERSION.img initrd /initramfs-$VERSION.img
options "$OPTIONS" options "$OPTIONS"
} }
.
EOF EOF
fi
if ! grep -q '^timeout ' "$REFIND_CONF"; then if [ "x$line" = 'xmenuentry "Void Linux '"$VERSION"'" {' ]
printf '%s\n' 1i "timeout 20" . then
skipping=yes
else
printf '%s\n' "$line"
fi
done
if [ $has_timeout = no ]
then
echo 'timeout 20'
fi fi
echo wq
} }
zprocess <"$REFIND_CONF" >"$tmpfile"
mv "$tmpfile" "$REFIND_CONF"
mkedscript | ed "$REFIND_CONF" >/dev/null
exit 0 exit 0

View file

@ -21,8 +21,4 @@ tmpfile=$(mktemp /tmp/refind.XXXXXXX)
zversion=$(echo $VERSION | sed 's/[.]/[.]/g') zversion=$(echo $VERSION | sed 's/[.]/[.]/g')
sed "/^menuentry \"Void Linux $zversion\" [{]\$/,/[}]/d" "$REFIND_CONF" >"$tmpfile" sed "/^menuentry \"Void Linux $zversion\" [{]\$/,/[}]/d" "$REFIND_CONF" >"$tmpfile"
if ! cmp -s "$REFIND_CONF" "$tmpfile"; then mv "$tmpfile" "$REFIND_CONF"
mv "$tmpfile" "$REFIND_CONF"
else
rm -f "$tmpfile"
fi

View file

@ -1,7 +1,7 @@
# Template file for 'refind' # Template file for 'refind'
pkgname=refind pkgname=refind
version=0.11.4 version=0.11.4
revision=2 revision=3
makedepends="gnu-efi-libs git" makedepends="gnu-efi-libs git"
depends="bash dosfstools efibootmgr" depends="bash dosfstools efibootmgr"
short_desc="EFI boot manager utility" short_desc="EFI boot manager utility"