summaryrefslogtreecommitdiff
path: root/pcr/pactools/pt-pacfix
blob: cd128331e0c9f5490dc517e965ddc4b4730d1b66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
#
# pacfix.py: a script by pierluigi to list all the packages currently installed according to /var/log/pacman.log
#            2008-07-04: Modified by Chris Giles to prevent failure when "pacman.log" has lines with only two words


pkg=[]

logfile = open("/var/log/pacman.log","r")
log=logfile.readlines()
for myline in log:
    myarray = myline.strip("\n").split(" ")
    if len(myarray) >= 3 :
        if (myarray[2]=="installed" or myarray[2]=="upgraded"):
            if (pkg.count(myarray[3])==0):
                pkg.append(myarray[3])
        if (myarray[2]=="removed"):
            if (pkg.count(myarray[3])!=0):
                pkg.remove(myarray[3])
pkg.sort()
for p in pkg:
    print(p)