Hide Forgot
Description of problem: The "Unknown tag:" in this error message is binary data. The error message should contain a hexadecimal representation of the binary data. $ rpmspec -q --srpm firefox-44.0.1-2.fc23.src.rpm error: line 1: Unknown tag: ���� error: query of specfile firefox-44.0.1-2.fc23.src.rpm failed, can't parse Verify with: $ rpmspec -q --srpm firefox-44.0.1-2.fc23.src.rpm |& hexdump -C Version-Release number of selected component (if applicable): rpm-4.13.0-0.rc1.11.fc23.x86_64 See also: Bug 1308133 - [Doc] rpmspec help does not match man page; man page needs usage examples (was: rpmspec fails to parse source rpm)
(In reply to Steve from comment #0) > The error message > should contain a hexadecimal representation of the binary data. A better idea is to verify first that the file is a text file. The "file" command knows the difference between a text file and an RPM file: $ file firefox.spec firefox-44.0.1-2.fc23.src.rpm firefox.spec: UTF-8 Unicode text firefox-44.0.1-2.fc23.src.rpm: RPM v3.0 src
I added some special code to detect when a binary package is passed instead of a spec file.
(In reply to Florian Festi from comment #2) > I added some special code to detect when a binary package is passed instead > of a spec file. Thanks, Florian.[1] Binary data could still be written to the terminal in other cases: $ rpmspec -q firefox-44.0.1.source.tar.xz error: line 1: Unknown tag: �7zXZ error: query of specfile firefox-44.0.1.source.tar.xz failed, can't parse $ hexdump -C firefox-44.0.1.source.tar.xz | head -1 00000000 fd 37 7a 58 5a 00 00 04 e6 d6 b4 46 02 00 21 01 |.7zXZ......F..!.| [1] https://github.com/rpm-software-management/rpm/commit/d93c97b60673d725b9eb255008b8a57dfad65fdb
Created attachment 1131610 [details] reverse-video.spec test file that sets reverse video on a terminal This sets reverse video on a terminal, because the "rpmspec" command writes binary data to the terminal: $ rpmspec -q reverse-video.spec error: line 1: Unknown tag: error: query of specfile reverse-video.spec failed, can't parse The "rpm" command handles the same file gracefully: $ rpm -q -p reverse-video.spec error: reverse-video.spec: not an rpm package (or package manifest) Contents of the test file: $ hexdump -C reverse-video.spec 00000000 1b 5b 3f 35 68 00 00 00 00 00 00 00 00 00 00 00 |.[?5h...........|
rpmCharCheck()[1] checks for invalid characters. Is it being called? [1] https://github.com/rpm-software-management/rpm/blob/d93c97b60673d725b9eb255008b8a57dfad65fdb/build/parsePreamble.c#L613
No, but it also dumps the line unquoted into the terminal...
(In reply to Florian Festi from comment #6) > No, but it also dumps the line unquoted into the terminal... Thanks for pointing that out. A "check" function should not be writing any error messages ... The simplest solution might be to do what the "rpm" command does and not put any string from the file in the error message.