_ 2013MAY01 EDIT:
_ Changed the order of the arguments, according to the first beta. When executed with no arguments, a simple help is displayed. The arguments are increasingly optional, so it is possible to provide just the "pmagic-extracted" path and the script should work, asking confirmation from the user.
_ First beta attached to post #12, reply #11._ Beta2 attached to post #152013MAY13 EDIT:
_ Beta3 attached to
post #22 ;
post #12 and
post #15 are still relevant (read them)
______
I am seeking help here to put together a pm2ubcd.sh script to customize UBCD with an updated version of PMagic. Since PMagic releases are much more frequent than UBCD's ones, this should simplify the task for users, in a similar way as other scripts in UBCD. If it works as expected, Victor can hopefully add it to the next release of UBCD.
Here are the minimal conditions and goals:
_ The script would be located under
ubcd-extracted/ubcd/tools/linux/pm2ubcd/
, named
pm2ubcd.sh
.
_ The task of downloading and extracting the content of (Pmagic's and UBCD's) ISO images is up to the user.
_ The script should not care about the specific version or variant of PMagic. The user might want to use an older version of PMagic, or a newer one, or a different variant (i586, i686, x86_64).
_ The script should work on UBCD v5.2.1. Older versions of UBCD won't be supported by the script.
_ Similarly to other scripts in UBCD, the arguments needed by the script would be:
13_ "iso_filename=" parameter (to modify PMagic's syslinux.cfg);
21_ Path where the content of the PMagic ISO image is located (already extracted by the user);
32_ Path where the content of UBCD is located (already extracted by the user).
There could be an alternative way to the first argument. Instead of the user having to provide the "iso_filename=" argument, it could (potentially) be read from other files in "
ubcd-extracted
". For the time being, I'm inclined to request this parameter from the user.
_
The script should:
1_ Delete the prior squashfs PMagic file(s) such as
Code:
ubcd-extracted/pmagic/pmodules/PMAGIC_*.SQFS
Any other (modules, scripts, personal, configuration) files are not to be touched.
2_ Move
ubcd-extracted/pmagic/boot/syslinux/*.cfg
to
ubcd-extracted/pmagic/boot/syslinux/*_<MOVE_DATE__MOVE_TIME>.cfg.old
3_ Copy (overwriting files and
merging directories):
Code:
pmagic-extracted/pmagic/ ==>> ubcd-extracted/pmagic/
Code:
pmagic-extracted/boot/ ==>> ubcd-extracted/pmagic/boot/
4_ Delete unnecessary files (or exclude them from the previous "copy" step):
Code:
ubcd-extracted/pmagic/boot/syslinux/*.c32
ubcd-extracted/pmagic/boot/syslinux/isohybrid
ubcd-extracted/pmagic/boot/syslinux/isolinux*.*
ubcd-extracted/pmagic/boot/syslinux/mbr.bin
ubcd-extracted/pmagic/boot/syslinux/memdisk
5_ Using "sed" and other "auxiliary tools" in a similar way as used in other scripts already included in UBCD, the new pm2ubcd.sh script should edit
ubcd-extracted/pmagic/boot/syslinux/*.cfg
as follows:
5.1_
Code:
F<digit> *message*.txt
==>> F<digit> /pmagic/boot/syslinux/message*.txt
5.2_
Code:
initrd=/pmagic/initrd.img
==>> initrd=/pmagic/initrd.img iso_filename=ubcd521.iso
which in fact is dependent on the first argument of the script but I used here "
ubcd521.iso
" just for clarity.
6_ Finally, executing the script without options should offer help about the script (let's leave this condition for later discussion).
The above conditions cover i586, i686 and dual x32/x64 variants of PMagic and UBCD v5.2.x.
The following are "parts and pieces" of the above condition #5 of the pm2ubcd.sh script, in alpha stage; has NOT been tested, and it may possibly contain pseudo-code.
Code:
# Change the working directory to the root directory of the extracted iso.
SCRIPTDIR=`dirname "${0}"`
cd "${SCRIPTDIR}/../../../../"
# Get all syslinux config files from /pmagic/boot/syslinux/, that need to be edited.
SYSLINUX_CONFIGFILES_PMAGIC=`find ./pmagic/boot/syslinux/ -name '*.cfg'`
# 'Point to /pmagic/boot/syslinux/ where appropriate:'
for SYSLINUX_CONFIGFILE_PMAGIC in $SYSLINUX_CONFIGFILES_PMAGIC; do
sed 's|^F[[:digit:]] \(.*\)\message\(.*\)\.txt|^F[[:digit:]] /pmagic/boot/syslinux/message\2\.txt'
done
# NEED TO ESTABLISH ISO_FILENAME VARIABLE FROM SCRIPT FIRST ARGUMENT
#
# 'Add iso_filename parameter'
# for SYSLINUX_CONFIGFILE_PMAGIC in $SYSLINUX_CONFIGFILES_PMAGIC; do
# sed 's| initrd=/pmagic/initrd.img | initrd=/pmagic/initrd.img iso_filename=ubcd521.iso'
# done
I would like to request help to put together the complete script, respecting all the aforementioned conditions / steps.
Suggestions, ideas, improvements, code... are all welcome.
TIA,
Ady.