Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#55250 - [syslinux] syslinux-install_update fails when using /dev/loop0 with gpt partitions

Attached to Project: Arch Linux
Opened by elionne (elionne) - Wednesday, 23 August 2017, 13:04 GMT
Last edited by Anatol Pomozov (anatolik) - Saturday, 20 January 2018, 22:19 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Anatol Pomozov (anatolik)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

When I use syslinux-install_update on a local image file attached to /dev/loop0 it fails with :

/usr/bin/syslinux-install_update: line 116: warning: command substitution: ignored null byte in input
sfdisk: toggle boot flags is supported for MBR only # added log
FAILED to Set the boot flag on /dev/loop0p1

My partitions are gpt and attached respectively to /dev/loop0p{1,2,3}

Additional info:
* syslinux (6.03-7)

Steps to reproduce:

I want to use syslinux-install_update to add a boot loader to a local image file.

I use the following script

# First I create an image file:
truncate -s 3G disk.img

# Create 3 gpt partitions for the system
cat <<EOF | sfdisk disk.img
label: gpt

start=2048, size=100M, bootable, name=boot
size=+500M, name=swap, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
name=root
EOF

losetup --partscan /dev/loop0 disk.img

The last command attaches my partitions to /dev/loop0p{1,2,3}.
After creating my Archlinux install on root I want to install syslinux as bootloader, so:

mount /dev/loop0p3 archlinux
mount /dev/loop0p1 archlinux/boot

syslinux-install_update -c archlinux -i -a -m

But it fails with the above errors.

I fix the problem by patching function "get_disk" with the following patch.

--- a/syslinux-install_update 2017-08-23 14:23:28.109304021 +0200
+++ b/syslinux-install_update 2017-08-23 14:24:57.451532689 +0200
@@ -60,7 +60,7 @@

case "$part" in
*[[:digit:]]p[[:digit:]]*)
- local disk="${part%%p${partnum}}" # get everything before p1
+ local disk="${part%%p[[:digit:]]}" # get everything before p1
;;
*)
local disk="${part%%[[:digit:]]*}"

This task depends upon

Closed by  Anatol Pomozov (anatolik)
Saturday, 20 January 2018, 22:19 GMT
Reason for closing:  Fixed
Comment by Anatol Pomozov (anatolik) - Saturday, 09 September 2017, 20:23 GMT
In your patch partnumber should be [[:digit:]]* to match situation when partnumber has two digits.
Comment by Anatol Pomozov (anatolik) - Saturday, 09 September 2017, 20:23 GMT
Just merged as r305194
Comment by elionne (elionne) - Monday, 11 September 2017, 22:43 GMT
I think the match pattern is not good.

I tried the following example in bash:

part=/dev/loop0p1
echo ${part%%p[[:digit:]]} # > /dev/loop0
echo ${part%%p[[:digit:]]*} # > /dev/loo

I think, because loop finish with a 'p' the last match not work. But with a single '%' it works.

part=/dev/loop0p11
echo ${part%p[[:digit:]]*} # > /dev/loop0

part=/dev/loop0p1
echo ${part%p[[:digit:]]*} # > /dev/loop0

part=/dev/loop11p11
echo ${part%p[[:digit:]]*} # > /dev/loop0

Comment by Anatol Pomozov (anatolik) - Monday, 11 September 2017, 22:49 GMT
Thanks for the clarification. Do we expect "part == /dev/loop0" (i.e. partition equals to the whole block device) work?
Comment by elionne (elionne) - Monday, 11 September 2017, 23:45 GMT
I think so. To be more precise $disk (i.e /dev/sda /dev/sdb /dev/loop2) is the whole block device and $part it is the partition number (/dev/sda1, /dev/loop2p1).

I'm sorry if what I'm saying is obvious. Just to be sure.
Comment by Anatol Pomozov (anatolik) - Tuesday, 12 September 2017, 00:03 GMT
As far as I understand single % in bash string matching means shortest match, thus it should work in our case. Double %% means longest match thus ${part%%p[[:digit:]]*} should also match /dev/loop0p1. Do you have explanation why it does not work?
Comment by elionne (elionne) - Tuesday, 12 September 2017, 00:07 GMT
I think because '*' match any characters (wildcard). It is not like regexp match (0 or more).
Comment by Anatol Pomozov (anatolik) - Tuesday, 12 September 2017, 00:16 GMT
If so then the pattern with the start means `p\d.*` and it is not the same as what we want (`p\d*`). I am going to return to non-star pattern and hope nobody uses more than 10 partitions at mmcblk
Comment by Anatol Pomozov (anatolik) - Tuesday, 12 September 2017, 16:50 GMT
The fix is merged as r305369

Loading...