8 config
= configparser
.RawConfigParser()
9 config
.read(os
.path
.dirname(os
.path
.realpath(__file__
)) + "/../conf/config")
11 aur_db_host
= config
.get('database', 'host')
12 aur_db_name
= config
.get('database', 'name')
13 aur_db_user
= config
.get('database', 'user')
14 aur_db_pass
= config
.get('database', 'password')
15 aur_db_socket
= config
.get('database', 'socket')
16 db_path
= config
.get('aurblup', 'db-path')
17 sync_dbs
= config
.get('aurblup', 'sync-dbs').split(' ')
18 servers
= config
.get('aurblup', 'servers').split(' ')
22 h
= pyalpm
.Handle("/", db_path
)
23 for sync_db
in sync_dbs
:
24 repo
= h
.register_syncdb(sync_db
, pyalpm
.SIG_DATABASE_OPTIONAL
)
25 repo
.servers
= [server
.replace("%s", sync_db
) for server
in servers
]
26 t
= h
.init_transaction()
30 for pkg
in repo
.pkgcache
:
31 blacklist
.add(pkg
.name
)
32 [blacklist
.add(x
) for x
in pkg
.replaces
]
34 db
= mysql
.connector
.connect(host
=aur_db_host
, user
=aur_db_user
,
35 passwd
=aur_db_pass
, db
=aur_db_name
,
36 unix_socket
=aur_db_socket
, buffered
=True)
39 cur
.execute("SELECT Name FROM PackageBlacklist")
40 oldblacklist
= set([row
[0] for row
in cur
.fetchall()])
42 for pkg
in blacklist
.difference(oldblacklist
):
43 cur
.execute("INSERT INTO PackageBlacklist (Name) VALUES (%s)", [pkg
])
44 for pkg
in oldblacklist
.difference(blacklist
):
45 cur
.execute("DELETE FROM PackageBlacklist WHERE Name = %s", [pkg
])