You are not logged in.

#1 2011-06-17 22:19:13

akurei
Member
From: Bochum, NRW, Germany
Registered: 2009-05-25
Posts: 152
Website

[SOLVED] (PKGBUILD) Nested if statement... Why is that not working?

The tarball: http://files.iowolf.de/public/kernel26-lqx-test.tgz

I modified kernel26-lqx PKGBUILD, but I cannot get it to NOT execute the statement in line 98 of the PKGBUILD.
This is the block:

   if [ $_localmodcfg = "y" ]; then
      msg "If you have modprobe_db installed, running reload_database now"
      if [[ -e /usr/bin/reload_database ]]; then
         if [[ -e /usr/bin/kajsakskakskkakskaskak ]]; then
            sudo /usr/bin/reload_database
         else
            if [ $(whoami) != "root" ]; then
               msg2 "WARNING: You should either install sudo or run makepkg as root (not recommended) to successfully execute \"reload_database\"!"
               msg2 "Continue? [y/N] "
               read _yesno
               if [ "$_yesno" != "y" -a "$_yesno" != "Y" ]; then
                  exit 1
               fi
            fi
            /usr/bin/reload_database
         fi
      fi
      msg "Running Steven Rostedt's make localmodconfig now"
      make localmodconfig
   else
      if [ $_oldcfg = "y" ]; then
         if [ ! -f /proc/config.gz  ]; then
            echo "WARNING: There's no \"/proc/config.gz\". Please unselect _oldcfg. Aborting..." 1>&2
            exit 1
         fi
         yes "" | make oldconfig
      else
         yes "" | make config
      fi
   fi

It ALWAYS executes the "sudo /usr/bin/reload_database" and I don't know why?

Does anyone have a suggestion, please?

EDIT:

Strange, it is working outside of the PKGBUILD in a seperate file...

test.sh

#!/bin/bash
_localmodcfg="y"
_oldcfg="n"

   if [ $_localmodcfg = "y" ]; then
      echo "If you have modprobe_db installed, running reload_database now"
      if [[ -e /usr/bin/reload_database ]]; then
         if [[ -e /usr/bin/kajsakskakskkakskaskak ]]; then
            sudo /usr/bin/reload_database
         else
            if [ $(whoami) != "root" ]; then
               echo "WARNING: You should either install sudo or run makepkg as root (not recommended) to successfully execute \"reload_database\"!"
               echo "Continue? [y/N] "
               read _yesno
               if [ "$_yesno" != "y" -a "$_yesno" != "Y" ]; then
                  exit 1
               fi
            fi
            /usr/bin/reload_database
         fi
      fi
      echo "Running Steven Rostedt's make localmodconfig now"
   else
      if [ $_oldcfg = "y" ]; then
         if [ ! -f /proc/config.gz  ]; then
            echo "WARNING: There's no \"/proc/config.gz\". Please unselect _oldcfg. Aborting..." 1>&2
            exit 1
         fi
         echo "make oldconfig"
      else
         echo "make config"
      fi
   fi

Output

akurei@joel: /tmp $ LANG=C bash lol.sh
If you have modprobe_db installed, running reload_database now
WARNING: You should either install sudo or run makepkg as root (not recommended) to successfully execute "reload_database"!
Continue? [y/N] 
n
akurei@joel: /tmp $ LANG=C bash lol.sh
If you have modprobe_db installed, running reload_database now
WARNING: You should either install sudo or run makepkg as root (not recommended) to successfully execute "reload_database"!
Continue? [y/N] 
y
WARNING: Error inserting hdaps (/lib/modules/2.6.39-ARCH/kernel/drivers/platform/x86/hdaps.ko): No such device or address
Running Steven Rostedt's make localmodconfig now

Last edited by akurei (2011-06-19 19:41:14)

Offline

#2 2011-06-18 11:14:54

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [SOLVED] (PKGBUILD) Nested if statement... Why is that not working?

That's interesting. I found this faq explaining the difference between [ and [[ but, while instructive for me, I don't think it helps smile.

Are you sure it's executing line 98 and not the second "/usr/bin/reload_database", the whole script being run as root?

Offline

#3 2011-06-18 13:40:28

akurei
Member
From: Bochum, NRW, Germany
Registered: 2009-05-25
Posts: 152
Website

Re: [SOLVED] (PKGBUILD) Nested if statement... Why is that not working?

stqn wrote:

That's interesting. I found this faq explaining the difference between [ and [[ but, while instructive for me, I don't think it helps smile.

I did try with single brackets, too. But it did not work either.

Are you sure it's executing line 98 and not the second "/usr/bin/reload_database", the whole script being run as root?

Pretty much, because it is asking for my password for sudo and I run this by executing "makepkg -fc".

Offline

#4 2011-06-18 13:42:00

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [SOLVED] (PKGBUILD) Nested if statement... Why is that not working?

Your PKGBUILD has no install function, which means the build function runs as fakeroot, altering your $UID/$USER.

Offline

#5 2011-06-19 15:31:16

akurei
Member
From: Bochum, NRW, Germany
Registered: 2009-05-25
Posts: 152
Website

Re: [SOLVED] (PKGBUILD) Nested if statement... Why is that not working?

Ah! Cool, I will try to fix it with that in mind! Thank you!

Offline

#6 2011-06-19 19:42:54

akurei
Member
From: Bochum, NRW, Germany
Registered: 2009-05-25
Posts: 152
Website

Re: [SOLVED] (PKGBUILD) Nested if statement... Why is that not working?

stqn wrote:

Are you sure it's executing line 98 and not the second "/usr/bin/reload_database", the whole script being run as root?

It turned out that it WAS executing the second "/usr/bin/reload_database". Seems like "reload_database" calls "sudo" by itself, that's what fooled me.

Offline

Board footer

Powered by FluxBB