Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'd like to install software packages, similar to apt-get install <foo> but:

  1. Without sudo, and
  2. Into a local directory

The purpose of this exercise is to isolate independent builds in my continuous integration server.

I don't mind compiling from source, if that's what it takes, but obviously I'd prefer the simplest approach possible. I tried apt-get source --compile <foo> as mentioned here but I can't get it working for packages like autoconf. I get the following error:

dpkg-checkbuilddeps: Unmet build dependencies: help2man

I've got help2man compiled in a local directory, but I don't know how to inform apt-get of that. Any ideas?

UPDATE: I found an answer that almost works at http://askubuntu.com/a/350/23678. The problem with chroot is that it requires sudo. The problem with apt-get source is that I don't know how to resolve dependencies. I must say, chroot looks very appealing. Is there an equivalent command that doesn't require sudo?

share|improve this question
    
I suggest that's a duplicate of this question : [askubuntu.com/questions/147654/… [1]: askubuntu.com/questions/147654/… –  user91632 Sep 27 '12 at 14:30
3  
@kamil, it's not. I'm not trying to install without network access. I'm trying to install without sudo and into a non-system directory. –  Gili Sep 27 '12 at 14:35
    
Guys, please don't downvote my question without explaining why. Thank you. –  Gili Sep 27 '12 at 15:11
    
+1 because I don't see a reason for downvote. –  January Sep 27 '12 at 16:49
    
If you don't have root on the system, you will not be able to resolve dependencies easily. It is sometimes possible, though; you would have to start installing the software in your home, starting with the bottom-most dependencies, and modifying your LD_PATH so that programs can find their libraries. However, you will fail if any of the packages requires root (or suid) to run. –  January Sep 27 '12 at 16:51
show 2 more comments

2 Answers

up vote 4 down vote accepted

This is, in general, not doable, because you would mess with the apt dependencies system.

There are two solutions:

  1. Install the source package, change into the source directory, configure and install the package irrespective of the packaging systems manually to a directory of your choice.

    apt-get source <package>
    

    This does not need root, downloads the package source, unpacks it in a directory within the current directory. You can then change to that directory, make modifications to the source, configure the installation to another target etc.

    Configuring to which installation directory the programs should go depends, however, on the particular program. Many programs use the ./configure --prefix localdir to target the installation to localdir; but this is by far not always the case.

  2. Create a chroot environment into which you will install the packages:

    debootstrap precise myfancyinstall
    

    Now you have created a dummy installation in the myfancyinstall/ directory

    chroot myfancyinstall
    

    You can use apt-get install within the chroot cage to install whatever you wish.

share|improve this answer
    
This looks promising. Using apt-get source without --compile seems to suppress the warning about unmet dependencies (allowing me to resolve them myself) –  Gili Sep 27 '12 at 14:47
    
Is there a way to get packages that have no source this way as well? –  soandos Feb 18 at 16:03
    
Solution (2) will work regardless. Otherwise, you are on your own: maybe there is another way of installing package. Or download the deb package file and unpack it with ar: ar vx mypackage.deb. Then analyse the contents of the package and find out how to install it manually. –  January Feb 18 at 21:26
add comment

using a bash shell, and acquiring the "package.deb" file (assuming pack name is "package") you can run the following command to accomplish what you want - installing the package so that your home directory is treated the same way "/" would be treated in a normal install.

This is the command:

apt-get download package; dpkg -i --force-not-root --root=$HOME package.deb

You might face some errors, such as $HOME/var/lib/dpkg/lock is missing so just create all the missing files you will get from the errors and then the install should work without sudo.

notice that if "apt-get download" doesn't work, you can try "apt download" or "apitutde download package".

if neither methods work, you can just download the package manually from http://packages.ubuntu.com/

another method would be to run the chroot command with the parameter $HOME and then installing the same way as above only without --root=$HOME. that command would bring you in a shell where "/" is your current $HOME. to return to normal mode don't forget to "exit"

good luck.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.