You are not logged in.

#1 2005-11-17 12:43:52

Cotton
Member
From: Cornwall, UK
Registered: 2004-09-17
Posts: 568

Checking installed packages

Is there a utility to get pacman to synchronise its database with packages that are actually installed?

I've recently reinstalled Arch but kept the previous /var partition.  Consequentially, pacman thinks packages are installed when they're not which leads to apps sometimes failing to run.  Reinstalling the app is not necessarily successful,  as package dependancies may not be met for similar reasons.

Is a complete Arch reinstallation the only way to solve this issue?

Offline

#2 2005-11-17 15:58:15

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Checking installed packages

hm.... you should be able to do this with a script.... Penguin will show up with bash magic, I'm sure but if you want to try it yourself, try somethng like this (UNTESTED):

pacman -Q | cut -d ' ' -f 1 >tempfile
#you may need to replace newlines with spaces in tempfile using sed
pacman -Sy
pacman -S $(cat tempfile)

Notes:
pacman -Q #list installed packages
pacman -Q |  cut -d ' ' -f 1 #only package names

Dusty

Offline

#3 2005-11-17 17:01:49

sh__
Member
Registered: 2005-07-19
Posts: 272

Re: Checking installed packages

Here's a one-liner:

pacman -Sy `pacman -Q | sed 's/ .*/ /' | tr -d 'n'`

sed does the same thing as Dusty's cut and tr eliminates newlines.

EDIT: ...and this fails if pacman -Q does not list the actually installed packages. I guess you need a way to fix /var/lib/pacman/local to match the currently installed pkgs.

Offline

#4 2005-11-17 23:38:54

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: Checking installed packages

Dusty wrote:

[..]... Penguin will show up with bash magic..[...]

BAM!

#!/bin/bash
pacman -Q | cut -d' ' -f1 | paste -s | sed 's|s| |g' >filelist
for e in `cat filelist`; do
search=`find /var/abs/ -type d -name $e`
[ ! -z $search ] && echo $e >>doable
done
pacman -Sy --noconfirm `cat doable`

make sure you have an abs tree on your system...

Offline

#5 2005-11-17 23:41:11

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Checking installed packages

I don't know enough bash to give you the details, but you could loop your way through /var/lib/pacman/local with

pacman -Q <pkgname>

and if the response is

Package "<pkgname>" was not found.

delete it.

Offline

#6 2005-11-18 20:36:20

Cotton
Member
From: Cornwall, UK
Registered: 2004-09-17
Posts: 568

Re: Checking installed packages

The locally installed apps are a special case - the main problem is how to identify the packages in pacman's now incorrect database with the contents of /usr/bin and then automatically reinstall the missing packages.

Offline

#7 2005-11-20 14:45:24

sh__
Member
Registered: 2005-07-19
Posts: 272

Re: Checking installed packages

Pacman keeps the database of installed packages in /var/lib/pacman/local. You could make a backup of /var/lib/pacman/local and check which packages are installed before the date you did the reinstall. Remove them from the database, then reinstall them with pacman.

This sorts the packages by modification time:

ls -lt /var/lib/pacman/local/

Offline

Board footer

Powered by FluxBB