Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have been running Debian Wheezy for a long time. Today I ran a dpkg upgrade, which has somehow broken things badly. The upgrade aborted, and now apt-get and dpkg are not running.

# dpkg
dpkg: error while loading shared libraries: libselinux.so.1: cannot open shared object file: No such file or directory

I can download the .deb files that contain the missing files, but I cannot install them without working tools. How do I get out of this catch 22?

share|improve this question
    
Boot from a live cd and install the deb. I think you can pass a chroot argument to dpkg. –  strugee Jun 24 '13 at 22:31
    
can you locate libselinux.so.1 on your system. you can also check ldd /usr/bin/dpkg for missing dependencies on dpkg. –  Raza Jun 24 '13 at 22:39
    
Actually, ldd has missing dependencies :S –  Thorarin Jun 24 '13 at 22:53

2 Answers 2

You can extract the contents of a .deb file using a combination of the ar and tar commands:

mkdir /tmp/selinux
cd /tmp/selinux
ar p /path/to/libselinux.deb data.tar.gz | tar xz

This the contents of the package will be unpacked in a hierarchy rooted at your current directory, and you can move the required files to the appropriate place. For libselinux this is likely to be just /lib/x86_64-linux-gnu/libselinux.so.1 (directory name depending on your architecture).

Once you have that working again, you should probably use dpkg -i to reinstall the full package.

share|improve this answer
    
I managed to place back the file in that directory (using a different method, but this looks nice), but it's still giving me the same error. It seems to be looking in the wrong place... work in progress :) –  Thorarin Jun 24 '13 at 22:54
1  
It may help to run ldconfig after putting the library back in place. –  qqx Jun 24 '13 at 23:47
    
You should also check that there's a file in /etc/ld.so.conf.d/ which lists the directory where the library is located. On my system it's listed in /etc/ld.so.conf.d/x86_64-linux-gnu.conf. –  qqx Jun 25 '13 at 0:05
    
Or it may be that ldconfig is what got hosed in the first place. –  tripleee Jun 25 '13 at 5:05
    
@qqx That file was there with the proper directory. I hadn't tried ldconfig. I managed to get dpkg running again but while fixing some package conflicts things got broken even more badly. Now trying a rescue CD. –  Thorarin Jun 25 '13 at 7:55

Library files in the standard directories must be registered in a cache for performance. If the upgrade aborted at the wrong time, it's possible that you have library files that are present in the filesystem but not in the cache. Run ldconfig as root to update the cache.

To help troubleshoot dynamic library problems, it can help to have some statically linked utility suites: busybox-static, sash, zsh-static.

share|improve this answer
    
The busybox-static package turned out to be quite useful. –  Thorarin Jun 25 '13 at 14:15

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.