# Downgrading glibc

## krinn

I wonder why i only make topics for crazy weirdos that will break their gentoo...

But here's another "breakmygentoo" thread.

Downgrading glibc is really something you shouldn't do, as it will certainly break your gentoo but if you're like me and know that you will certainly break your gentoo BUT really wish to downgrade glibc anyway, here's how you can do it.

Portage will refuse to do it and stop with a security error message you should really follow instead of this thread.

WARNING: DO NOT DO THIS EXCEPT IF YOU CLEARLY UNDERSTAND THAT YOUR GENTOO WILL BE BROKEN !

So the purpose of this thread is to disable portage security and do downgrade your glibc (and i do hope you know well how your system works else you will just break your gentoo)

In my example i'll switch back from glibc-2.12.1-r1 to glibc-2.11.2

You will have good chance to success if you're just trying to get back to a previous glibc version your system was using, but if you are trying to downgrade to a previous glibc version nothing was build against, you're in the best path to break your system.

You have some safer (if downgrading glibc could be considered safe) ways to do that using another glibc version put on a directory to work with it... But this way is the gentoo way (by gentoo way, i'm not saying gentoo way to do it, as gentoo way is clear: portage don't allow you to do that ! But gentoo way as "doing it with portage"), to just let portage undo a bad glibc upgrade you didn't catch.

0: you better build a livecd, because chance you'll kill your gentoo are more than high

1: backup gcc & glibc 

```
quickpkg gcc glibc
```

2: you should find a gcc that was built with the previous glibc, it's best way to success

If you don't know if you have a gcc that was built against a previous glibc then you will get in trouble as you should know what you are doing, else you can try finding it with genlop

2a: finding where the "bad" glibc was emerge

```
genlop -t glibc

     Fri Sep 17 00:55:01 2010 >>> sys-libs/glibc-2.12.1-r1

       merge time: 14 minutes and 40 seconds.

```

2b: same but for gcc

```
genlop -t gcc

     Thu Jul 15 13:25:12 2010 >>> sys-devel/gcc-4.3.2-r4

       merge time: 19 minutes and 44 seconds.

```

As that gcc version was emerge before the glibc one, it means it still use a previous glibc version, good candidate for me (even i didn't took time to check what glibc was used to build that one at that time, but hey! If you're still reading this, you should know you don't really care to break your gentoo

step3: optional, but this will prevent you getting again in trouble later, mask that fu@@@@@ glibc version

```
echo ">sys-libs/glibc-2.12.1" >> /etc/portage/package.mask
```

(check with an emerge -pv glibc run after that your masking is good, this one work to mask it because 2.12.1-r1 and no 2.12.1 exist)

step4: removing portage security

```
cd /usr/portage/sys-libs/glibc/files/eblits

nano pkg_setup.eblit
```

Now you'll have to find the checking, line 12 for me, you should see the portage warning

```
                        eerror "Sanity check to keep you from breaking your sys$

                        eerror " Downgrading glibc is not supported and a sure $

                        die "aborting to save your system"  
```

Just disable the die (a simple # to comment it out), message will still be output, but portage will continue so. Line will look like that then

```
#                        die "aborting to save your system"
```

step5: now bypass the portage checksum security

```
cd ../..

pwd

## just to output where you should be now

/usr/portage/sys-libs/glibc

ebuild glibc-2.11.2.ebuild digest

>>> Creating Manifest for /usr/portage/sys-libs/glibc
```

step6: switch to your "should work" gcc version

```
gcc-config i686-pc-linux-gnu-4.3.2

source /etc/profile
```

step7: downgrading glibc THIS IS YOUR LAST CHANCE TO STOP THE CARNAGE !

```
emerge -1 glibc
```

step8: cleaning your toolchain (if you're lucky enough)

```
emerge -1 gcc && emerge -1 glibc && emerge -1 gcc
```

step9:

9a: resync your tree to remove the changes you've made to the manifest & eblit file

9b emerge -e world or look for the thread i've made to rebuild only package that were build against the "bad" glibc version. ->> https://forums.gentoo.org/viewtopic-t-842667.html

If something goes bad, you can still use "emerge -k gcc/glibc" you've backup or you're dead and need tinderbox/livecd help.

Don't say you've didn't  get warn before...

----------

## aCOSwt

<trolling>

 *krinn wrote:*   

> I wonder why i only make topics for crazy weirdos that will break their gentoo...

 

Being personally a krinn's topics reader, I take this as a personal attack I think I should report against !   :Wink: 

 *krinn wrote:*   

> But here's another "breakmygentoo" thread.

 

What do you mean by another ? (Monty python 4.3 intonation)

Should I understand that the preceeding advice you gave me and other crazy-weirdos (while we were not known by ourselves as crazy-weirdos) was a trick to break our gentoo ?

Hmmm... should report you for this.  :Evil or Very Mad: 

 *krinn wrote:*   

> Downgrading glibc is really something you shouldn't do

 

Hmmm... who wrote recently some kind of howto I had personally found very interesting about how to restore a system to the state it had on a certain date ?

=> potentially downgrading glibc ?  :Twisted Evil: 

 *krinn wrote:*   

> ]Portage will refuse to do it and stop with a security error message you should really follow instead of this thread.
> 
> WARNING: DO NOT DO THIS EXCEPT IF YOU CLEARLY UNDERSTAND THAT YOUR GENTOO WILL BE BROKEN !

 

Gonna fill a bug about this and ask for some change in the wording : "Warning : You are following an advice from krinn you crazy weirdos !"

</trolling>

BTW... Thanks for the tip !

----------

## krinn

You can report all you wish, but after that any mod could only agree with me you're a weirdo now  :Smile: 

Guys that need to follow my advices are like me, users that update things without taking care of what they are doing, and then try to undo the mistakes.

I would say, noob user, sadly as i'm not really new at gentoo, i think "lame" may fit better.

So i prefer call me a "weirdo user" than "lame user", it looks more friendly and lesser the shame a bit.

Must be why i can only do howto for only a few audience, the ones as weird as me that keep crashing their gentoo but prefer tweak it to death instead of reinstalling it.

Jesus ! lame & lazy, i really prefer weirdo  :Very Happy: 

----------

## Jacekalex

Thank you

Very good Howto

In my broke after upgrading to glibc-2.12.1-r1, the system solved thanks to your howto.   :Very Happy: 

My native language is Polish, sorry for bad English.

Thanks

 :Very Happy: 

----------

## krinn

Thank you, i could make 100 howtos easy to follow on how to break the distro also.

----------

## NeddySeagoon

krinn,

You have more followers than this guide

----------

## krinn

Maybe some followers, but having some "crazy weirdos" followers isn't really a good sign  :Smile: 

Ring me back if i ever get some workshippers

----------

## jseymour

Here is another you have helped with this post. Thanks so much. And note to self -- stay with current stable glibc.  :Very Happy: 

----------

## clytle374

Thanks for the info.  I'm trying to build Linuxcnc which requires a rtai(realtime) kernel.  After trying and fighting kernel/rtai combos for a month, I decided it must be a glib/glibc/gcc issue. Since it builds but always exhibits the same failure during initializing a pci card.   

I tried your guide as a last ditch effort.  It was a new install, so everything was built against the new glibc.  Even sh broke  :Smile:   I was adequately warned, no hard feelings. And since it didn't work, I had nothing to loose anyway.

At this point I'm giving up, for now, on building a Gentoo system to run it.  I'll have to use the Ubuntu disk it comes with.  

Would it be possible to downgrade those packages during the install while still chrooted?  Sorry, that answer is way beyond my state of awareness.

Thanks

Cory

----------

## krinn

I'm sorry, except if you boostrap a new system from stage1 to have your own glibc version, you can't success, as soon as a newer glibc is install and criticals tools are build against it, you're dead. Just as an easy example, gcc should be first program you will rebuild with the downgraded glibc version, but to build it, you will need... gcc, and that gcc will be in a state where it expect all functions, files... that were provided by the newer glibc. Kinda a dead end.

----------

## Kollin

BIG FAT WARNING: WHEN YOU DO THIS WITH GLIBC-2.15--->GLIBC-2.14 THE FIRST THING THAT BREAKES IS BASH!!!  

----------

## megabaks

o_O?

edit eblits...broken bash..."should work" gcc version ...are you crazy?

```
#!/bin/bash

[[ ${1} == "" ]] && echo -e "Usage: bash ${0} [VERSION] [ARCH] \nexample: bash ${0} 2.14.1-r2 32" && exit 1

[[ ${2} == "" ]] && echo -e "Usage: bash ${0} [VERSION] [ARCH] \nexample: bash ${0} 2.14.1-r2 32" && exit 1

AVAILABLE=`emerge -p glibc | awk '/sys-libs\/glibc/ {print $4}'`

[[ "${AVAILABLE/sys-libs\/glibc-/}" > "${1}" ]] && echo -e "you need mask:\n>sys-libs/glibc-${1}" && exit 1

##### find and define some stuff

export "$(emerge --info | grep 'PORTDIR=' | tr -d \")"

export "$(emerge --info | grep 'PORTAGE_TMPDIR=' | tr -d \")"

export "$(emerge --info | grep 'CFLAGS=' | tr -d \")"

export "$(emerge --info | grep 'CXXFLAGS=' | tr -d \")"

export "$(emerge --info | grep 'LDFLAGS=' | tr -d \")"

DIR="${PORTAGE_TMPDIR}/portage/sys-libs/glibc-${1}/image"

##### binary package for subj

quickpkg sys-libs/glibc

##### you need to make portage think that it has not installed glibc yet

rm -Rf /var/db/pkg/sys-libs/glibc-*

##### compile target glibc

ebuild ${PORTDIR}/sys-libs/glibc/glibc-${1}.ebuild clean install || exit 1

##### fix environment

case ${2} in

32 ) export LDFLAGS="-L${DIR}/lib -L${DIR}/usr/lib $LDFLAGS";;

64 ) export LDFLAGS="-L${DIR}/lib64 -L${DIR}/usr/lib64 -L${DIR}/lib32 -L${DIR}/usr/lib32 $LDFLAGS";;

esac

export CXXFLAGS="-I${DIR}/usr/include $CXXFLAGS"

export CFLAGS="-I${DIR}/usr/include $CFLAGS"

##### let's go

ALL_TARGETS="$(emerge -pve system | awk '/ebuild/ {print $4}' | grep -v libc | grep -v 'dev-lang/python' )"

for target in ${ALL_TARGETS};do

  export TARGETS+=" =${target}"

done

emerge -avO1 --keep-going=y ${TARGETS}

##### we need rebuild current python

VER="$(python -V 2>&1 | awk '{print $2}')"

CURRENT_PYTHON="$(ls -1 /var/db/pkg/dev-lang/ | grep python-${VER}*)"

ebuild ${PORTDIR}/dev-lang/python/${CURRENT_PYTHON}.ebuild clean configure

sed -e "s|BASECFLAGS=|BASECFLAGS= -I${DIR}/usr/include |" \

    -i ${PORTAGE_TMPDIR}/portage/dev-lang/${CURRENT_PYTHON}/work/Python-${VER}/Makefile

ebuild ${PORTDIR}/dev-lang/python/${CURRENT_PYTHON}.ebuild merge

##### unset previously defined vars

unset LDFLAGS CXXFLAGS CFLAGS 

##### workaround for glib/pkgconfig

FFI_VER="$(ls -1 /var/db/pkg/dev-libs/ | grep libffi)"

case ${2} in

32 ) export LIBFFI_LIBS="-L/usr/lib -lffi" && export LIBFFI_CFLAGS="-I/usr/lib/${FFI_VER}/include";;

64 ) export LIBFFI_LIBS="-L/usr/lib64 -L/usr/lib32/ -lffi" && export LIBFFI_CFLAGS="-I/usr/lib64/${FFI_VER}/include -I/usr/lib32/${FFI_VER}/include";;

esac

##### rebuild system

emerge -aveD --keep-going=y system

emerge -aveD --keep-going=y world
```

enjoy

for details use this ---> http://ru.gentoo-wiki.com/wiki/Откат_(downgrade)_glibc  (russian)

sorry my bad english

----------

## xaviermiller

Hello,

The eblit hack don't work with binary packages. In my case, I had to temporary redefine die() in Portage in order to downgrade glibc (gcc was broken with the new version of glibc).

----------

## Moderato

"Crazy" or not, but I sadly needed to downgrade my glibc package today, since I started with a multilib stage3, but (temporarily) switched to a no-multilib profile in order to update a few packages as the first thing in the clean stage3 system to cut down on dependencies. Due to stupidity, I haven't reverted to the multilib profile afterwards and instead went on with upgrading glibc. Later at some point I wondered about missing ABI_X86 expand flags, and sure enough the breakage only then struck me.

I wasn't able to just rebuild glibc in a multilib fashion, naturally, since it lacked the gnu/stubs-32.h header file and probably others as well.

Luckily I was able to rectify this situation by checkout out another clean stage3 instance, saving a binpkg of this glibc package, manipulating it to allow for downgrades and install it in the broken system. This unbroke my now-multilib-again system.

 *xaviermiller wrote:*   

> Hello,
> 
> The eblit hack don't work with binary packages. In my case, I had to temporary redefine die() in Portage in order to downgrade glibc (gcc was broken with the new version of glibc).

 

Just to make that clear: naturally binpkgs won't be affected by any direct change in the portage tree, as all necessary scripts are (sanely) incorporated in the environment file that is saved in binpkgs. When binpkgs are installed, this (and other) metadata is unpacked and used. The "more correct" way would have been to edit the bundled package metadata in this case, instead of breaking the "die" command.

For sanity, I'll refrain from actually telling people how to do this in detail, but this pointer should help enough: https://wiki.gentoo.org/wiki/Binary_package_guide#Advanced_topics

----------

## LdBeth

Static link most of your tool chains first, then you might get more chance to success .

----------

## wim-x

In 2.29-r2, an I_ALLOW_TO_BREAK_MY_SYSTEM option was introduced to be able to downgrade when calling emerge.

----------

## NeddySeagoon

Moderato,

See also  Fix My Gentoo

I've had to do use the tar method a number of times after distcc broke my glibc.

I've not tried it on a live filesystem. That would be very risky.

----------

## krinn

i like the variable name chosen to allow this  :Smile: 

----------

