You are not logged in.
I want to figure out all the files on my system that I've installed by compiling or copying.
That is, want to remove all binaries, libraries and themes that were not installed by pacman.
"pacman -Ql >> filelest" creates a list of all files installed by pacman. The list looks like this
a2ps /etc/a2ps/a2ps-site.cfg
a2ps /etc/a2ps/a2ps.cfg
a2ps /usr/bin/a2ps
a2ps /usr/bin/card
a2ps /usr/bin/composeglyphs
a2ps /usr/bin/fixnt
Now, how can one remove the name of the package which is the first entry in each line in the above file?
How can one create a list with full paths of all files in a given directory?
My guess is that a simple script the uses sed or awk will probably do the job, but I'm no programmer.
Anyone caring to help? It would be a useful script.
Offline
I forgot to mention the obvious. That /home, /root, /proc, /tmp, /mnt, /media and /var would be excluded.
Offline
OK. Done it. But in a dirty way.
using slocate, I created a list of all files on my system
cd /
updatedb
slocate / > filelist
Sorted the list
sort filelist > filelist_sorted
Created list of files installed by pacman
pacman -Ql > pacman_raw_list
Removed the package name at the beginning of each line
cat pacman_raw_list| sed -e 's/^ *[^ ]* //' >> pacmanlist
Sorted pacmanlist
sort pacmanlist > pacmanlist_sorted
Compared both files using diff
diff filelist_sorted pacmanlist_sorted > diff_file
Now I have a diff file. The lines stating the files that wasn't installed by pacman have < at the beginning.
Lets put them aside
cat diff_file | grep "<" > dirtyfiles1
Remove the leading < from each line
cat dirtyfiles| sed -e 's/^ *[^ ]* //' > dirtyfiles2
Now dirtyfiles2 have all the files that is on my system that wasn't installed by pacman
Last edited by potentials (2007-06-15 04:36:34)
Offline
I believe you can use find instead of slocate.
I found a weird thing btw, it looked like pacman -Ql didn't list directory for almost all packages, except these ones :
pacman -Ql | grep "/$"
cups /var/spool/cups/tmp/
ttf-ms-fonts /tmp/ttf-ms-fonts/
Let's forget about this for one moment, because there is now a much bigger problem. There are many files which aren't supposed to be owned by packages. For example, /proc or /dev dir, but also, your $HOME, or pacman database in /var/lib/pacman, or abs files in /var/abs.
cat pacman_list_sorted | cut -d'/' -f2 | uniq
gives you the first level of directory to look at, but for /home or /var you need to go deeper.
Anyway, here is what I did :
pacman -Ql | cut -d' ' -f2 | sort > pacman_list_sorted
sudo find /{bin,boot,etc,home,lib,opt,sbin,tmp,usr,var} ! -type d | sort > filelist_sorted
diff pacman_list_sorted filelist_sorted |grep ">" | sed -e "s/> //"
As said above, this listed all my files in $HOME, and all files of pacman database, abs,..
So I did :
$ cat pacman_list_sorted | cut -d'/' -f2,3 | uniq |grep home
home/lighttpd
$ cat pacman_list_sorted | cut -d'/' -f2,3 | uniq |grep ^var
var/games
var/lib
var/spool
$ cat pacman_list_sorted | cut -d'/' -f2,3,4 | uniq |grep "var/lib"
var/lib/ntp
var/lib/xkb
So in my case, a more precise find is :
sudo find /{bin,boot,etc,home/lighttpd,lib,opt,sbin,tmp,usr,var/{games,lib/{ntp,xkb},spool}} ! -type d | sort > filelist_sorted
The problem using find + sort + diff is that when you've a whole directory that exists only on filesystem (for example $HOME, /var/abs, /var/lib/pacman), each files listed in it will be listed.
If this could be avoided, it would make the above problem of having to select the directories carefully irrelevant.
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline