One-click editing of initrd.gz
April 07, 2012 —
BarryK
This has been such a long time coming! I think that someone did develop a tool for editing an initrd.gz file, but anyway, I decided that it is about time this feature was built-in to Woof.
Just as we can click on any .sfs, .2fs or .3fs file in a ROX-Filer window, and have them opened up, now the same can be done with a 'initrd.gz' file.
initrd.gz is the initramfs, that gets loaded by the kernel. Developers often want to modify this file, perhaps to just quickly test a change. Or when remastering and want to make a permanent change.
Now, just click on a 'initrd.gz' file and it is recognised as mime-type 'application/initramfs-gz' and ROX-Filer will run /usr/sbin/edit-initramfs. The latter is a new script. The initrd.gz gets expanded at /root/initrd-expanded. After any modifications, clicking on the initrd.gz file again will update it. Dialog windows clearly explain each step.
This will work in all future Woof-built puppies, but for anyone who wants to implement it right now, you need to do these things:
1. Mime type
Append this line "application/initramfs-gz:initrd.gz" into /usr/share/mime/globs.
2. ROX-Filer
Get the file 'http://bkhome.org/fossil/woof2.cgi/finfo?name=woof-code/rootfs-skeleton/root/Choices/MIME-types/application_initramfs-gz'.
3. Handler script
Get the script 'http://bkhome.org/fossil/woof2.cgi/finfo?name=woof-code/rootfs-skeleton/usr/sbin/edit-initramfs'
Woof commit:
http://bkhome.org/fossil/woof2.cgi/info/5c05a1fe16
Note, it is supposed to automatically recognise gzip, bzip2 and xz compression of intrd.gz, however I have only tested gzip.
Comments
mime/globsUsername: L18L
[i][b]Append[/b] this line "application/initramfs-gz:initrd.gz" into /usr/share/mime/globs. [/i] Append means at the end? This does not work. But inserted at line number 3 ([b]prepend[/b]ed) it works.
Re prepended
Username: BarryK
"Before I posted that advice, I tested. I prepended and appended, both worked. I concluded that position does not matter. I had wondered if the earlier *gz would be found first and used, but not so. I just tried it again, appended, it works.
globs
Username: MHHP
"IIRC, /../../globs must not contain any empty lines and must end with an empty new line. FWIW /MHHP
Re globs
Username: BarryK
"Yes, it is likely that L18L left off the newline on the last entry.
update puppy.xml too
Username: jamesbond
"Hi Barry, If you do this, please remember to update [b]/usr/share/mime/packages/puppy.xml[/b] too. That globs and globs2 file are re-created from those xml files when one runs update-mime-database (some installers will do this) - if you don't add the entry to puppy/xml, the changes you put in globs/globs2 will be lost. cheers!
spoke too soon
Username: jamesbond
"Please ignore the above, I see you have done that already :) cheers!
re re globs
Username: L18L
"I confirm: my wrong result was without newline
2 initrd files
Username: scottman
"I have found you cannot edit 2 initrd.gz files at the same time.. If I already have 1 initrd.gz file unpacked to edit, and I click on another to open up that one as well, the script gets tricked into thinking I have clicked on the first one again, and asks me to re-package it... This is probably not important, although it does mean users cannot open 2 initrd.gz files and copy the contents of one into the other...
Re 2 initrd files
Username: BarryK
"scottman, You can, just rename the first 'initrd-expanded' folder, the one that you want to copy files out of.
save over 5mb per iso
Username: technosaurus
"I have been doing this a while for speed, but it turns out to also have a significant effect on the sfs size - to the tune of over 5Mb (a normally >24Mb zdrv reduces to <19Mb) [code]cd /lib/modules/$KERNEL_VERSION while read LINE; do echo ${LINE##*/}; done <modules.order >modules.order~ mv -f modules.order~ modules.order for KO in `find . -type f -name *.ko`;do mv "$KO" .;done for x in *; do [ -d "$x" ] && rm -rf "$x"; done depmod[/code] short, simple, effective (at least on my hardware) (Note: some embedded software has paths hard-coded - perhaps ndis_wrapper - though this would simplify those codes immensely) You can think scottman for reminding me of this, since it was his oops that jostled my recollection.
Tags: woof