FS#13803 - Using /bin/dash as /bin/sh breaks package installing.

Attached to Project: Arch Linux
Opened by Ramil (gravicappa) - Saturday, 14 March 2009, 13:49 GMT
Last edited by Roman Kyrylych (Romashka) - Saturday, 23 January 2010, 16:49 GMT
Task Type Bug Report
Category System
Status Closed
Assigned To No-one
Architecture All
Severity Medium
Priority Normal
Reported Version 3.3.3
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 5
Private No

Details

Description:
When /bin/sh is a symlink do /bin/dash instead of /bin/bash install scripts of
some package fail. Although it is written somewhere on forums that it is safe
to use dash as /bin/sh interpreter.

Packages that was caught failing (listed with error message):
coreutils # Syntax error: "(" unexpected
e2fsprogs # same
fakeroot # shift: 28: can't shift that many
gnupg2 # Syntax error: "(" unexpected
util-linux-ng # same
kernel26 # shift: 145: can't shift that many
libbonobo # shift: 22: can't shift that many
libidn # Syntax error: "(" unexpected
syslog-ng # shift: 13: can't shift that many
tar # Syntax error: "(" unexpected

Steps to reproduce:
- install dash
- make /bin/sh a symlink to /bin/dash
- try to upgrade by sudo pacman -Syu or install one of packages listed above.
This task depends upon

Closed by  Roman Kyrylych (Romashka)
Saturday, 23 January 2010, 16:49 GMT
Reason for closing:  Deferred
Additional comments about closing:  3 new bugreports were opened, 2 are closed already.
Comment by Xavier (shining) - Saturday, 14 March 2009, 17:32 GMT
You need to fix all scriptlets from all packages and remove the three stupid useless lines at the end.
Comment by Ramil (gravicappa) - Monday, 16 March 2009, 07:32 GMT
I think the problem is that pacman runs install scripts by sh instead of explicitely use bash.
Comment by Aaron Griffin (phrakture) - Monday, 16 March 2009, 22:24 GMT
Scriptlets should be /bin/sh compatible, but they are not. Arch is not guaranteed to work with /bin/sh linked to dash (yet).

You are welcome to submit patches or bug reports for packages which fail under dash, however
Comment by Ramil (gravicappa) - Tuesday, 17 March 2009, 08:44 GMT
Here is the patches for core and extra repos. I am not able to test all of them though.
Comment by Xavier (shining) - Tuesday, 04 August 2009, 18:58 GMT
Ramil : how did you create these patches? was it entirely automated?
they are probably outdated by now
Comment by Ramil (gravicappa) - Tuesday, 04 August 2009, 19:21 GMT
It was partially automated. Here are scripts I used.
Comment by Richard Gill (riri) - Tuesday, 04 August 2009, 20:04 GMT
Xavier, I started to isolate broken packages on my installation, first listing packages containing an install script.

I got the same error than this bug report mentions directly in the first one (autoconf). The fact is that 2 kinds of errors occur :
* using array variables, almost for info filelists (this can be easily modified to a portable syntax manually (see commented lines below) :

#filelist=(first.info second.info)
filelist='first.info second.info'

post_install() {
#for file in ${filelist[@]}; do
for file in $filelist; do # or with braces : ${filelist}
...
}

pre_remove() {
#for file in ${filelist[@]}; do
for file in $filelist; do
...
}

* using the shift instruction alone on its line when no argument is specified by pacman : $# -lt 1 - if any argumnt, this could be changed in

if [ $# -gt 0 ]; then
op=$1
shift
$op "$@" # note the "$@" instead of $*, which is a better practice (better management of quoting)
fi

this's more verbose, but the action is still their, and ok if arguments are specified or not to the script

I can try to make a script to do the two mentionned transformations (if all the repos can be checked and modified with that, it would be cool).
However, maybe their are other quirks, I did not tried all install scripts with dash -c ". /var/lib/pacman/local/package_name/install"
Comment by Aaron Griffin (phrakture) - Tuesday, 04 August 2009, 23:17 GMT
The shift junk can be completely removed - it is old and a hold-over. We don't do it that way anymore
Comment by Allan McRae (Allan) - Wednesday, 05 August 2009, 01:30 GMT
grep "^shift$" $(find /var/abs -name *.install)

388 packages need fixed. So I suggest we start there. I will open separate bug reports for packages in core, extra and community (i.e. 3 bug reports).


   shift.txt (16.6 KiB)
Comment by Xavier (shining) - Wednesday, 05 August 2009, 15:23 GMT
Ramil, thanks a lot for all the info.

I completely overlooked there were so many scripts using arrays, for the info files, and that this was not compatible.

And even if someone commit all these changes, it would still need all packages to be rebuilt. Considering the number of affected packages, it will take ages.

So yeah, maybe pacman should just call /bin/bash :P
Comment by Gavin Bisesi (Daenyth) - Wednesday, 11 November 2009, 15:24 GMT
Allan: I haven't noticed those bug reports, can you link to them from here if they've been opened?

I also don't think pacman should call bash, sh *should* be fine... Do the packaging guidelines on the wiki mention not to use bashisms?
Comment by Loui Chang (louipc) - Wednesday, 11 November 2009, 22:50 GMT
See 'Related Tasks'
Just now, I've removed the legacy lines from scripts in community.
Comment by Gavin Bisesi (Daenyth) - Wednesday, 11 November 2009, 23:05 GMT
Ahh, forgot that related ones are on a tab :)

Loading...