How to install specific version of a Debian/Ubuntu package using apt-get

I know so many people face a problem that the sources.list file which include the repo URLs where their system get the packages from all of these repos in that file, and the problem mostly happens when users install a recent or old version of the OS but they really need specific version of the package not the default one that apt-get usually grabs from the repos.

I usually face the same problem mostly when building something from scratch and really need specific version, here is how to follow up specific version if it exists on these repos, if not you gotta get the source code and compile it by yourself.

For example, when doing $ sudo apt-get install binutils
I was able to install binutils-2.22.6 but I really needed to install binutils-2.20.2 here is how to go for it.

$ sudo apt-cache show binutils
I was able to see the version I needed and then you might have more than one version exists, so what to do to get the specific one you need:

$ sudo apt-get install <package_name>=<package_version>
EX
$ sudo apt-get install binutils=2.20.6

This should be working fine ūüėČ

Cheers,

Build Barrelfish operating system from scratch “Development Environment on Ubuntu 12.04 LTS”

Check out this page first from barrelfish Wiki to make sure you fulfill all required packages needed before going forward¬†http://wiki.barrelfish.org/Getting_Started¬†if you don’t know how to install gcc-4.5.X from scratch or you have a different version installed on your machine, just follow my post here¬†https://ahegazi.wordpress.com/2013/11/28/build-gcc-from-scratch/¬†then keep going to get barrelfish built as follow:

1. Install ghc compiler (version 7.4.1) Check the working version of haskell used by barrelfish team first before proceeding, get the right working version at the moment barrelfish team use version 7.4.1

$ sudo apt-get install  ghc

If you can’t grab the requied version through apt-get just install it manually from¬†this page. In my case, it‚Äôs ghc-7.4.1-x86_64-unknown-linux-n.tar.bz2. Then

1
2
3
4
$ tar xjvf ghc-7.4.1-x86_64-unknown-linux-n.tar.bz2
$ cd ghc-7.4.1
$ ./configure
$ sudo make install

This will install the ghc 7.4.1 executable system-widely. If you have no root access, then you should just install in your home folder and then tweak the PATH variable to make sure the ghc-7.4.1 executable will be first found.

2. Install cabal-install

1
$ sudo apt-get install cabal-install

4. Install ghc-paths using cabal

1
2
$ cabal update
$ cabal install cabal-install   ## This is very important step
$ cabal install ghc-paths

5. Install hg

1
$ sudo apt-get install mercurial

If you will boot Barrelfish on Intel SCC, two extra steps must be performed:

1. Install the patched crbif driver

1
2
3
4
5
6
$ wget http://www.dcl.hpi.uni-potsdam.de/research/scc/crbif-dkms-1.1.3-tty.tar.bz2
$ tar xjvf crbif-dkms-1.1.3-tty.tar.bz2
$ cd crbif-dkms-1.1.3
$ make -C /lib/modules/`uname -r`/build M=`pwd` modules
$ sudo rmmod crbif
$ sudo insmod crbif.ko

http://www.dcl.hpi.uni-potsdam.de/research/scc/serial.htm

http://communities.intel.com/message/140647#140647

2. Prepare the bin2obj executable
Grab the bin2obj.c from

http://marcbug.scc-dc.com/svn/repository/trunk/linuxkernel/bin2obj/bin2obj.c

Compile it and rename the executable as bin2obj and put it somewhere the shell can find.

 

Personally this is what I have done, on an x86_64 machine with Ubuntu 12.04 LTS

$ sudo apt-get update

$ sudo apt-get install mercurial m4 binutils (binutils should be the one needed by barrelfish)

$ hg clone http://hg.barrelfish.org/barrelfish
### To start Check out this http://wiki.barrelfish.org/Getting_Started

– To remove gcc, and all of these staff with the wrong version
$ sudo apt-get –purge remove binutils ### This will remove gcc
1) We need to install GCC 4.5-2 http://superuser.com/questions/236372/how-to-build-g-4-5-2-on-ubuntu-10-04
http://blog.erdemagaoglu.com/post/3444247672/compiling-gcc-4-5-on-debian-unstable

Order is important when installing these packages:

 

## Install gmp-5.0.1 ##
#######################

$ curl -O http://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gmp/gmp-5.0.1.tar.gz
$ tar zxf gmp-5.0.1.tar.gz
$ cd gmp-5.0.1/
$ ./configure –prefix=/usr
$ sudo make
$ sudo make install
$ cd ..
## Install mpfr-3.0.0 ##
########################
$ wget http://www.mpfr.org/mpfr-3.0.0/mpfr-3.0.0.tar.gz
$ tar zxf mpfr-3.0.0.tar.gz
$ cd mpfr-3.0.0/
$ ./configure –prefix=/usr
$ sudo make
$ sudo make install
$ cd ..
## Install mpc-0.9 ##
#####################
$ wget http://www.multiprecision.org/mpc/download/mpc-0.9.tar.gz
$ tar zxf mpc-0.8.2.tar.gz
$ cd mpc-0.8.2/
$ ./configure –prefix=/usr
$ sudo make
$ sudo make install
$ cd ..
## Install ppl-0.11.1 ##
########################
$ wget wget http://bugseng.com/external/ppl/download/ftp/releases/0.11.1/ppl-0.11.1.tar.gz
$

 

## Install cloog-ppl-0.15.10 ##
###############################
$ wget http://www.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/cloog-ppl-0.15.10.tar.gz
## Install libelf-0.8.13 ##
###########################
$ wget http://fossies.org/linux/misc/libelf-0.8.13.tar.gz
$ tar xvzf libelf-0.8.13.tar.gz
$ cd libelf-0.8.13
$ ./configure –prefix=/usr
$ sudo make
$ sude make install
$ cd ..
## install gcc-4.5.2 ##
#######################
$ wget http://ftp.gnu.org/gnu/gcc/gcc-4.5.2/gcc-4.5.2.tar.gz
$ tar xvzf gcc-4.5.2.tar.gz
$ cd gcc-4.5.2
$ ./configure
$ sudo make
$ sudo make install

OR OR OR OR

$ sudo apt-get install gcc-4.5

After installation

$ sudo cp /usr/bin/gcc-4.5 /usr/bin/gcc >>
## Install Ghc latest one used by barrelfish team is 7.4.1 #
############################################################

$ cp /usr/lib/libgmp.so /usr/lib/libgmp.so.3 ## I installed it before but I just change the name
$ cp /usr/lib/x86_64-linux-gnu/libgmpxx.so /usr/lib/x86_64-linux-gnu/libgmpxx.so.3

Download it from http://www.haskell.org/ghc
tar
$ ./configure
$ sudo make install directly
$ ghc –version

 

Build gcc 4.5.X from scratch on Ubuntu

First of all just as anywhere else mentions, you need GMP, MPFR andMPC to compile gcc. But these are not enough, you will need PPL,CLOOG and libelf too. You might try these to get from debian/ubuntu repositories but you may not be able to find them. Even if you do, you may not be able to install because of the same dependency conflicts.

You really can try to grab it from ubuntu repo if you are lucky and can find the exact version you are looking for as follow:

$ sudo apt-get install gcc-4.5 g++-4.5
$ ln -s /usr/bin/gcc-4.5 /usr/bin/gcc
$ ln -s /usr/bin/g++-4.5 /usr/bin/g++

If you can’t find exact version, just got for the¬†manual way which I prefer:

I compiled all of them manually and here are the versions used:

  • gmp-5.0.1
  • mpc-0.9
  • mpfr-3.0.0
  • ppl-0.11.1
  • cloog-ppl-0.15.10
  • libelf-0.8.13
  • and of course gcc-4.5.2

Any of those require any other library than the ones in the list, i installed using apt. After ./configure && make && make installing all dependencies i did those to get a build.

mkdir gcc-build
cd gcc-build
../gcc-4.5.2/./configure --disable-ppl-version-check --enable-languages=c,c++
make -j3
make install

Creating a dir like gcc-build and building there is the preferred way of doing things, but docs say doing a build in the same directory as sources may yield unexpected results.

How to install specific version of Ubuntu/Debian package using apt-get

I know so many people face a problem that the sources.list file which include the repo URLs where their system get the packages from all of these repos in that file, and the problem mostly happens when users install a recent or old version of the OS but they really need specific version of the package not the default one that apt-get usually grabs from the repos.

I usually face the same problem mostly when building something from scratch and really need specific version, here is how to follow up specific version if it exists on these repos, if not you gotta get the source code and compile it by yourself.For example, when doing $ sudo apt-get install binutils
I was able to install binutils-2.22.6 but I really needed to install binutils-2.20.2 here is how to go for it.$ sudo apt-cache show binutils
I was able to see the version I needed and then you might have more than one version exists, so what to do to get the specific one you need:

$ sudo apt-get install <package_name>=<package_version>
EX
$ sudo apt-get install binutils=2.20.6

This should be working fine ūüėČ

Cheers,