[pacman-dev] [PATCH] libalpm: Explicitly run install scriptlets in bash.
I was experimenting using dash as /bin/sh and noticed that a lot of packages were having errors in their install scriptlets. popen passes commands to /bin/sh so we need to explicitly invoke bash, which the scriptlets are written for. WOO! Signed-off-by: Loui Chang <louipc.ist@gmail.com> --- lib/libalpm/trans.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index d1c0e93..5e63326 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -435,6 +435,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn, { char scriptfn[PATH_MAX]; char cmdline[PATH_MAX]; + char cmdargs[PATH_MAX]; char tmpdir[PATH_MAX]; char *scriptpath; int clean_tmpdir = 0; @@ -486,13 +487,16 @@ int _alpm_runscriptlet(const char *root, const char *installfn, } if(oldver) { - snprintf(cmdline, PATH_MAX, ". %s; %s %s %s", + snprintf(cmdargs, PATH_MAX, "%s; %s %s %s", scriptpath, script, ver, oldver); } else { - snprintf(cmdline, PATH_MAX, ". %s; %s %s", + snprintf(cmdargs, PATH_MAX, "%s; %s %s", scriptpath, script, ver); } + /* Explicitly run scriptlets in bash */ + snprintf(cmdline, PATH_MAX, "/bin/bash -c 'source %s'", cmdargs); + retval = _alpm_run_chroot(root, cmdline); cleanup: -- 1.6.3.3
On Tue, Jul 28, 2009 at 6:34 PM, Loui Chang<louipc.ist@gmail.com> wrote:
I was experimenting using dash as /bin/sh and noticed that a lot of packages were having errors in their install scriptlets.
popen passes commands to /bin/sh so we need to explicitly invoke bash, which the scriptlets are written for. WOO!
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
On Tue 28 Jul 2009 18:50 +0200, Xavier wrote:
On Tue, Jul 28, 2009 at 6:34 PM, Loui Chang<louipc.ist@gmail.com> wrote:
I was experimenting using dash as /bin/sh and noticed that a lot of packages were having errors in their install scriptlets.
popen passes commands to /bin/sh so we need to explicitly invoke bash, which the scriptlets are written for. WOO!
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Hmm sticky situation. If that's the case, there needs to be better documentation. I assumed that install scripts could be written for bash just as makepkg and PKGBUILDs require bash. Is there any intention to make those dash compatible for consistency? It isn't reasonable to expect users to write those scripts for dash when other packaging scripts require bash to function properly. That, and /bin/sh still points to bash by default in Arch. Though that's out of pacman's scope, I think it's something to consider.
On Tue, Jul 28, 2009 at 12:46 PM, Loui Chang<louipc.ist@gmail.com> wrote:
On Tue 28 Jul 2009 18:50 +0200, Xavier wrote:
On Tue, Jul 28, 2009 at 6:34 PM, Loui Chang<louipc.ist@gmail.com> wrote:
I was experimenting using dash as /bin/sh and noticed that a lot of packages were having errors in their install scriptlets.
popen passes commands to /bin/sh so we need to explicitly invoke bash, which the scriptlets are written for. WOO!
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Hmm sticky situation. If that's the case, there needs to be better documentation.
I assumed that install scripts could be written for bash just as makepkg and PKGBUILDs require bash. Is there any intention to make those dash compatible for consistency?
It isn't reasonable to expect users to write those scripts for dash when other packaging scripts require bash to function properly.
That, and /bin/sh still points to bash by default in Arch. Though that's out of pacman's scope, I think it's something to consider.
Another thought would be to make the scriptlet executable and pass the "function" as an arg to the script, this way we can support #!/bin/bash and #!/bin/sh as well as a myriad of other things
On Tue, Jul 28, 2009 at 7:54 PM, Aaron Griffin<aaronmgriffin@gmail.com> wrote:
Another thought would be to make the scriptlet executable and pass the "function" as an arg to the script, this way we can support #!/bin/bash and #!/bin/sh as well as a myriad of other things
Then we need to put back the 3 magic lines in the few scripts where they were removed, don't we? In any cases, it shouldn't be difficult to do that change automatically on all scriptlets in the repo. And either way, I think this should be done. Either remove these lines from all scriptlets, or make sure all scriptlets have them.
On Tue, Jul 28, 2009 at 12:59 PM, Xavier<shiningxc@gmail.com> wrote:
On Tue, Jul 28, 2009 at 7:54 PM, Aaron Griffin<aaronmgriffin@gmail.com> wrote:
Another thought would be to make the scriptlet executable and pass the "function" as an arg to the script, this way we can support #!/bin/bash and #!/bin/sh as well as a myriad of other things
Then we need to put back the 3 magic lines in the few scripts where they were removed, don't we?
In any cases, it shouldn't be difficult to do that change automatically on all scriptlets in the repo. And either way, I think this should be done. Either remove these lines from all scriptlets, or make sure all scriptlets have them.
Yeah, I'm not advocating it, just saying it's a possibility. I think I might actually like Loui's proposal, although it needs to be more complex: Check for ROOTDIR/bin/bash, if it exists, use it Else, check for ROOTDIR/bin/sh and use THAT if it exists If none exist, warn and carry on
On Tue 28 Jul 2009 13:03 -0500, Aaron Griffin wrote:
On Tue, Jul 28, 2009 at 12:59 PM, Xavier<shiningxc@gmail.com> wrote:
On Tue, Jul 28, 2009 at 7:54 PM, Aaron Griffin<aaronmgriffin@gmail.com> wrote:
Another thought would be to make the scriptlet executable and pass the "function" as an arg to the script, this way we can support #!/bin/bash and #!/bin/sh as well as a myriad of other things
Then we need to put back the 3 magic lines in the few scripts where they were removed, don't we?
In any cases, it shouldn't be difficult to do that change automatically on all scriptlets in the repo. And either way, I think this should be done. Either remove these lines from all scriptlets, or make sure all scriptlets have them.
Yeah, I'm not advocating it, just saying it's a possibility. I think I might actually like Loui's proposal, although it needs to be more complex: Check for ROOTDIR/bin/bash, if it exists, use it Else, check for ROOTDIR/bin/sh and use THAT if it exists If none exist, warn and carry on
Maybe this would be better as an Arch Linux only patch, if there's an intention of making current scripts dash compatible.
participants (3)
-
Aaron Griffin
-
Loui Chang
-
Xavier