Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 463752 - sys-apps/kexec-tools-2.0.4 missing quotation marks in test for ${INITRD}
Summary: sys-apps/kexec-tools-2.0.4 missing quotation marks in test for ${INITRD}
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Justin Lecher (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-29 16:34 UTC by Christer Ekholm
Modified: 2013-04-01 13:18 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christer Ekholm 2013-03-29 16:34:21 UTC
sys-apps/kexec-tools-2.0.4 doesn't work without a initrd.


There is a bug in the test for initrd. The test for nonzero length of
${INITRD} is missing neccesary quotation marks, which result in this
when run with -d

+ img=/boot/vmlinuz-3.8.5
+ '[' -n ']'
+ '[' -z ']'
+ eerror 'Requested initrd: '
 * Requested initrd: 
+ eerror 'could not be found'
 * could not be found
+ return 1
+ eend 

The solution is to add quotation-mark like this:

--- files/kexec.init-2.0.4.~1~	2013-03-27 12:50:55.000000000 +0100
+++ files/kexec.init-2.0.4	2013-03-29 17:23:15.774419925 +0100
@@ -80,7 +80,7 @@
 		fi
 	fi
 
-	if [ -n ${INITRD}] && [ -z ${initrd} ]; then
+	if [ -n "${INITRD}" ] && [ -z "${initrd}" ]; then
 		eerror "Requested initrd: ${INITRD}"
 		eerror "could not be found"
 		return 1
Comment 1 Christer Ekholm 2013-03-29 16:59:47 UTC
I also found missing quotes resulting in a "whith " in the message.

 	local msg=
-	[ -n ${initrd} ] && \
+	[ -n "${initrd}" ] && \
 		msg="with ${initrd}"
Comment 2 iGentoo 2013-03-30 07:39:10 UTC
# checkbashisms /usr/portage/sys-apps/kexec-tools/files/kexec.init-2.0.4 

possible bashism in /usr/portage/sys-apps/kexec-tools/files/kexec.init-2.0.4 line 92 (should be VAR="${VAR}foo"):
	[ -n "${KPARAM}" ] || KEXEC_OPT_ARGS+=" --reuse-cmdline"
Comment 3 Justin Lecher (RETIRED) gentoo-dev 2013-03-30 13:02:06 UTC
+*kexec-tools-2.0.4-r1 (30 Mar 2013)
+
+  30 Mar 2013; Justin Lecher <jlec@gentoo.org> files/kexec.init-2.0.4,
+  -kexec-tools-2.0.4.ebuild, +kexec-tools-2.0.4-r1.ebuild:
+  Fix init script if no initrd is used, #463752
+
Comment 4 iGentoo 2013-03-30 16:25:49 UTC
(In reply to comment #3)
> +*kexec-tools-2.0.4-r1 (30 Mar 2013)
> +
> +  30 Mar 2013; Justin Lecher <jlec@gentoo.org> files/kexec.init-2.0.4,
> +  -kexec-tools-2.0.4.ebuild, +kexec-tools-2.0.4-r1.ebuild:
> +  Fix init script if no initrd is used, #463752
> +

 * QA Notice: shell script appears to use non-POSIX feature(s):
 *    possible bashism in /etc/init.d/kexec line 84 (should be 'b = a'):
 *    	if [ -n "${INITRD}" ] && \
 *    		! [ "${INITRD}" == "${initrd}" ]; then
 *    possible bashism in /etc/init.d/kexec line 93 (should be VAR="${VAR}foo"):
 *    	[ -n "${KPARAM}" ] || KEXEC_OPT_ARGS+=" --reuse-cmdline"
Comment 5 Christer Ekholm 2013-03-30 16:45:51 UTC
(In reply to comment #3)
> +*kexec-tools-2.0.4-r1 (30 Mar 2013)
> +
> +  30 Mar 2013; Justin Lecher <jlec@gentoo.org> files/kexec.init-2.0.4,
> +  -kexec-tools-2.0.4.ebuild, +kexec-tools-2.0.4-r1.ebuild:
> +  Fix init script if no initrd is used, #463752
> +

I can confirm that it works now.

Thanks!

The cosmetic glitch resulting in a message "with ", when $initrd is
empty is still present though (see Comment 1). Not important at all,
leave it like that unless you are making other changes also.
Comment 6 Justin Lecher (RETIRED) gentoo-dev 2013-04-01 13:18:24 UTC
How do you check for POSIX compliance?

+  01 Apr 2013; Justin Lecher <jlec@gentoo.org> files/kexec.init-2.0.4:
+  Fix bashism in init script, #463752
+