Bug#419062: linux-image-2.6.20-1-sparc64: fails to boot, initramfs scripts problem
reassign -1 initramfs-tools
severity -1 normal
retitle -1 initamfs-tools: mkinitramfs fails with some locales
tag -1 + patch
thanks
> ok thanks, your initramfs-tools install seems b0rked:
> cd /usr/share/initramfs-tools/scripts/ \
> && find . -regex '.*/[a-z0-9_]+$'\'' -type f
>
> gives almost no output, please reinstall initramfs-tools.
"apt-get install --reinstall" reinstalled initramfs-tools 0.86. This
reran update-initrams, the resulting initrd.img had the same /scripts
with no files.
cd /usr/share/initramfs-tools/scripts/ &&
find . -regex '.*/[a-z0-9_]+$'\'' -type f
results in empty list again. The same with no regexp filter returns
./init-top/framebuffer
./init-bottom/udev
./local
./init-premount/udev
./init-premount/thermal
./nfs
./local-premount/resume
./local-top/lvm
./local-top/udev_helper
./functions
Hah, seems like a sloppy regex problem - should have noticed at once.
a-z should be [:lower:] to also work in Danish, Estonian and other
locales where there are more letters after z il alphabet (...szšžtuv...
in Estoanian for example). Or prepend the find with LANG=C.
Tested LANG=C update-initramfs -u -t -k 2.6.20-1-sparc64 and the
resulting initrd.img contained all the files, fine. Rebooted, seemed to
work (except that new kernel kad libata-pata enabled for pata_cmd64x and
my hda became sda... no problem if the experimental pata_cdm64x really
works - seems to be OK so far). So it's definitely a locale-specific
problem.
First it seemed like LANG=C find ... is the only sane solution here
since find -regex does not seem to know character classes but still
adheres to LC_COLLATE and so it's not possible to denote all lowercase
letters independently from locale. But man find tells about -regextype
posix-basic option, this might help... yes, it helps and makes character
classes work in find -regex.
But it's more strange than that - what's the trailing ' there for?
Removed it from my command-line testing, probably a escape from sh -x.
These work for me and list all the files:
find . -regextype posix-extended -regex '.*/[[:lower:]0-9_]+$' -type f
LANG=C find . -regex '.*/[a-z0-9_]+$' -type f
Regextype posix-basic would need \+, posix-extended works with just +.
Or we could just use find | grep ... if -regextype posix-extended seems
bad (for portability to busybox-embedded find or something like that) -
grep is usually more consistent regexp-matcher.
There are more a-z usages in initramfs-tools, here is a patch to correct
them. Tested to work - a initrd generated with this patch works fine.
Sorry, no source patch, but should be appliable to source just fine.
There is also an inconsitency - most places look for lowercase letters
only, one place for both upper and lower case letters. Bug or feature?
--- /usr/sbin/mkinitramfs.old 2007-04-13 20:55:44.000000000 +0300
+++ /usr/sbin/mkinitramfs 2007-04-13 20:55:49.000000000 +0300
@@ -84,7 +84,7 @@
. "${CONFDIR}/initramfs.conf"
EXTRA_CONF=''
for i in /usr/share/initramfs-tools/conf.d/* ${CONFDIR}/conf.d/*; do
- EXTRA_CONF="${EXTRA_CONF} $(basename $i | grep '^[a-z0-9][a-z0-9\._-]*$' | grep -v '\.dpkg-.*$')";
+ EXTRA_CONF="${EXTRA_CONF} $(basename $i | grep '^[[:lower:][:digit:]][[:lower:][:digit:]\._-]*$' | grep -v '\.dpkg-.*$')";
done
for i in ${EXTRA_CONF}; do
if [ -e ${CONFDIR}/conf.d/${i} ]; then
@@ -203,13 +203,14 @@
# add existant boot scripts
for b in $(cd /usr/share/initramfs-tools/scripts/ && find . \
- -regex '.*/[a-z0-9_]+$' -type f); do
+ -regextype posix-extended -regex '.*/[[:lower:][:digit:]_]+$' -type f); do
[ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \
|| mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")"
cp -p "/usr/share/initramfs-tools/scripts/${b}" \
"${DESTDIR}/scripts/$(dirname "${b}")"
done
-for b in $(cd "${CONFDIR}/scripts" && find . -regex '.*/[a-z0-9_]+$' -type f); do
+for b in $(cd "${CONFDIR}/scripts" && find . -regextype posix-extended \
+ -regex '.*/[[:lower:][:digit:]_]+$' -type f); do
[ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \
|| mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")"
cp -p "${CONFDIR}/scripts/${b}" "${DESTDIR}/scripts/$(dirname "${b}")"
--- /usr/share/initramfs-tools/scripts/functions.old 2007-04-13 20:11:37.000000000 +0300
+++ /usr/share/initramfs-tools/scripts/functions 2007-04-13 20:54:13.000000000 +0300
@@ -87,7 +87,7 @@
for si_x in ${initdir}/*; do
# only allow variable name chars
case ${si_x#${initdir}/} in
- *[!A-Za-z0-9_]*)
+ *[![:alnum:]_]*)
continue
;;
esac
--
Meelis Roos (mroos@linux.ee)
Reply to: