mkpkglists.py 1.26 KB
Newer Older
1
2
3
4
5
#!/usr/bin/python3

import datetime
import gzip

6
import aurweb.config
Lukas Fleischer's avatar
Lukas Fleischer committed
7
import aurweb.db
8

9
10
packagesfile = aurweb.config.get('mkpkglists', 'packagesfile')
pkgbasefile = aurweb.config.get('mkpkglists', 'pkgbasefile')
11

12
13

def main():
Lukas Fleischer's avatar
Lukas Fleischer committed
14
    conn = aurweb.db.Connection()
15
16
17
18
19

    datestr = datetime.datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
    pkglist_header = "# AUR package list, generated on " + datestr
    pkgbaselist_header = "# AUR package base list, generated on " + datestr

20
    with gzip.open(packagesfile, "w") as f:
21
        f.write(bytes(pkglist_header + "\n", "UTF-8"))
Lukas Fleischer's avatar
Lukas Fleischer committed
22
23
24
25
        cur = conn.execute("SELECT Packages.Name FROM Packages " +
                           "INNER JOIN PackageBases " +
                           "ON PackageBases.ID = Packages.PackageBaseID " +
                           "WHERE PackageBases.PackagerUID IS NOT NULL")
26
27
        f.writelines([bytes(x[0] + "\n", "UTF-8") for x in cur.fetchall()])

28
    with gzip.open(pkgbasefile, "w") as f:
29
        f.write(bytes(pkgbaselist_header + "\n", "UTF-8"))
Lukas Fleischer's avatar
Lukas Fleischer committed
30
31
        cur = conn.execute("SELECT Name FROM PackageBases " +
                           "WHERE PackagerUID IS NOT NULL")
32
33
        f.writelines([bytes(x[0] + "\n", "UTF-8") for x in cur.fetchall()])

Lukas Fleischer's avatar
Lukas Fleischer committed
34
    conn.close()
35
36
37
38


if __name__ == '__main__':
    main()