-
Notifications
You must be signed in to change notification settings - Fork 6
/
update.py
executable file
·69 lines (56 loc) · 2.07 KB
/
update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
import os
import requests
import re
CONFIG = """
# This file is autogenerated from update.py, don't touch
# Modify update.py instead
baseURL = "https://aflplus.plus/"
languageCode = "en-us"
title = "AFLplusplus"
publishDir = "docs"
[params]
sitename = "AFLplusplus"
description = "The AFLplusplus website"
image = "ogimage.png"
ogimage = "ogimage.png"
BookMenuBundle = "/menu"
BookLogo = 'aflpp_logo_256x256_w.png'
ReleaseName = "__REL_NAME__"
ReleaseURL = "__REL_URL__"
"""
os.system("cd AFLplusplus && git pull origin stable")
os.system("cp -v AFLplusplus/docs/*.md content/docs/")
os.system("cp -v content/docs/README.md content/docs/_index.md")
link_re = re.compile('\[(.*?)\]\((.*?)\)')
for fname in os.listdir("content/docs/"):
if not fname.endswith('.md'): continue
with open(os.path.join("content/docs/", fname)) as f:
data = f.read()
#for m in link_re.finditer(data):
def foo(m):
n = m.group(1)
l = m.group(2)
if l.startswith('http'):
return m.group()
fl = l.rsplit('#', 1)[0]
if not os.path.exists(os.path.join("content/docs/", fl)):
if not os.path.exists(os.path.join("AFLplusplus/docs/", fl)):
return m.group().replace(l, 'https://github.com/AFLplusplus/AFLplusplus/blob/stable/' + l)
return m.group().replace(l, 'https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/' + l)
return m.group().replace(l, '{{< relref "%s" >}}' % l.strip())
data = link_re.sub(foo, data)
with open(os.path.join("content/docs/", fname), 'w') as f:
f.write('''---
bookCollapseSection: true
weight: 20
type: docs
---
''' + data)
os.system("cd LibAFL && git pull origin main")
os.system("cd LibAFL/docs && mdbook build && cp -r -v book/html/* ../../static/libafl-book")
r = requests.get("https://api.github.com/repos/AFLplusplus/AFLplusplus/releases/latest")
CONFIG = CONFIG.replace("__REL_NAME__", r.json()["name"])
CONFIG = CONFIG.replace("__REL_URL__", r.json()["html_url"])
with open("config.toml", "w") as f:
f.write(CONFIG)