rpmstrap using /bin/sh when it should use /bin/bash

Bug #64032 reported by Chmouel Boudjnah
22
Affects Status Importance Assigned to Milestone
rpmstrap (Debian)
Fix Released
Unknown
rpmstrap (Ubuntu)
Fix Released
Medium
Unassigned
Declined for Feisty by Cesare Tirabassi
Gutsy
Fix Released
Medium
Unassigned
Hardy
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: rpmstrap

rpmstrap does not work with the default edgy shell 'dash' it should be set as /bin/bash

Revision history for this message
pajgrant (patrick-some) wrote :

Just confirming this bug. Can be worked around by running:

/bin/bash /usr/bin/rpmstrap

Revision history for this message
Olly Betts (ojwb) wrote :

I've just run into this too, and can also confirm that using bash instead seems to allow rpmstrap to work correctly (I made a copy earlier on my path than /usr/bin and changed the #! line to "#!/bin/bash").

Revision history for this message
Dan O'Huiginn (daniel-ohuiginn) wrote :

This is trivial to fix, but first I'd like to get some upstream input on whether making the change is likely to break anything else.

Please could (any of) you give some more information on exactly what breaks with the existing package?

Revision history for this message
Dan O'Huiginn (daniel-ohuiginn) wrote :

Never mind about that information; here's what happens in my case. Running first without, and then with bash.

root@zembla:/tmp# rpmstrap --download-only centos4 centos4-rpms
local: 299: -e: bad variable name
basename: invalid option -- e
Try `basename --help' for more information.
wget: option requires an argument -- O
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
basename: invalid option -- e
Try `basename --help' for more information.
rpmstrap: critical error: Could not obtain -e from http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/

root@zembla:/tmp# bash rpmstrap --download-only centos4 centos4-rpms
[works OK]
root@zembla:/tmp#

Changed in rpmstrap:
assignee: nobody → daniel-ohuiginn
importance: Undecided → Medium
status: Unconfirmed → In Progress
Revision history for this message
Olly Betts (ojwb) wrote :

Indeed - it's just fallout from Ubuntu edgy making /bin/sh invoke dash rather than bash. Linux distros have traditionally always used bash, and coders have either just assumed that would always be true, or accidentally used bash extensions without realising they weren't portable (because they worked fine when the script was tested on Linux).

(Rereading that, it sounds a bit negative about /bin/sh being dash - on the contrary I think it's an excellent move - in the long term it'll help make Free Software more portable, and the short term pain can easily be worked around by fixing the #! line to use bash...)

The first bashism seems to be:

PROGNAME=${0##*/}

It seems better not to diverge too much from upstream, so I think just changing the interpreter in the #! line is a better fix than trying to eliminate all the bashisms.

It would be good to get this fixed - the fix is low risk (since /bin/sh used to *BE* /bin/bash) and it clearly doesn't work at all right now so it would be hard to make things worse...

Revision history for this message
Dan O'Huiginn (daniel-ohuiginn) wrote :

OK, here's a debdiff. I've only altered the main script; there are several other scripts in the package using #!/bin/sh, but I've left them alone for now

Revision history for this message
robos (robos) wrote :

Just used it in feisty beta and there the problem still persists. 0.5.2-2 is the version installed there.
Robos

Revision history for this message
Dan O'Huiginn (daniel-ohuiginn) wrote :

robos,
I'm afraid my patch didn't/won't make it into Feisty. You can apt-get source and apply the debdiff if you like, although it's probably easier just to edit the script in the way Olly describes above.

Revision history for this message
Steve Kowalik (stevenk) wrote :

There is nothing for Ubuntu-universe-sponsors to upload, please resubscribe us where there is.

Revision history for this message
Dan O'Huiginn (daniel-ohuiginn) wrote :

Steve: there's a debdiff in comment 6. Is there something else you need before it is ready for upload?

Revision history for this message
Olly Betts (ojwb) wrote :

Dan: I don't think Steve saw your last comment - he said: "please resubscribe us where there is" and looking at the subscribers, I don't see him or Ubuntu-universe-sponsors there currently...

I'm tempted to readd them myself, but I'm not sure what the etiquette is here.

Revision history for this message
Alvin Cura (alvinc) wrote :

Will this be fixed in gutsy?

I can confirm my own experience with the problem. It has to do the the "echo -e" statements in /usr/lib/rpmstrap/functions which don't work in dash.

Revision history for this message
Olly Betts (ojwb) wrote :

It's not fixed in the gutsy RC. I imagine it should qualify for an incremental update - rpmstrap currently just doesn't work if your /bin/sh is dash, which is the Ubuntu default since edgy. Changing the #! line to #!/bin/bash is pretty safe as the package would have been running with /bin/bash on dapper and earlier anyway.

Revision history for this message
Olly Betts (ojwb) wrote :

I've just resubscribed ubuntu-universe-sponsors. There's a debdiff in comment#6 which fixes this bug. If there's more you need, please say!

Revision history for this message
Cesare Tirabassi (norsetto) wrote :

Yes, since gutsy is frozen, the patch needs to be redone for gutsy-proposed.
I'm unsubscribing u-u-s, please subscribe motu-uvf once the patch is ready.

Changed in rpmstrap:
status: Unknown → New
Revision history for this message
Cesare Tirabassi (norsetto) wrote :

Dan doesn't seem to be active since April, so I made the necessary corrections myself to be able to get this into gutsy.

Changed in rpmstrap:
assignee: daniel-ohuiginn → nobody
status: In Progress → New
Revision history for this message
Cesare Tirabassi (norsetto) wrote :

Just in case, here is the build log.
Install log:

cesare@norsetto:~/rpmstrap$ sudo dpkg -i buildresult/rpmstrap_0.5.2-2ubuntu1_all.deb
Selecting previously deselected package rpmstrap.
(Reading database ... 92910 files and directories currently installed.)
Unpacking rpmstrap (from .../rpmstrap_0.5.2-2ubuntu1_all.deb) ...
Setting up rpmstrap (0.5.2-2ubuntu1) ...

Run:

cesare@norsetto:~/rpmstrap$ rpmstrap --download-only centos4 centos4-rpms
cesare@norsetto:~/rpmstrap$ ll centos4-rpms
total 9616
-rw-r--r-- 1 cesare cesare 0 2007-10-18 12:57 audit-1.0.12-1.EL4.x86_64.rpm
-rw-r--r-- 1 cesare cesare 0 2007-10-18 12:57 audit-libs-1.0.12-1.EL4.x86_64.rpm
<cut>

Changed in rpmstrap:
assignee: nobody → norsetto
status: New → In Progress
Revision history for this message
Scott Kitterman (kitterman) wrote :

Ack from motu-uvf. Please use ubuntu0.1 and save ubuntu1 for Hardy.

Changed in rpmstrap:
assignee: norsetto → nobody
status: In Progress → Fix Committed
Revision history for this message
Martin Pitt (pitti) wrote :

Accepted into gutsy-proposed, please test. Please note that "fix committed" should not be set until the package is actually in -proposed (i. e. now), not just in the queue (see SRU procedure).

Revision history for this message
Cesare Tirabassi (norsetto) wrote :

I have succesfull tested the command of comment #4 (see comment #17).
Any invocation should do as a test though.

Revision history for this message
Cesare Tirabassi (norsetto) wrote :

To test it, please add the following line to your sources.list:

deb http://archive.ubuntu.com/ubuntu/ gutsy-proposed universe

Then, update and upgrade (or install) rpmstrap.

Please provide feedback here.

Note that if we don't get 2 positive feedbacks this will not go through.

Revision history for this message
Olly Betts (ojwb) wrote :

I added the line to sources.list and upgraded rpmstrap (but not the other unrelated update from there).

This fixes this problem for me.

Revision history for this message
Alvin Cura (alvinc) wrote :

Confirmed: Fix is working with Fedora Core 4 (Stentz) script (with regard to parsing the array of packages). Output is attached.

HOWEVER! The rpm installation actions are failing. I have not yet looked into why. If anyone already knows why, I'd appreciate some info rather than spending too much time on it.

Environment:
alvinc@fai:~$ uname -a ; dpkg-query -l rpmstrap
Linux fai 2.6.22-14-xen #1 SMP Sun Oct 14 23:20:20 GMT 2007 x86_64 GNU/Linux
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
ii rpmstrap 0.5.2-2ubuntu0 bootstrap a basic RPM-based system

Revision history for this message
Alvin Cura (alvinc) wrote :

Additional info (verifying that the wget on the array works):

root@fai:/tmp/rpmstrap.295074023# ls
basesystem-8.0-4.noarch.rpm libacl-2.2.23-5.x86_64.rpm
bash-3.0-17.x86_64.rpm libattr-2.4.16-3.i386.rpm
chkconfig-1.3.11.1-1.x86_64.rpm libattr-2.4.16-3.x86_64.rpm
cracklib-2.7-28.i386.rpm libgcc-3.4.2-6.fc3.i386.rpm
cracklib-2.7-28.x86_64.rpm libgcc-3.4.2-6.fc3.x86_64.rpm
cracklib-dicts-2.7-28.x86_64.rpm libselinux-1.17.14-1.i386.rpm
db4-4.2.52-6.i386.rpm libselinux-1.17.14-1.x86_64.rpm
db4-4.2.52-6.x86_64.rpm libstdc++-3.4.2-6.fc3.i386.rpm
e2fsprogs-1.35-11.2.i386.rpm libstdc++-3.4.2-6.fc3.x86_64.rpm
e2fsprogs-1.35-11.2.x86_64.rpm libtermcap-2.0.8-39.x86_64.rpm
ethtool-1.8-4.x86_64.rpm mingetty-1.07-3.x86_64.rpm
fedora-release-3-9.x86_64.rpm mktemp-1.5-10.x86_64.rpm
filesystem-2.3.0-1.x86_64.rpm ncurses-5.4-13.i386.rpm
findutils-4.1.20-7.x86_64.rpm ncurses-5.4-13.x86_64.rpm
gawk-3.1.3-9.x86_64.rpm net-tools-1.60-37.x86_64.rpm
glib-1.2.10-15.x86_64.rpm pcre-4.5-3.x86_64.rpm
glib2-2.4.7-1.i386.rpm popt-1.9.1-21.i386.rpm
glib2-2.4.7-1.x86_64.rpm popt-1.9.1-21.x86_64.rpm
glibc-2.3.3-74.i686.rpm psmisc-21.4-4.x86_64.rpm
glibc-2.3.3-74.x86_64.rpm sed-4.1.2-4.x86_64.rpm
glibc-common-2.3.3-74.x86_64.rpm setup-2.5.44-1.noarch.rpm
grep-2.5.1-31.x86_64.rpm shadow-utils-4.0.3-37.x86_64.rpm
hwdata-0.145-1.noarch.rpm tar-1.14-4.x86_64.rpm
info-4.7-5.x86_64.rpm termcap-5.4-3.noarch.rpm
iproute-2.6.9-3.x86_64.rpm tzdata-2004e-2.noarch.rpm
iputils-20020927-16.x86_64.rpm words-2-23.noarch.rpm
less-382-4.x86_64.rpm zlib-1.2.1.2-1.i386.rpm
libacl-2.2.23-5.i386.rpm zlib-1.2.1.2-1.x86_64.rpm

Again, it failure is in rpm/alien (or so it seems, I'm not sure yet)

Revision history for this message
Olly Betts (ojwb) wrote :

Looking at your log, some of the RPM URLs are no longer valid. I suspect if you look at the downloaded RPM files, some probably actually contain HTML 404 pages, or perhaps are just zero size. I'll try one of the newer supported distros (suse10.0) and see if that works, but it looks like the script needs adjusting for current download locations for at least some of the distros (and updating with newer distros ideally).

Revision history for this message
Cesare Tirabassi (norsetto) wrote :

Anyone interested in taking this project over, feel free to grab the code and go for it:

http://rpmstrap.pimpscript.net/

Revision history for this message
Olly Betts (ojwb) wrote :

I've just successfully created a chroot for i686 suse10.0.

Looking at /usr/share/doc/rpmstrap/TODO, I think the problem you are seeing is just this:

* The x86_64 (and other archs) are buggy or not yet supported.
Right now, only i[3456]86 is. These archs should be added.

Revision history for this message
Johan Euphrosine (proppy) wrote :

proppy@nekun:~/Desktop/20071022$ sudo apt-get install rpmstrap
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
  rpmstrap
1 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 31.5kB of archives.
After unpacking 0B of additional disk space will be used.
Get:1 http://archive.ubuntu.com gutsy-proposed/universe rpmstrap 0.5.2-2ubuntu0.1 [31.5kB]
Fetched 31.5kB in 0s (68.8kB/s)
(Reading database ... 136026 files and directories currently installed.)
Preparing to replace rpmstrap 0.5.2-2 (using .../rpmstrap_0.5.2-2ubuntu0.1_all.deb) ...
Unpacking replacement rpmstrap ...
Setting up rpmstrap (0.5.2-2ubuntu0.1) ...
proppy@nekun:~/Desktop/20071022$ mkdir rpmstrap
proppy@nekun:~/Desktop/20071022$ cd rpmstrap/
proppy@nekun:~/Desktop/20071022/rpmstrap$ rpmstrap --download-only centos4 centos4-rpms
proppy@nekun:~/Desktop/20071022/rpmstrap$ ls
centos4-rpms
proppy@nekun:~/Desktop/20071022/rpmstrap$ ls centos4-rpms
audit-1.0.12-1.EL4.i386.rpm
audit-libs-1.0.12-1.EL4.i386.rpm
basesystem-8.0-4.noarch.rpm
bash-3.0-19.2.i386.rpm
beecrypt-3.1.0-6.i386.rpm
[...]

Revision history for this message
Johan Euphrosine (proppy) wrote :

Works for me

Revision history for this message
Alvin Cura (alvinc) wrote : Re: [Bug 64032] Re: rpmstrap using /bin/sh when it should use /bin/bash

Hi Cesare!

I read your link briefly. The project is dead? I thought there would be
new life for it with the use of Xen.....

Revision history for this message
Olly Betts (ojwb) wrote :

I think "dead" is overstating the case. The original author is no longer interested in maintaining rpmstrap, and it would certainly benefit from updating to support newer RPM-based distros, but that doesn't mean that someone else can't take on the role of maintainer. The page Cesare linked to indicates the original author would welcome someone doing so.

I already have too many things on my plate to commit to taking over maintenance myself, but I would find being able to easily set up chroot for different distros useful, so if someone else does so, I should at least be able to test and provide the occasional patch.

But I think this is all orthogonal to this bug - the proposed update fixes the problem that this bug is about, and the rpmstrap package is now useful again, albeit for bootstrapping rather old releases on x86 only.

Revision history for this message
Alvin Cura (alvinc) wrote :

Would it be worthy then to roll it into a Launchpad team and maintain it
from there?

Revision history for this message
Cesare Tirabassi (norsetto) wrote :

rpmstrap (0.5.2-2ubuntu1) hardy; urgency=low

  * Add patch 010-fix-shebang.patch (LP: #64032):
    Change rpmstrap shebang to /bin/bash since it is a bash script
  * Modify Maintainer value to match Debian-Maintainer-Field Spec
  * Automatically regenerated debian/control and debian/rules by yada

 -- Cesare Tirabassi <email address hidden> Tue, 23 Oct 2007 17:25:42 +0200

Changed in rpmstrap:
status: Fix Committed → Fix Released
Revision history for this message
Olly Betts (ojwb) wrote :

It occurred to me to check if there are any similar tools to rpmstrap, but which are still actively supported upstream, and I quickly found "mach":

http://thomas.apestaart.org/projects/mach/

This covers most of the distributions which rpmstrap does, and a few others. The main comparative omission seem to be SuSE 10.0.

And it's packaged for Ubuntu already:

http://packages.ubuntu.com/gutsy/admin/mach

The distro list in the description seems to be a little out of date - look at the list of files to see an up-to-date list.

I've not actually tried mach out yet, but assuming it works as advertised it would probably be more productive to direct effort to fixing any shortcomings mach has compared to rpmstrap.

Revision history for this message
Cesare Tirabassi (norsetto) wrote :
Revision history for this message
Cesare Tirabassi (norsetto) wrote :

Why were the archive admins unsubscribed?
Why was ubuntu-sru subscribed (note that this is in universe)?
Has the procedure changed from https://wiki.ubuntu.com/StableReleaseUpdates#Universe ?

Revision history for this message
Martin Pitt (pitti) wrote :

Copied to gutsy-updates.

Cesare, the subscriber change was a misunderstanding, sorry.

Changed in rpmstrap:
status: Fix Committed → Fix Released
Revision history for this message
Jonathan Riddell (jr) wrote :

Ubuntu Package Archive Administrators has been unsubscribed from this bug.

Changed in rpmstrap (Debian):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.