Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

How To Downgrade Perl on Ubuntu

by Ovid (Cardinal)
on Jul 30, 2009 at 12:59 UTC ( #784595=perlmeditation: print w/replies, xml ) Need Help??

Ubuntu has recently offered a Perl upgrade to 5.10 and I accidentally accepted the upgrade. Unfortunately, since our development Perl is 5.8.8, I've encountered a few annoying problems. Since many people are confused about how to do this, I decided to slog through and figure it out. Not fun. The answers to the various problems are scattered hither and yon, making this a very unpleasant process.

First, you need to get Perl and apply a regex patch which closes a security hole (many thanks to Rufus Cable for alerting me to the patch):

wget wget +patch tar xzf perl-5.8.8.tar.gz cd perl-5.8.8 patch -p1 < ../regexp-5.8.8.patch rm -f {config,Policy}.sh sh Configure -de

Be sure to read the INSTALL file for more information about the Configure options.

At this point, everything should be fine, but you can't run make yet. Actually, you can run make, but it will likely fail. Fortunately, you can keep fixing errors and rerunning make until all errors go away.

The first problem is a strange "You haven't done a make depend yet" error. As it turns out, this is because Ubuntu has decided to link /bin/sh to /bin/dash instead of /bin/bash. It's a faster shell, but not only does it not support everything bash does, it also is less tolerant of errors. The makedepend file has an unterminated quote string, so doing this gets you over the first hurdle:

sudo ln -s /bin/bash /bin/sh

Be sure to change the symlink back after you're done if you want dash instead of bash (note that using a correct shebang line at the top of your bash scripts makes this a non-issue for you).

If you've already tried to run make, you might see this error:

makedepend: Already running, exiting

That's because it previously exited abnormally (anyone remember "abend"?) and left a .depending directory lying around. Simply remove this directory and rerun.

If you run make now, you might hit the second error:

No rule to make target `<command-line>', needed by `miniperlmain.o'.

Apparently, we filter out some of the gcc output, but it's changed over time and we missed this. The following fixes it:

perl -i~ -nle 'print unless /<command-line>/' makefile x2p/makefile

That command tells perl to edit those files in place, reprinting all lines except those containing the string <command-line>. If for some bizarre reason you don't yet have Perl installed (or if it's broken), you can edit those files manually, but it's tedious and error prone.

You can rerun make and it might be fine, but you might hit this error:

SysV.xs:7:25: error: asm/page.h: No such file or directory

Arg! I don't know what this is, but apparently it's related to the linux headers. What I don't understand is that I have them installed (sudo apt-get install linux-headers-$(uname -r)), but page.h is not symlinked in /usr/include/asm/. A locate '/page.h' | grep asm returned many candidates, but the most likely fix seemed like this:

sudo ln -s /usr/src/linux-headers-2.6.28-13/arch/x86/include/asm/page.h /usr/include/asm/page.h

Obviously, the exact page.h you're linking to will vary depending on your architecture and kernel.

Assuming all is well and make completes successfully, you can now run make test && make install and you'll have successfully downgraded perl (I would recommend you set your prefix when you run Configure to ensure that you don't overwrite the system perl. You can always set up a symlink to ensure you have the proper Perl running).

Replies are listed 'Best First'.
Re: How To Downgrade Perl on Ubuntu
by neo_ (Novice) on Jul 30, 2009 at 22:21 UTC
    First thing I did when I installed Ubuntu is  sudo rm -f /bin/dash because it mucks up my kernel builds.
      Ubuntu can be a PITA sometimes as it seems :) I'm using it on a virtual machine for a couple of years so not a big deal for me. But I'm curious, did anything break after removing it?
        No, in fact, I didn't notice anything that broke after removing dash. I'd never even heard of dash until Ubuntu.
Re: How To Downgrade Perl on Ubuntu
by Anonymous Monk on Mar 26, 2010 at 07:54 UTC
    I followed steps above exactly but got stuck with the following two test failures:
    t/op/sprintf..............................FAILED--no leader found t/op/sprintf2.............................FAILED--expected 263 tests, +saw 3
    The only thing done different on my box is the page.h location:
    > ls -l /usr/include/asm/page.h lrwxrwxrwx 1 root root 52 2010-03-26 00:02 /usr/include/asm/page.h -> +/usr/local/rhel5.amd64/usr/include/asm-x86_64/page.h
    And this is the file content:
    > ~/Downloads/perl.downgrade/perl-5.8.8$ cat /usr/include/asm/page.h #ifndef _X86_64_PAGE_H #define _X86_64_PAGE_H #endif /* _X86_64_PAGE_H */
    Does anybody have an idea why those tests fails and how to fix them? Thanks a bunch!
      I ran into exactly the same test case failures recently with RHEL 6 (2.6.32-71.el6.x86_64). So perhaps this is related to newer kernel or compilers? I'm using the RH RPM gcc distro (gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) ) and kernel 2.6.32-71. My error is:
      ... t/op/sprintf..............................FAILED--no leader found t/op/sprintf2.............................FAILED--expected 263 tests, +saw 3 ... Failed 2 test scripts out of 931, 99.79% okay.
      In my case, I utilized a standard RedHat patch from their Perl 5.8.8 devel RPM to address the asm/page.h issue. As per RHN 2006 change log, this "stop IPC/SysV.c including <asm/page.h> for getpagesize(), which is now declared by including <unistd.h>". The patch is (perl-5.8.8-no_asm_page_h.patch):
      --- perl-5.8.8/ext/IPC/SysV/SysV.xs.no_asm_page_h 2001-06-30 14:46: +07.000000000 -0400 +++ perl-5.8.8/ext/IPC/SysV/SysV.xs 2006-06-02 17:37:22.000000000 - +0400 @@ -3,9 +3,6 @@ #include "XSUB.h" #include <sys/types.h> -#ifdef __linux__ -# include <asm/page.h> -#endif #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM) #ifndef HAS_SEM # include <sys/ipc.h>
      On the original topic of downgrading Perl, specific to RHEL 6, I had to address new 64-bit default system library locations which are lib64 vs. lib. Specifically, I added this argument to Configure:
      sh ./Configure ... -Dlibpth='/usr/local/lib64 /lib64 /usr/lib64'
      This path problem is discussed in this thread:

      Anyway, any insight on the failed test issue would be much appreciated.

Re: How To Downgrade Perl on Ubuntu
by monster_monk (Initiate) on Aug 18, 2010 at 19:01 UTC
    Is this script working for ubuntu 10.04? Any one have tried? Thanks.
      I am specifically looking for 64bit version for Ubuntu 10.04. Thanks.
Re: How To Downgrade Perl on Ubuntu
by Anonymous Monk on Feb 11, 2012 at 18:55 UTC
    For me, the <command-line> lines kept getting regenerated in the file x2p/makefile every time I ran make. I had to add perl -i~ -nle 'print unless /<command-line>/' makefile x2p/makefile to the top level Makefile itself before it descended into x2p.
    translators: miniperl$(EXE_EXT) $(CONFIGPM) FORCE perl -i~ -nle 'print unless /<command-line>/' x2p/makefile @echo " "; echo " Making x2p stuff"; cd x2p; $(LDLIBPTH) + $(MAKE) all
    Thanks, Rahul
      I tried this and hit all these problems plus a new one: for some reason it failed to link with the maths library (so you get undefined symbols sin, cos etc). So I cut and pasted the failed line in the shell and added -lm at the end (cos I couldn't be bothered to fix the make file or configure script).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://784595]
Front-paged by Arunbear
and the fog begins to lift...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2017-02-20 02:57 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (293 votes). Check out past polls.