You are not logged in.
Hi everyone,
I am trying to modify the grub2-efi-bzr (http://aur.archlinux.org/packages.php?ID=38369) package making some changes in the PKGBUILD and the post-install script. I want to pass few environment variables from the PKGBUILD to the install script. How do I do that?
Some code from the PKGBUILD
_bzrtrunk="lp:grub/grub2" # GRUB2 BZR Main Trunk
# _bzrtrunk="lp:~skodabenz/grub/grub2-bzr-exp" # GRUB2 BZR Experimental Branch
_bzrmod="grub2"
if [ ${_bzrtrunk} = "lp:~skodabenz/grub/grub2-bzr-exp" ]
then
_bzrmod="grub2_exp"
pkgver="exp_${pkgver}"
fi
# grub-extras bzr repo locations
_bzrtrunk_zfs="lp:~skodabenz/grub/grub2-extras-zfs"
_bzrtrunk_lua="lp:~skodabenz/grub/grub2-extras-lua"
if [ "$CARCH" = 'i686' ]
then
_EFI_ARCH=i386
elif [ "$CARCH" = 'x86_64' ]
then
_EFI_ARCH=x86_64
fi
# _EFI_ARCH=x86_64 # Uncomment if you want to override the if condition for _EFI_ARCH above, incase the EFI ARCH does not match the Linux Kernel ARCH.
# $CARCH=x86_64 and _EFI_ARCH=i386 requires gcc-multilib with lib32-glibc installed in the system.
# I do not know about $CARCH=i686 and _EFI_ARCH=x86_64
if [ ${_EFI_ARCH} = "i386" ]
then
pkgver="${pkgver}_x86"
_trns_name="grub2_efi_x86"
elif [ ${_EFI_ARCH} = "x86_64" ]
then
pkgver="${pkgver}_x64"
_trns_name="grub2_efi_x64"
fi
Now the post-install script needs the values of _EFI_ARCH and _trns_name env variables. I do not want to copy the if statements to that script as these are decided at compile time but needed while setting up grub2-efi. This is due to the fact that EFI-ARCH need not match the Linux Kernel ARCH. How do I do that.
Code from the post-install script
${_trns_name}-install --root-directory=/ --no-floppy --recheck --debug
cp /usr/lib/${_trns_name}/${_EFI_ARCH}-efi/lua.mod /boot/${_trns_name}/
cp /usr/lib/${_trns_name}/${_EFI_ARCH}-efi/zfs.mod /boot/${_trns_name}/
cp /usr/lib/${_trns_name}/${_EFI_ARCH}-efi/zfsinfo.mod /boot/${_trns_name}/
cp /usr/lib/${_trns_name}/${_EFI_ARCH}-efi/unifont.pf2 /boot/${_trns_name}/
cp /usr/lib/${_trns_name}/${_EFI_ARCH}-efi/ascii.pf2 /boot/${_trns_name}/
${_trns_name}-mkimage --verbose --directory=/usr/lib/${_trns_name}/${_EFI_ARCH}-efi --prefix="" --output=/boot/${_trns_name}/grub2.efi --format=${_EFI_ARCH}-efi ${_EFI_APP_MODULES}
Thank in advance.
Last edited by skodabenz (2010-07-27 15:46:40)
My new forum user/nick name is "the.ridikulus.rat" .
Offline
Offline
Thanks. I used sed as you suggested and it works. If possible can you check whether the PKGBUILD is correct.
My new forum user/nick name is "the.ridikulus.rat" .
Offline
Don't rely on %foo% existing -- it won't after the first build and this will prevent the PKGBUILD from being reentrant. I would use something like this (untested):
sed -i "s|^\(_EFI_ARCH\)=.*|\1=${_EFI_ARCH}|; \
s|^\(_trns_name\)=.*|\1=${_trns_name}|; \
s|^\(export _EFI_APP_MODULES\)=.*|\1=${_EFI_APP_MODULES}|" \
${startdir}/grub2-efi-bzr.install
Offline
Don't rely on %foo% existing -- it won't after the first build and this will prevent the PKGBUILD from being reentrant. I would use something like this (untested):
sed -i "s|^\(_EFI_ARCH\)=.*|\1=${_EFI_ARCH}|; \ s|^\(_trns_name\)=.*|\1=${_trns_name}|; \ s|^\(export _EFI_APP_MODULES\)=.*|\1=${_EFI_APP_MODULES}|" \ ${startdir}/grub2-efi-bzr.install
Your code works except for 1 problem in the install script I want
export __EFI_APP_MODULES="${_EFI_APP_MODULES}" (the passed ${_EFI_APP_MODULES} value should again come inside double quotes).
right now
export _EFI_APP_MODULES=ata part_gpt part_msdos fat ntfs ntfscomp ext2 iso9660 udf hfsplus fshelp normal chain linux ls search search_fs_file search_fs_uuid search_label help loopback boot configfile echo efi_gop efi_uga xnu xnu_uuid lvm
which is equivalent to
export _EFI_APP_MODULES=ata
I want
export _EFI_APP_MODULES="ata part_gpt part_msdos fat ntfs ntfscomp ext2 iso9660 udf hfsplus fshelp normal chain linux ls search search_fs_file search_fs_uuid search_label help loopback boot configfile echo efi_gop efi_uga xnu xnu_uuid lvm"
How to do it with sed since sed already uses double quotes?
My new forum user/nick name is "the.ridikulus.rat" .
Offline
I used Double quotes inside single quotes for _EFI_APP_MODULES in the PKGBUILD and that solved the problem. Thanks for the help. Can you check the PKGBUILD now?
_EFI_APP_MODULES='"ata part_gpt part_msdos fat ntfs ntfscomp ext2 iso9660 udf hfsplus fshelp normal chain linux ls search search_fs_file search_fs_uuid search_label help loopback boot configfile echo efi_gop efi_uga xnu xnu_uuid lvm"'
Solution from : http://www.tek-tips.com/viewthread.cfm? … 6&page=101
Last edited by skodabenz (2010-07-28 11:36:43)
My new forum user/nick name is "the.ridikulus.rat" .
Offline
Escaping double quotes inside the sed expression would work as well. This might be a bit cleaner, as an overly curious user might be tempted to remove the single quotes.
Rest of it looks fine by me, but I'm by no means a proper substitute for a Bash interpreter, or makepkg. Does it build? Does it rebuild correctly?
Offline
The package build very well and the versioning occurs as I intended. I know next to nothing about sed and such commands. That's why I started this topic. Do you know any site where hints like the one you gave me, are available. Thank you.
My new forum user/nick name is "the.ridikulus.rat" .
Offline
Offline